summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog/cmoduleresultview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/searchdialog/cmoduleresultview.cpp')
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp81
1 files changed, 39 insertions, 42 deletions
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index ab4810b..5bbc32f 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,10 +18,12 @@
#include <QtAlgorithms>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -43,8 +45,6 @@ CModuleResultView::~CModuleResultView() {
/** Initializes this widget. */
void CModuleResultView::initView() {
- namespace DU = util::directory;
-
// see also csearchresultview.cpp
setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
@@ -62,7 +62,7 @@ void CModuleResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
+ m_actions.copyMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
m_actions.copyMenu->addAction(m_actions.copy.result);
@@ -72,7 +72,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
+ m_actions.saveMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
m_actions.saveMenu->addAction(m_actions.save.result);
@@ -82,7 +82,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
m_actions.printMenu->addAction(m_actions.print.result);
@@ -96,48 +96,45 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-void CModuleResultView::setupTree(
- const CSwordModuleSearch::Results &results,
- const QString &searchedText)
+void CModuleResultView::setupTree(const CSwordModuleSearch::Results & results,
+ const QString & searchedText)
{
+ /// \todo implement sorting in this method.
+
clear();
m_results = results;
- /// \todo this class is for sorting
- //util::CSortListViewItem* item = 0;
- //util::CSortListViewItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
-
qDeleteAll(m_strongsResults);
m_strongsResults.clear();
bool strongsAvailable = false;
- Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
- sword::ListKey result = results.value(m);
-
- item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
- /// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
-
- item->setIcon(0, util::tool::getIconForModule(m) );
- //----------------------------------------------------------------------
- // we need to make a decision here. Either don't show any Strong's
- // number translations, or show the first one in the search text, or
- // figure out how to show them all.
- // I choose option number 2 at this time.
- //----------------------------------------------------------------------
- int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
- if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
- QString sNumber;
- //--------------------------------------------------
- // get the strongs number from the search text
- //--------------------------------------------------
- // first find the first space after "strong:"
- // this should indicate a change in search token
- sstIndex = sstIndex + 7;
- sTokenIndex = searchedText.indexOf(" ", sstIndex);
- sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
+ Q_FOREACH(const CSwordModuleInfo * m, results.keys()) {
+ /// \todo Remove this constructor hack once sword gets it right:
+ const int count = sword::ListKey(results.value(m)).getCount();
+ QTreeWidgetItem * item = new QTreeWidgetItem(this,
+ QStringList(m->name())
+ << QString::number(count));
+
+ item->setIcon(0, util::tool::getIconForModule(m));
+ /*
+ We need to make a decision here. Either don't show any Strong's
+ number translations, or show the first one in the search text, or
+ figure out how to show them all. I choose option number 2 at this time.
+ */
+
+ // strong search text index for finding "strong:"
+ int sstIndex = searchedText.indexOf("strong:", 0);
+ if (sstIndex != -1) {
+ /*
+ Get the strongs number from the search text. First find the first
+ space after "strong:". This should indicate a change in search
+ token
+ */
+ sstIndex += 7;
+ const int sTokenIndex = searchedText.indexOf(" ", sstIndex);
+ const QString sNumber(searchedText.mid(sstIndex, sTokenIndex - sstIndex));
setupStrongsResults(m, results[m], item, sNumber);
@@ -146,7 +143,7 @@ void CModuleResultView::setupTree(
}
};
- //Allow to hide the module strongs if there are any available
+ // Allow to hide the module strongs if there are any available
setRootIsDecorated( strongsAvailable );
}
@@ -269,8 +266,8 @@ void CModuleResultView::printResult() {
CSwordModuleInfo *m = activeModule();
if (m != 0) {
CExportManager mgr(true, tr("Printing search result"));
- mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
- CBTConfig::getFilterOptionDefaults());
+ mgr.printKeyList(m_results[m], m, btConfig().getDisplayOptions(),
+ btConfig().getFilterOptions());
};
}