summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/searchdialog')
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp14
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp36
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h19
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp80
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h22
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h12
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h45
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp188
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h15
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp245
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h145
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp229
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h40
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h2
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp130
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h22
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp2
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h2
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp135
-rw-r--r--src/frontend/searchdialog/csearchdialog.h62
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp56
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h38
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp61
-rw-r--r--src/frontend/searchdialog/csearchresultview.h27
30 files changed, 970 insertions, 758 deletions
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index e638130..ece0ced 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,11 +26,14 @@ namespace Search {
static const int DIALOG_HEIGHT = 400;
static const int DIALOG_BORDER = 30;
-CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules, QWidget* parentDialog )
- : QDialog(parentDialog) {
+CSearchAnalysisDialog::CSearchAnalysisDialog(
+ const CSwordModuleSearch::Results &results,
+ QWidget *parentDialog)
+ : QDialog(parentDialog)
+{
initView();
m_analysis->reset();
- m_analysis->analyse(modules);
+ m_analysis->analyse(results);
// Set initial width based on the search data, but limit to the
// width of the desktop
@@ -39,7 +42,6 @@ CSearchAnalysisDialog::CSearchAnalysisDialog( QList<CSwordModuleInfo*> modules,
if (width > desktopWidth)
width = desktopWidth;
resize(width, DIALOG_HEIGHT);
-
}
/** Initializes this dialog. */
@@ -49,7 +51,7 @@ void CSearchAnalysisDialog::initView() {
m_analysis = new CSearchAnalysisScene(this);
m_analysisView = new CSearchAnalysisView(m_analysis, this);
-//// m_analysisView->show();
+//// m_analysisView->show();
vboxLayout->addWidget(m_analysisView);
m_buttonBox = new QDialogButtonBox(this);
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index 4bff4a0..b4edcad 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,10 @@
#include <QDialog>
-#include <QObject>
+#include "backend/cswordmodulesearch.h"
+
+// Sword includes
+#include <listkey.h>
class CSwordModuleInfo;
@@ -25,13 +28,13 @@ class CSearchAnalysisView;
class CSearchAnalysisScene;
/**
- @author The BibleTime team <info@bibletime.info>
+ @author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisDialog : public QDialog {
Q_OBJECT
public:
- CSearchAnalysisDialog(QList<CSwordModuleInfo*> modules, QWidget* parentDialog);
- ~CSearchAnalysisDialog() {}
+ CSearchAnalysisDialog(const CSwordModuleSearch::Results &results,
+ QWidget *parentDialog = 0);
protected: // Protected methods
/**
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index b2fc1ad..23b2962 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -41,13 +41,17 @@ const int LEGEND_INNER_BORDER = 5;
const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;
-CSearchAnalysisItem::CSearchAnalysisItem(const int moduleCount, const QString &bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules)
- : QGraphicsRectItem(),
- m_moduleList( modules ),
- m_scaleFactor(scaleFactor),
- m_bookName(bookname),
- m_moduleCount(moduleCount),
- m_bufferPixmap(0) {
+CSearchAnalysisItem::CSearchAnalysisItem(
+ const int moduleCount,
+ const QString &bookname,
+ double *scaleFactor,
+ const CSwordModuleSearch::Results &results)
+ : m_results(results),
+ m_scaleFactor(scaleFactor),
+ m_bookName(bookname),
+ m_moduleCount(moduleCount),
+ m_bufferPixmap(0)
+{
m_resultCountArray.resize(m_moduleCount);
int index = 0;
for (index = 0; index < m_moduleCount; ++index) m_resultCountArray[index] = 0;
@@ -137,23 +141,27 @@ int CSearchAnalysisItem::width() {
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
/// \todo Fix that loop
int i = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
+ for (RCI it = m_results.begin(); it != m_results.end(); it++) {
+ const CSwordModuleInfo *info = it.key();
+
+ /// \warning This is a workaround for sword constness
+ sword::ListKey &results = const_cast<sword::ListKey &>(it.value());
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
- CSwordModuleInfo* info = (*it);
const QColor c = CSearchAnalysisScene::getColor(i);
toolTipString.append(
- QString("<tr bgcolor=\"white\"><td><b><font color=\"#%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
- .arg(QString().sprintf("%02X%02X%02X", c.red(), c.green(), c.blue()))
+ QString("<tr bgcolor=\"white\"><td><b><font color=\"%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
+ .arg(c.name())
.arg(info ? info->name() : QString::null)
.arg( m_resultCountArray[i] )
- .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)info->searchResult().Count())*(double)100 : 0.0, 0, 'g', 2)
+ .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)results.Count())*(double)100 : 0.0, 0, 'g', 2)
);
++i;
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index d5a46a9..7db96a9 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,19 +13,19 @@
#include <QGraphicsRectItem>
#include <QGraphicsScene>
+#include "backend/cswordmodulesearch.h"
class CSwordModuleInfo;
namespace Search {
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
class CSearchAnalysisItem : public QGraphicsRectItem {
public:
+ CSearchAnalysisItem(const int moduleCount, const QString &bookname,
+ double *scaleFactor,
+ const CSwordModuleSearch::Results &results);
- CSearchAnalysisItem(const int moduleCount, const QString& bookname, double *scaleFactor, QList<CSwordModuleInfo*>* modules);
~CSearchAnalysisItem();
/**
* Sets the resultcount of this item
@@ -52,7 +52,8 @@ class CSearchAnalysisItem : public QGraphicsRectItem {
private:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
+ private: /* Fields: */
+ CSwordModuleSearch::Results m_results;
double *m_scaleFactor;
QString m_bookName;
int m_moduleCount;
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index 38b6552..c5b9d02 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -39,12 +39,6 @@ const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;
-CSearchAnalysisLegendItem::CSearchAnalysisLegendItem(QList<CSwordModuleInfo*> *list )
- : QGraphicsRectItem() {
- m_moduleList = list;
-}
-
-/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
painter->save();
@@ -61,8 +55,7 @@ void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraph
// for (unsigned int index=0; index < m_moduleList->count(); index++){
int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList->end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList->begin()); it != end_it; ++it) {
+ Q_FOREACH(const CSwordModuleInfo *m, m_moduleList) {
// the module color indicators
QPoint p1( (int)(rect().x()) + LEGEND_INNER_BORDER, (int)(rect().y()) + LEGEND_INNER_BORDER + moduleIndex*(LEGEND_DELTAY + ITEM_TEXT_SIZE) );
QPoint p2(p1.x() + ITEM_TEXT_SIZE, p1.y() + ITEM_TEXT_SIZE);
@@ -72,7 +65,7 @@ void CSearchAnalysisLegendItem::paint(QPainter* painter, const QStyleOptionGraph
painter->drawRect(r);
QPoint p3( p2.x() + LEGEND_INNER_BORDER, p2.y() );
- painter->drawText(p3, (*it)->name() );
+ painter->drawText(p3, m->name() );
++moduleIndex;
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index b3110eb..232fe64 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,19 +17,20 @@ class CSwordModuleInfo;
namespace Search {
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
class CSearchAnalysisLegendItem : public QGraphicsRectItem {
- public:
- CSearchAnalysisLegendItem(QList<CSwordModuleInfo*>* list );
+ public: /* Methods: */
+ inline CSearchAnalysisLegendItem(const QList<const CSwordModuleInfo*> &modules)
+ : m_moduleList(modules) {}
- private:
+ private: /* Methods: */
+ /** Reimplementation of QGraphicsItem::paint. */
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
- QList<CSwordModuleInfo*>* m_moduleList;
+
+ private: /* Fields: */
+ QList<const CSwordModuleInfo*> m_moduleList;
};
-}
+} // namespace Search
#endif
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index 6d486a8..e4165ab 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -51,14 +51,12 @@ CSearchAnalysisScene::CSearchAnalysisScene(QObject *parent )
setSceneRect(0, 0, 1, 1);
}
-
-QHash<QString, CSearchAnalysisItem*>* CSearchAnalysisScene::getSearchAnalysisItemList() {
- // Returns pointer to the search analysis items
- return &m_itemList;
-}
-
/** Starts the analysis of the search result. This should be called only once because QCanvas handles the updates automatically. */
-void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
+void CSearchAnalysisScene::analyse(
+ const CSwordModuleSearch::Results &results)
+{
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
/**
* Steps of analysing our search result;
* -Create the items for all available books ("Genesis" - "Revelation")
@@ -67,13 +65,13 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
* -Find out how many times we found the book
* -Set the count to the items which belongs to the book
*/
- setModules(modules);
+ setResults(results);
m_lastPosList.clear();
- const int numberOfModules = m_moduleList.count();
+ const int numberOfModules = m_results.count();
if (!numberOfModules)
return;
- m_legend = new CSearchAnalysisLegendItem(&m_moduleList);
+ m_legend = new CSearchAnalysisLegendItem(m_results.keys());
addItem(m_legend);
m_legend->setRect(LEFT_BORDER, UPPER_BORDER,
LEGEND_WIDTH, LEGEND_INNER_BORDER*2 + ITEM_TEXT_SIZE*numberOfModules + LEGEND_DELTAY*(numberOfModules - 1) );
@@ -84,20 +82,19 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
m_maxCount = 0;
int count = 0;
CSwordVerseKey key(0);
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
CSearchAnalysisItem* analysisItem = m_itemList[key.book()];
bool ok = true;
while (ok && analysisItem) {
moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ for (RCI it = m_results.begin(); it != m_results.end(); it++) {
qApp->processEvents( QEventLoop::AllEvents );
- if (!m_lastPosList.contains(*it)) {
- m_lastPosList.insert(*it, 0);
+ if (!m_lastPosList.contains(it.key())) {
+ m_lastPosList.insert(it.key(), 0);
}
- analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), *it)));
+ analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), it.key())));
m_maxCount = (count > m_maxCount) ? count : m_maxCount;
++moduleIndex;
@@ -112,25 +109,30 @@ void CSearchAnalysisScene::analyse(QList<CSwordModuleInfo*> modules) {
ok = key.next(CSwordVerseKey::UseBook);
analysisItem = m_itemList[key.book()];
}
- setSceneRect(0, 0, xPos + BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX + RIGHT_BORDER, height() );
+ setSceneRect(0, 0, xPos + BAR_WIDTH + (m_results.count() - 1)*BAR_DELTAX + RIGHT_BORDER, height() );
slotResized();
}
/** Sets the module list used for the analysis. */
-void CSearchAnalysisScene::setModules(QList<CSwordModuleInfo*> modules) {
- m_moduleList.clear();
- foreach (CSwordModuleInfo * mod, modules) {
- if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
- m_moduleList.append(mod);
+void CSearchAnalysisScene::setResults(
+ const CSwordModuleSearch::Results &results)
+{
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
+ m_results.clear();
+ for (RCI it = results.begin(); it != results.end(); it++) {
+ const CSwordModuleInfo *m = it.key();
+ if ( (m->type() == CSwordModuleInfo::Bible) || (m->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
+ m_results.insert(m, it.value());
}
}
m_itemList.clear();
CSearchAnalysisItem* analysisItem = 0;
CSwordVerseKey key(0);
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
do {
- analysisItem = new CSearchAnalysisItem(m_moduleList.count(), key.book(), &m_scaleFactor, &m_moduleList);
+ analysisItem = new CSearchAnalysisItem(m_results.count(), key.book(), &m_scaleFactor, m_results);
addItem(analysisItem);
analysisItem->hide();
m_itemList.insert(key.book(), analysisItem);
@@ -160,13 +162,13 @@ void CSearchAnalysisScene::reset() {
/** No descriptions */
void CSearchAnalysisScene::slotResized() {
- m_scaleFactor = (double)( (double)(height() - UPPER_BORDER - LOWER_BORDER - BAR_LOWER_BORDER - 100 - (m_moduleList.count() - 1) * BAR_DELTAY)
+ m_scaleFactor = (double)( (double)(height() - UPPER_BORDER - LOWER_BORDER - BAR_LOWER_BORDER - 100 - (m_results.count() - 1) * BAR_DELTAY)
/ (double)m_maxCount);
QHashIterator<QString, CSearchAnalysisItem*> it( m_itemList );
while ( it.hasNext() ) {
it.next();
if (it.value()) {
- it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_moduleList.count() - 1)*BAR_DELTAX, height() - LOWER_BORDER - BAR_LOWER_BORDER);
+ it.value()->setRect(it.value()->rect().x(), UPPER_BORDER, BAR_WIDTH + (m_results.count() - 1)*BAR_DELTAX, height() - LOWER_BORDER - BAR_LOWER_BORDER);
}
}
update();
@@ -200,9 +202,12 @@ QColor CSearchAnalysisScene::getColor(int index) {
}
}
-/** Returns the count of the book in the module */
-unsigned int CSearchAnalysisScene::getCount( const QString book, CSwordModuleInfo* module ) {
- sword::ListKey& result = module->searchResult();
+unsigned int CSearchAnalysisScene::getCount(const QString &book,
+ const CSwordModuleInfo* module)
+{
+ /// \warning This is a workaround for sword constness
+ sword::ListKey result = m_results[module];
+
const int length = book.length();
unsigned int i = m_lastPosList[module];
unsigned int count = 0;
@@ -218,6 +223,8 @@ unsigned int CSearchAnalysisScene::getCount( const QString book, CSwordModuleInf
}
void CSearchAnalysisScene::saveAsHTML() {
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
+
const QString fileName = QFileDialog::getSaveFileName(0, tr("Save Search Analysis"), QString::null, tr("HTML files (*.html;*.HTML;*.HTM;*.htm)") );
if (fileName.isEmpty()) return;
@@ -230,9 +237,8 @@ void CSearchAnalysisScene::saveAsHTML() {
const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
CSwordVerseKey key(0);
- sword::ListKey searchResult;
- key.key("Genesis 1:1");
+ key.setKey("Genesis 1:1");
CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
@@ -242,9 +248,12 @@ void CSearchAnalysisScene::saveAsHTML() {
tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
- foreach (CSwordModuleInfo* mod, m_moduleList) {
+ for (RCI it = m_results.begin(); it != m_results.end(); it++) {
+ const CSwordModuleInfo *mod = it.key();
tableTitle += QString("<th align=\"left\">") + mod->name() + QString("</th>");
- searchResult = mod->searchResult();
+
+ /// \warning This is a workaround for sword constness
+ sword::ListKey searchResult = it.value();
countStr.setNum(searchResult.Count());
tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
@@ -259,8 +268,7 @@ void CSearchAnalysisScene::saveAsHTML() {
analysisItem = m_itemList.value( key.book() );
int moduleIndex = 0;
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_moduleList.begin()); it != end_it; ++it) {
+ for (RCI it = m_results.begin(); it != m_results.end(); it++) {
count = analysisItem->getCountForModule(moduleIndex);
countStr.setNum(count);
m_searchAnalysisHTML += QString("<td align=\"right\">") + countStr + QString("</td>");
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index 2a4f171..a3a1832 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,8 +15,12 @@
#include <QColor>
#include <QHash>
#include <QMap>
+#include "backend/cswordmodulesearch.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"
+// Sword includes
+#include <listkey.h>
+
class CSwordModuleInfo;
@@ -39,16 +43,14 @@ class CSearchAnalysisScene : public QGraphicsScene {
* This should be called only once because
* QCanvas handles the updates automatically.
*/
- void analyse(QList<CSwordModuleInfo*> modules);
+ void analyse(const CSwordModuleSearch::Results &results);
+
/**
* This function returns a color for each module
* @return The color at position index in the list
*/
static QColor getColor(int index);
- /**
- * This function returns a pointer to the list of AnalysisItems
- */
- QHash<QString, CSearchAnalysisItem*>* getSearchAnalysisItemList();
+
void reset();
/**
* resize the height of the scene
@@ -65,17 +67,17 @@ class CSearchAnalysisScene : public QGraphicsScene {
void slotResized();
protected:
- void setModules(QList<CSwordModuleInfo*> modules);
+ void setResults(const CSwordModuleSearch::Results &results);
private:
/**
* Returns the count of the book in the module
*/
- unsigned int getCount( const QString book, CSwordModuleInfo* module );
+ unsigned int getCount(const QString &book, const CSwordModuleInfo *module);
- QList<CSwordModuleInfo*> m_moduleList;
+ CSwordModuleSearch::Results m_results;
QHash<QString, CSearchAnalysisItem*> m_itemList;
- QMap<CSwordModuleInfo*, unsigned int> m_lastPosList;
+ QMap<const CSwordModuleInfo*, unsigned int> m_lastPosList;
int m_maxCount;
double m_scaleFactor;
CSearchAnalysisLegendItem* m_legend;
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index 7efa604..d177f63 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index e66fc57..8d8c5f3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +22,7 @@ namespace Search {
class CSearchAnalysisScene;
/**
- @author The BibleTime team <info@bibletime.info>
+ @author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisView : public QGraphicsView {
public:
@@ -31,10 +31,10 @@ class CSearchAnalysisView : public QGraphicsView {
~CSearchAnalysisView() {}
/**
- * Returns the sizeHint for this view
- * We give back the size of the parent widgetas default.
- * This is a reimplementation from QCanvasView::sizeHint().
- */
+ * Returns the sizeHint for this view
+ * We give back the size of the parent widgetas default.
+ * This is a reimplementation from QCanvasView::sizeHint().
+ */
virtual QSize sizeHint() const;
/**
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
new file mode 100644
index 0000000..1d5f556
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
@@ -0,0 +1,58 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
+
+#include <QAction>
+#include <QToolButton>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/managers/cswordbackend.h"
+#include "util/tool.h"
+
+
+namespace {
+const QString groupingOrderKey("GUI/SearchDialog/ModuleChooserDialog/grouping");
+}
+
+BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
+ Qt::WindowFlags flags)
+ : BtModuleChooserDialog(parent, flags)
+{
+ // Initialize the tree model:
+ BtBookshelfTreeModel::Grouping grouping(groupingOrderKey);
+ BtBookshelfTreeModel *treeModel = new BtBookshelfTreeModel(grouping, this);
+ treeModel->setCheckable(true);
+ connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+
+ // Initialize the bookshelf widget:
+ bookshelfWidget()->showHideAction()->setVisible(false);
+ bookshelfWidget()->showHideButton()->hide();
+ bookshelfWidget()->setTreeModel(treeModel);
+ bookshelfWidget()->setSourceModel(CSwordBackend::instance()->model());
+
+ retranslateUi();
+}
+
+BtSearchModuleChooserDialog::~BtSearchModuleChooserDialog() {
+ // Intentionally empty
+}
+
+void BtSearchModuleChooserDialog::retranslateUi() {
+ setWindowTitle(tr("Works to Search in"));
+ util::tool::initExplanationLabel(label(), QString::null,
+ tr("Select the works which should be searched."));
+}
+
+void BtSearchModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ g.saveTo(groupingOrderKey);
+}
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.h b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
new file mode 100644
index 0000000..103682c
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
@@ -0,0 +1,45 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTSEARCHMODULECHOOSERDIALOG_H
+#define BTSEARCHMODULECHOOSERDIALOG_H
+
+#include "frontend/btmodulechooserdialog.h"
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+
+class BtBookshelfTreeModel;
+class CSwordModuleInfo;
+
+class BtSearchModuleChooserDialog: public BtModuleChooserDialog {
+ Q_OBJECT
+ public:
+ BtSearchModuleChooserDialog(QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
+ ~BtSearchModuleChooserDialog();
+
+ inline void setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
+ bookshelfWidget()->treeModel()->setCheckedModules(modules);
+ }
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return bookshelfWidget()->treeModel()->checkedModules();
+ }
+
+ protected slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
+
+ protected:
+ void retranslateUi();
+};
+
+#endif // BTSEARCHMODULECHOOSERDIALOG_H
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index 95c9218..9f76b6b 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.cpp
+++ b/src/frontend/searchdialog/btsearchoptionsarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,12 +19,12 @@
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/htmldialogs/bttabhtmldialog.h"
+#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
+#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
#include "frontend/searchdialog/crangechooserdialog.h"
-#include "frontend/searchdialog/csearchmodulechooserdialog.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
@@ -204,15 +204,15 @@ void BtSearchOptionsArea::initConnections() {
}
/** Sets the modules used by the search. */
-void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules ) {
+void BtSearchOptionsArea::setModules(const QList<const CSwordModuleInfo*> &modules) {
qDebug() << "BtSearchOptionsArea::setModules";
qDebug() << modules;
QString t;
m_modules.clear(); //remove old modules
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+ QList<const CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ for (QList<const CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) {
/// \todo Check for containsRef compat
if (*it == 0) { //don't operate on null modules.
continue;
@@ -256,24 +256,30 @@ void BtSearchOptionsArea::moduleListTextSelected(int index) {
QString text = m_modulesCombo->itemText(index);
qDebug() << text;
QStringList moduleNamesList = text.split(", ");
- QList<CSwordModuleInfo*> moduleList;
+ QList<const CSwordModuleInfo*> moduleList;
foreach(QString name, moduleNamesList) {
- moduleList.append(CPointers::backend()->findModuleByName(name));
+ moduleList.append(CSwordBackend::instance()->findModuleByName(name));
}
//set the list and the combobox list and text
setModules(moduleList);
}
void BtSearchOptionsArea::chooseModules() {
- QString title(tr("Works to Search in"));
- QString label(tr("Select the works which should be searched."));
- CSearchModuleChooserDialog* dlg = new CSearchModuleChooserDialog(this, title, label, modules());
- connect(dlg, SIGNAL(modulesChanged(QList<CSwordModuleInfo*>, QTreeWidget*)), this, SLOT(setModules(QList<CSwordModuleInfo*>)));
- dlg->exec();
-}
+ BtSearchModuleChooserDialog* dlg = new BtSearchModuleChooserDialog(this);
+ QSet<CSwordModuleInfo*> ms;
+ Q_FOREACH (const CSwordModuleInfo *module, modules()) {
+ ms.insert(const_cast<CSwordModuleInfo*>(module));
+ }
-QList<CSwordModuleInfo*> BtSearchOptionsArea::modules() const {
- return m_modules;
+ dlg->setCheckedModules(ms);
+ if (dlg->exec() == QDialog::Accepted) {
+ QList<const CSwordModuleInfo*> ms;
+ Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
+ ms.append(m);
+ }
+ setModules(ms);
+ }
+ delete dlg;
}
void BtSearchOptionsArea::reset() {
@@ -333,108 +339,8 @@ void BtSearchOptionsArea::setupRanges() {
}
void BtSearchOptionsArea::syntaxHelp() {
-
- QString style = QString(
- "<style type='text/css'>"
- "h1 a {font-size: medium}"
- "table {margin-left: 20px}"
- "td {"
- " border-width: 3px 3px 3px 3px;"
- " border-style: solid solid solid solid;"
- " border-color: white white white white;"
- " background-color: #faf0e6;"
- "}"
- "p#links {margin-left: 20px}"
- "</style>");
-
- //: Don't translate words inside <> tags!
- //: Translate 'All words' etc. indentically to the Search dialog options.
- QString intro = tr(
- "<p>"
- "This help is mainly for 'Full syntax' option. 'All words' and 'Some words' options " "have more limited syntax; <a href='#wildcards'>wildcards</a> and <a " "href='#fields'>text fields</a> are supported for them. Some other syntax features " "may give strange or wrong results with All words/Some words."
- "</p>");
-
- QString links = tr(
- "<p id='links'>"
- "<A href='#allsome'>Which words to find</A><br />"
- "<A href='#grouping'>Grouping and order</A><br />"
- "<A href='#wildcards'>Wildcards (partial words)</A><br />"
- "<A href='#fields'>Text fields (different parts of text)</A><br/>"
- "<A href='#lucene'>Other syntax features</A><br/>"
- "</p>");
-
- //: Syntax words (AND, OR...) must not be translated.
- QString whichwords = tr(
- "<h1><A name='allsome'>Which words to find</A></h1>"
- "<p>Search terms are separated by spaces. <strong>AND</strong> (all words), " "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) " "can be added between the words. If none is added explicitly OR is used " "automatically. '<strong>+</strong>word' means the word must be in the results, " "'<strong>-</strong>word' means it must not be in the results.</p>");
-
- //: In examples words to be searched for may be translated, but syntax words (AND, OR...) must not be translated.
- QString whichwordstable = tr(
- "<p><table><tr>"
- "<td>jesus AND god</td><td>Finds verses with both 'Jesus' and 'God'</td>"
- "</tr><tr>"
- "<td>jesus OR god</td><td>Finds verses with 'Jesus' or 'God' or both</td>"
- "</tr><tr>"
- "<td>jesus NOT god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr><tr>"
- "<td>+jesus -god</td><td>Finds verses with 'Jesus' but with no 'God'</td>"
- "</tr></table></p>");
-
- QString grouping = tr(
- "<h1><A name='grouping'>Grouping and order</A></h1>"
- "<p>Words can be grouped with <strong>parenthesis</strong>. "
- "Strict word order can be defined with <strong>quotes</strong>.</p>");
-
- QString groupingtable = tr(
- "<p><table><tr>"
- "<td>(a AND b) OR c</td><td>Finds verses with both 'a' AND 'b', and verses with 'c'</td>"
- "</tr><tr>"
- "<td>\"says lord\"</td><td>Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'</td>"
- "</tr><tr>"
- "<td>\"says the lord\"</td><td>Finds all verses with 'says the LORD'</td>"
- "</tr></table></p>");
-
- QString wildcards = tr(
- "<h1><A name='wildcards'>Wildcards (partial words)</A></h1>"
- "<p>'<strong>*</strong>' matches any sequence of 0 or more characters, while '<strong>?</strong>' matches any single character. A wildcard can not be used in the beginning of a word.</p>");
-
- QString wildcardstable = tr(
- "<p><table><tr>"
- "<td>a*</td><td>All words beginning with 'a'</td>"
- "</tr><tr>"
- "<td>a*a</td><td>'Assyria', 'aroma', 'abba' etc.</td>"
- "</tr><tr>"
- "<td>a?</td><td>'at' and 'an'</td>"
- "</tr><tr>"
- "<td>a??a</td><td>'abba', 'area', 'Asia' etc.</td>"
- "</tr></table></p>");
-
- QString fields = tr(
- "<h1><A name='fields'>Text fields (different parts of text)</A></h1>"
- "<p>Available text fields:<br /><table>"
- "<tr><td>heading:</td><td>Searches headings</td></tr>"
- "<tr><td>footnote:</td><td>Searches footnotes</td></tr>"
- "<tr><td>strong:</td><td>Searches Strong's numbers</td></tr>"
- "<tr><td>morph:</td><td>Searches morphology codes</td></tr></table></p>");
-
- QString fieldstable = tr(
- "<p>Examples:<br /><table>"
- "<tr><td>heading:Jesus</td><td>Finds headings with 'Jesus'</td></tr>"
- "<tr><td>footnote:Jesus AND footnote:said</td><td>Finds footnotes with 'Jesus' and 'said'</td></tr>"
- "<tr><td>strong:G846</td><td>Finds verses with Strong's Greek number 846</td></tr>"
- "<tr><td>morph:\"N-NSF\"</td><td>Finds verses with morphology code 'N-NSF'</td>"
- "</tr></table></p>");
-
- QString lucene = tr(
- "<h1><A name='lucene'>Other syntax features</A></h1>"
- "<p>BibleTime uses the CLucene search engine. You can read more on the <a href='http://lucene.apache.org/java/1_4_3/queryparsersyntax.html'>lucene syntax web page</a> (in external browser).</p>");
-
- QString syntax = style + intro + links + whichwords + whichwordstable +
- grouping + groupingtable + wildcards + wildcardstable +
- fields + fieldstable + lucene;
-
- BtTabHtmlDialog* dlg = new BtTabHtmlDialog(tr("Search Syntax Help"), 0, this);
- dlg->setHtml(syntax);
+ // The dialog is deleted on close:
+ BtSearchSyntaxHelpDialog *dlg = new BtSearchSyntaxHelpDialog(this);
dlg->show();
}
@@ -490,28 +396,28 @@ bool BtSearchOptionsArea::eventFilter(QObject* obj, QEvent* event) {
}
void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
-// static const QRegExp re("\\b(AND|OR)\\b");
-// qDebug() << "new text:" << newText;
-// qDebug() << "contains:" << (newText.contains(re));
-// if (newText.isEmpty() || !newText.contains(re) ) {
-// qDebug()<< "no AND/OR";
-// if (!m_typeAndButton->isEnabled()) {
-// m_typeOrButton->setEnabled(true);
-// m_typeAndButton->setEnabled(true);
-// m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
-// m_typeOrButton->setToolTip(tr("Some of the words"));
-// }
-// }
-// else {
-// qDebug() << "AND/OR!";
-// if (m_typeAndButton->isEnabled()) {
-// m_typeOrButton->setChecked(true);
-// m_typeOrButton->setEnabled(false);
-// m_typeAndButton->setEnabled(false);
-// m_typeAndButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
-// m_typeOrButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
-// }
-// }
+// static const QRegExp re("\\b(AND|OR)\\b");
+// qDebug() << "new text:" << newText;
+// qDebug() << "contains:" << (newText.contains(re));
+// if (newText.isEmpty() || !newText.contains(re) ) {
+// qDebug()<< "no AND/OR";
+// if (!m_typeAndButton->isEnabled()) {
+// m_typeOrButton->setEnabled(true);
+// m_typeAndButton->setEnabled(true);
+// m_typeAndButton->setToolTip(tr("All of the words (AND is added between the words)"));
+// m_typeOrButton->setToolTip(tr("Some of the words"));
+// }
+// }
+// else {
+// qDebug() << "AND/OR!";
+// if (m_typeAndButton->isEnabled()) {
+// m_typeOrButton->setChecked(true);
+// m_typeOrButton->setEnabled(false);
+// m_typeAndButton->setEnabled(false);
+// m_typeAndButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
+// m_typeOrButton->setToolTip(tr("Full syntax is used because text includes AND or OR"));
+// }
+// }
}
//bool BtSearchOptionsArea::isAndSearchType()
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index c7c1b1c..afc73ca 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -57,9 +57,11 @@ class BtSearchOptionsArea : public QWidget {
QPushButton* searchButton() const;
/**
- * Returns the list of used modules.
+ Returns the list of used modules.
*/
- QList<CSwordModuleInfo*> modules() const;
+ inline QList<const CSwordModuleInfo*> modules() const {
+ return m_modules;
+ }
/**
* Sets all options back to the default.
@@ -88,11 +90,12 @@ class BtSearchOptionsArea : public QWidget {
*/
void saveSettings();
bool eventFilter(QObject* obj, QEvent* event);
+
public slots:
/**
- * Sets the modules used by the search.
+ Sets the modules used by the search.
*/
- void setModules( QList<CSwordModuleInfo*> modules );
+ void setModules(const QList<const CSwordModuleInfo*> &modules);
/** Sets the modules when user selects them from the combobox.*/
void moduleListTextSelected(int index);
@@ -121,7 +124,7 @@ class BtSearchOptionsArea : public QWidget {
void sigStartSearch();
private:
- QList<CSwordModuleInfo*> m_modules;
+ QList<const CSwordModuleInfo*> m_modules;
QHBoxLayout *hboxLayout;
QGroupBox *searchGroupBox;
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 4b33f80..623de0e 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,6 +12,7 @@
#include <QApplication>
#include <QDebug>
#include <QFrame>
+#include <QMenu>
#include <QProgressDialog>
#include <QPushButton>
#include <QSize>
@@ -22,8 +23,6 @@
#include "backend/keys/cswordversekey.h"
#include "backend/rendering/cdisplayrendering.h"
#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "frontend/searchdialog/analysis/csearchanalysisdialog.h"
#include "frontend/searchdialog/cmoduleresultview.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/searchdialog/csearchresultview.h"
@@ -40,10 +39,6 @@ BtSearchResultArea::BtSearchResultArea(QWidget *parent)
qDebug() << "BtSearchResultArea::BtSearchResultArea end";
}
-BtSearchResultArea::~BtSearchResultArea() {
- saveDialogSettings();
-}
-
void BtSearchResultArea::initView() {
QVBoxLayout *mainLayout;
QWidget *resultListsWidget;
@@ -54,32 +49,32 @@ void BtSearchResultArea::initView() {
int mWidth = util::tool::mWidth(this, 1);
this->setMinimumSize(QSize(mWidth*40, mWidth*15));
mainLayout = new QVBoxLayout(this);
- mainSplitter = new QSplitter(this);
- mainSplitter->setOrientation(Qt::Horizontal);
+ m_mainSplitter = new QSplitter(this);
+ m_mainSplitter->setOrientation(Qt::Horizontal);
- resultListsWidget = new QWidget(mainSplitter);
+ resultListsWidget = new QWidget(m_mainSplitter);
resultListsWidgetLayout = new QVBoxLayout(resultListsWidget);
resultListsWidgetLayout->setContentsMargins(0, 0, 0, 0);
//Splitter for two result lists
- resultListSplitter = new QSplitter(resultListsWidget);
- resultListSplitter->setOrientation(Qt::Vertical);
- m_moduleListBox = new CModuleResultView(resultListSplitter);
- resultListSplitter->addWidget(m_moduleListBox);
- m_resultListBox = new CSearchResultView(resultListSplitter);
- resultListSplitter->addWidget(m_resultListBox);
- resultListsWidgetLayout->addWidget(resultListSplitter);
+ m_resultListSplitter = new QSplitter(resultListsWidget);
+ m_resultListSplitter->setOrientation(Qt::Vertical);
+ m_moduleListBox = new CModuleResultView(m_resultListSplitter);
+ m_resultListSplitter->addWidget(m_moduleListBox);
+ m_resultListBox = new CSearchResultView(m_resultListSplitter);
+ m_resultListSplitter->addWidget(m_resultListBox);
+ resultListsWidgetLayout->addWidget(m_resultListSplitter);
- mainSplitter->addWidget(resultListsWidget);
+ m_mainSplitter->addWidget(resultListsWidget);
//Preview ("info") area
- m_displayFrame = new QFrame(mainSplitter);
+ m_displayFrame = new QFrame(m_mainSplitter);
m_displayFrame->setFrameShape(QFrame::NoFrame);
m_displayFrame->setFrameShadow(QFrame::Plain);
- mainSplitter->addWidget(m_displayFrame);
+ m_mainSplitter->addWidget(m_displayFrame);
- mainLayout->addWidget(mainSplitter);
+ mainLayout->addWidget(m_mainSplitter);
QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
frameLayout->setContentsMargins(0, 0, 0, 0);
@@ -87,20 +82,38 @@ void BtSearchResultArea::initView() {
m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
frameLayout->addWidget(m_previewDisplay->view());
+ QAction* selectAllAction = new QAction(QIcon(), tr("Select all"), this);
+ selectAllAction->setShortcut(QKeySequence::SelectAll);
+ QObject::connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()) );
+
+ QAction* copyAction = new QAction(tr("Copy"), this);
+ copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
+ QObject::connect(copyAction, SIGNAL(triggered()), this, SLOT(copySelection()) );
+
+ QMenu* menu = new QMenu();
+ menu->addAction(selectAllAction);
+ menu->addAction(copyAction);
+ m_previewDisplay->installPopup(menu);
+
loadDialogSettings();
}
-void BtSearchResultArea::setSearchResult(QList<CSwordModuleInfo*> modules) {
+void BtSearchResultArea::setSearchResult(
+ const CSwordModuleSearch::Results &results)
+{
const QString searchedText = CSearchDialog::getSearchDialog()->searchText();
reset(); //clear current modules
- m_modules = modules;
- //pre-select the first module in the list
- //this will pre-select and display the first hit of that module
- m_moduleListBox->setupTree(modules, searchedText);
+ m_results = results;
+
+ // Populate listbox:
+ m_moduleListBox->setupTree(results, searchedText);
+
+ // Pre-select the first module in the list:
m_moduleListBox->setCurrentItem(m_moduleListBox->topLevelItem(0), 0);
- qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
+ Q_ASSERT(qobject_cast<CSearchDialog*>(parent()) != 0);
+ static_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(true);
}
void BtSearchResultArea::reset() {
@@ -108,7 +121,6 @@ void BtSearchResultArea::reset() {
m_resultListBox->clear();
m_previewDisplay->setText("<html><head/><body></body></html>");
qobject_cast<CSearchDialog*>(parent())->m_analyseButton->setEnabled(false);
- m_modules.clear();
}
void BtSearchResultArea::clearPreview() {
@@ -125,7 +137,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
QString text;
CDisplayRendering render;
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
modules.append(module);
CTextRendering::KeyTreeItem::Settings settings;
@@ -134,7 +146,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
vk.Headings(1);
- vk.key(key);
+ vk.setKey(key);
((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
@@ -152,7 +164,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
const QString startKey = vk.key();
- vk.key(key);
+ vk.setKey(key);
vk.next(CSwordVerseKey::UseVerse);
vk.next(CSwordVerseKey::UseVerse);
@@ -165,7 +177,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
else if (module->type() == CSwordModuleInfo::Commentary) {
CSwordVerseKey vk(module);
vk.Headings(1);
- vk.key(key);
+ vk.setKey(key);
((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
@@ -178,7 +190,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
}
const QString startKey = vk.key();
- vk.key(key);
+ vk.setKey(key);
const QString endKey = vk.key();
settings.keyRenderingFace = CTextRendering::KeyTreeItem::Settings::NoKey;
@@ -193,7 +205,7 @@ void BtSearchResultArea::updatePreview(const QString& key) {
}
}
-QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
+QStringList BtSearchResultArea::queryParser(const QString& queryString) {
QString token;
QStringList tokenList;
int cnt, pos;
@@ -226,13 +238,13 @@ QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
}
// wild card - treat as a special token break
//else if (queryString[cnt] == '*') {
- // token = token + queryString[cnt];
- // token = token.simplified();
- // if ((token != "*") && (token != ""))
- // tokenList.append(token);
- // // start next token with wildcard (kin*m -> kin* *m)
- // token = "*";
- // cnt++;
+ // token = token + queryString[cnt];
+ // token = token.simplified();
+ // if ((token != "*") && (token != ""))
+ // tokenList.append(token);
+ // // start next token with wildcard (kin*m -> kin* *m)
+ // token = "*";
+ // cnt++;
//}
// the ! token is also a token break
else if (queryString[cnt] == '!') {
@@ -423,20 +435,20 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
//char buf8[1000];
//standard::WhitespaceAnalyzer analyzer;
//lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //boost::scoped_ptr<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
+ //QSharedPointer<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
//StringReader reader(m_wcharBuffer);
//TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
//Token token;
//while(tokenStream->next(&token) != 0) {
- // lucene_wcstoutf8(buf8, token.termText(), 1000);
- // printf("%s\n", buf8);
+ // lucene_wcstoutf8(buf8, token.termText(), 1000);
+ // printf("%s\n", buf8);
//}
//===========================================================
// since I could not figure out the lucene query parser, I
// made a simple parser.
//===========================================================
- QStringList words = QueryParser(newSearchText);
+ QStringList words = queryParser(newSearchText);
qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
foreach (QString word, words) { //search for every word in the list
QRegExp findExp;
@@ -481,18 +493,15 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
void BtSearchResultArea::initConnections() {
connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
connect(m_resultListBox, SIGNAL(keyDeselected()), this, SLOT(clearPreview()));
- connect(m_moduleListBox, SIGNAL(moduleSelected(CSwordModuleInfo*)), m_resultListBox, SLOT(setupTree(CSwordModuleInfo*)));
+ connect(m_moduleListBox,
+ SIGNAL(moduleSelected(const CSwordModuleInfo*, const sword::ListKey&)),
+ m_resultListBox,
+ SLOT(setupTree(const CSwordModuleInfo*, const sword::ListKey&)));
connect(m_moduleListBox, SIGNAL(moduleChanged()), m_previewDisplay->connectionsProxy(), SLOT(clear()));
// connect the strongs list
- connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, QStringList*)),
- m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, QStringList*)));
-}
-
-/** Shows a dialog with the search analysis of the current search. */
-void BtSearchResultArea::showAnalysis() {
- CSearchAnalysisDialog dlg(m_modules, this);
- dlg.exec();
+ connect(m_moduleListBox, SIGNAL(strongsSelected(CSwordModuleInfo*, const QStringList&)),
+ m_resultListBox, SLOT(setupStrongsTree(CSwordModuleInfo*, const QStringList&)));
}
/**
@@ -501,127 +510,97 @@ void BtSearchResultArea::showAnalysis() {
void BtSearchResultArea::loadDialogSettings() {
QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
if (mainSplitterSizes.count() > 0) {
- mainSplitter->setSizes(mainSplitterSizes);
+ m_mainSplitter->setSizes(mainSplitterSizes);
}
else {
int w = this->size().width();
int w2 = m_moduleListBox->sizeHint().width();
mainSplitterSizes << w2 << w - w2;
- mainSplitter->setSizes(mainSplitterSizes);
+ m_mainSplitter->setSizes(mainSplitterSizes);
}
QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) resultListSplitter->setSizes(resultSplitterSizes);
+ if (resultSplitterSizes.count() > 0) m_resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
void BtSearchResultArea::saveDialogSettings() {
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, resultListSplitter->sizes());
-}
-
-StrongsResult::StrongsResult() {
-}
-
-StrongsResult::StrongsResult(const QString& text, const QString &keyName)
- : text(text) {
- //keyNameList.clear();
- keyNameList.append(keyName);
-}
-
-QString StrongsResult::keyText() const {
- return text;
-}
-
-int StrongsResult::keyCount() const {
- return keyNameList.count();
-}
-
-void StrongsResult::addKeyName(const QString& keyName) {
- if (keyNameList.indexOf(keyName) == -1)
- keyNameList.append(keyName);
-}
-
-QStringList* StrongsResult::getKeyList() {
- return & keyNameList;
+ CBTConfig::set(CBTConfig::searchMainSplitterSizes, m_mainSplitter->sizes());
+ CBTConfig::set(CBTConfig::searchResultSplitterSizes, m_resultListSplitter->sizes());
}
+/******************************************************************************
+* StrongsResultList:
+******************************************************************************/
-
-/********************************************
-************ StrongsResultClass *************
-********************************************/
-void StrongsResultClass::initStrongsResults(void) {
+StrongsResultList::StrongsResultList(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ const QString &strongsNumber)
+{
using namespace Rendering;
- CDisplayRendering render;
- QList<CSwordModuleInfo*> modules;
- CTextRendering::KeyTreeItem::Settings settings;
- QString rText, lText, key;
- bool found;
- int sIndex;
- int count;
- int index;
- QString text;
-
- modules.append(srModule);
- sword::ListKey& result = srModule->searchResult();
+ /// \warning This is a workaround for Sword constness
+ sword::ListKey result = results;
- count = result.Count();
+ int count = result.Count();
if (!count)
return;
- qApp->processEvents( QEventLoop::AllEvents, 1 ); //1 ms only
- srList.clear();
+
+ CTextRendering::KeyTreeItem::Settings settings;
+ QList<const CSwordModuleInfo*> modules;
+ modules.append(module);
+ clear();
+
// for whatever reason the text "Parsing...translations." does not appear.
// this is not critical but the text is necessary to get the dialog box
// to be wide enough.
- QProgressDialog* progress = new QProgressDialog(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
+ QProgressDialog progress(QObject::tr("Parsing Strong's Numbers"), 0, 0, count);
//0, "progressDialog", tr("Parsing Strong's Numbers"), tr("Parsing Strong's numbers for translations."), true);
-
//progress->setAllowCancel(false);
//progress->setMinimumDuration(0);
- progress->show();
- progress->raise();
- for (index = 0; index < count; index++) {
- progress->setValue( index );
- qApp->processEvents(QEventLoop::AllEvents, 1 ); //1 ms only
-
- key = QString::fromUtf8(result.GetElement(index)->getText());
- text = render.renderSingleKey(key, modules, settings);
- sIndex = 0;
- while ((rText = getStrongsNumberText(text, &sIndex)) != "") {
- StrongsResultList::iterator it;
- found = FALSE;
- for ( it = srList.begin(); it != srList.end(); ++it ) {
- lText = (*it).keyText();
- if (lText == rText) {
- found = TRUE;
+ progress.show();
+ progress.raise();
+
+ qApp->processEvents(QEventLoop::AllEvents, 1); //1 ms only
+
+ for (int index = 0; index < count; index++) {
+ progress.setValue(index);
+ qApp->processEvents(QEventLoop::AllEvents, 1); //1 ms only
+
+ QString key = QString::fromUtf8(result.GetElement(index)->getText());
+ QString text = CDisplayRendering().renderSingleKey(key, modules, settings);
+ for (int sIndex = 0;;) {
+ continueloop:
+ QString rText = getStrongsNumberText(text, sIndex, strongsNumber);
+ if (rText.isEmpty()) break;
+
+ for (iterator it = begin(); it != end(); ++it) {
+ if ((*it).keyText() == rText) {
(*it).addKeyName(key);
- break;
+ goto continueloop; // break, then continue
}
}
- if (found == FALSE)
- srList.append( StrongsResult(rText, key) );
+ append(StrongsResult(rText, key));
}
}
- delete progress;
- progress = 0;
- //qHeapSort(srList);
}
-QString StrongsResultClass::getStrongsNumberText(const QString& verseContent, int *startIndex) {
+QString StrongsResultList::getStrongsNumberText(const QString &verseContent,
+ int &startIndex,
+ const QString &lemmaText)
+{
// get the strongs text
int idx1, idx2, index;
QString sNumber, strongsText;
//const bool cs = CSwordModuleSearch::caseSensitive;
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
- if (*startIndex == 0) {
+ if (startIndex == 0) {
index = verseContent.indexOf("<body");
}
else {
- index = *startIndex;
+ index = startIndex;
}
// find all the "lemma=" inside the the content
@@ -639,7 +618,7 @@ QString StrongsResultClass::getStrongsNumberText(const QString& verseContent, in
idx2 = verseContent.indexOf("<", index, cs);
strongsText = verseContent.mid(index, idx2 - index);
index = idx2;
- *startIndex = index;
+ startIndex = index;
return(strongsText);
}
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index f0e3d6e..f7ef8d8 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,13 +16,14 @@
#include <QWidget>
#include "backend/managers/cswordbackend.h"
#include "backend/cswordmodulesearch.h"
+#include "frontend/display/creaddisplay.h"
+#include "frontend/searchdialog/analysis/csearchanalysisdialog.h"
namespace Search {
class CModuleResultView;
class CSearchResultView;
}
-class CReadDisplay;
class CSwordModuleInfo;
class QFrame;
class QHBoxLayout;
@@ -44,73 +45,45 @@ namespace Search {
* To add a new verse to a strongs text result use addKeyName.
*/
class StrongsResult {
- public:
- StrongsResult();
- StrongsResult(const QString& text, const QString &keyName);
-
- QString keyText() const;
- int keyCount() const;
- void addKeyName(const QString& keyName);
- QStringList* getKeyList();
+ public: /* Methods: */
+ inline StrongsResult() {}
+ inline StrongsResult(const QString &text,
+ const QString &keyName)
+ : m_text(text)
+ {
+ m_keyNameList.append(keyName);
+ }
- /* ????
- bool operator==(const StrongsResult &l, const StrongsResult &r)
- { return (l.keyText() == r.keyText()); }
+ const QString &keyText() const { return m_text; }
+ inline int keyCount() const { return m_keyNameList.count(); }
+ inline void addKeyName(const QString &keyName) {
+ if (m_keyNameList.contains(keyName)) return;
+ m_keyNameList.append(keyName);
+ }
- bool operator<(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() < r->keyText()); }
+ inline const QStringList &getKeyList() const { return m_keyNameList; }
- bool operator>(const StrongsResult &l, const StrongsResult &r)
- { return (l->keyText() > r->keyText()); }
- */
- private:
- QString text;
- QStringList keyNameList;
+ private: /* Fields: */
+ QString m_text;
+ QStringList m_keyNameList;
};
-typedef QList<StrongsResult> StrongsResultList;
-
/**
+* \todo Fix comment!
* This class is used to keep track of the text strongs results.
* It keeps track of all instances of all strongs text results.
* This class makes use of the above class StrongsResult.
-*
-* The functions of the class are:
-* - Store an instance of a strongs text result.
-* - Each strongs text result will contain a list of verses (keyNames).
-* - The number of verses (keyNames) is returned by keyCount().
-* - The text for the strongs text result is returned by keyText().
-* - The list of verses (keyNames) is returned by getKeyList() [as QStringList].
-*
-* To add a new verse to a strongs text result use addKeyName.
*/
-class StrongsResultClass {
- public:
- StrongsResultClass(CSwordModuleInfo* module, const QString& strongsNumber)
- : srModule(module), lemmaText(strongsNumber) {
- initStrongsResults();
- }
-
- QString keyText(int index) const {
- return srList[index].keyText();
- }
- int keyCount(int index) const {
- return srList[index].keyCount();
- }
- QStringList* getKeyList(int index) {
- return srList[index].getKeyList();
- }
- int Count() const {
- return srList.count();
- }
-
- private:
- void initStrongsResults(void);
- QString getStrongsNumberText(const QString& verseContent, int *startIndex);
-
- StrongsResultList srList;
- CSwordModuleInfo* srModule;
- QString lemmaText;
+class StrongsResultList: public QList<StrongsResult> {
+ public: /* Methods: */
+ StrongsResultList(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ const QString &strongsNumber);
+
+ private: /* Methods: */
+ QString getStrongsNumberText(const QString &verseContent,
+ int &startIndex,
+ const QString &lemmaText);
};
@@ -119,18 +92,27 @@ class StrongsResultClass {
*/
class BtSearchResultArea : public QWidget {
Q_OBJECT
- public:
+ public: /* Methods: */
BtSearchResultArea(QWidget *parent = 0);
- ~BtSearchResultArea();
+ inline ~BtSearchResultArea() { saveDialogSettings(); }
+
/**
* Sets the modules which contain the result of each.
*/
- void setSearchResult(QList<CSwordModuleInfo*> modules);
+ void setSearchResult(
+ const CSwordModuleSearch::Results &results);
- QSize sizeHint() const {
+ /**
+ Reimplemented from QWidget::sizeHint().
+ */
+ virtual QSize sizeHint() const {
return baseSize();
}
- QSize minimumSizeHint() const {
+
+ /**
+ Reimplemented from QWidget::minimumSizeHint().
+ */
+ virtual QSize minimumSizeHint() const {
return minimumSize();
}
@@ -140,19 +122,22 @@ class BtSearchResultArea : public QWidget {
*/
void reset();
- protected:
+ protected: /* Methods: */
/**
* Initializes the view of this widget.
*/
void initView();
+
/**
* Initializes the signal slot conections of the child widgets
*/
void initConnections();
+
/**
* This function breakes the queryString into clucene tokens
*/
- QStringList QueryParser(const QString& queryString);
+ QStringList queryParser(const QString& queryString);
+
/**
* This function highlights the searched text in the content using the search type given by search flags
*/
@@ -162,6 +147,7 @@ class BtSearchResultArea : public QWidget {
* Load the settings from the resource file
*/
void loadDialogSettings();
+
/**
* Save the settings to the resource file
*/
@@ -172,16 +158,33 @@ class BtSearchResultArea : public QWidget {
* Update the preview of the selected key.
*/
void updatePreview(const QString& key);
+
/**
* Clear the preview of the selected key.
*/
void clearPreview();
+
/**
* Shows a dialog with the search analysis of the current search.
*/
- void showAnalysis();
+ inline void showAnalysis() {
+ CSearchAnalysisDialog(m_results, this).exec();
+ }
+
+ /**
+ * Select all text
+ */
+ inline void selectAll() { m_previewDisplay->selectAll(); }
- private:
+ /**
+ * Copy selected text
+ */
+ inline void copySelection() {
+ m_previewDisplay->connectionsProxy()->copySelection();
+ }
+
+ private: /* Fields: */
+ CSwordModuleSearch::Results m_results;
CModuleResultView* m_moduleListBox;
CSearchResultView* m_resultListBox;
@@ -189,10 +192,8 @@ class BtSearchResultArea : public QWidget {
QFrame *m_displayFrame;
CReadDisplay* m_previewDisplay;
- QList<CSwordModuleInfo*> m_modules;
-
- QSplitter *mainSplitter;
- QSplitter *resultListSplitter;
+ QSplitter *m_mainSplitter;
+ QSplitter *m_resultListSplitter;
};
} //namespace Search
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
new file mode 100644
index 0000000..a1debc3
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
@@ -0,0 +1,229 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
+
+#include <QDesktopServices>
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QWebView>
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
+
+namespace Search {
+
+BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFlags wflags)
+ : QDialog(parent, wflags)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+ resize(550, 340);
+
+ QVBoxLayout *l = new QVBoxLayout;
+
+ m_webView = new QWebView(this);
+ m_webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
+ connect(m_webView, SIGNAL(linkClicked(QUrl)),
+ this, SLOT(linkClicked(QUrl)));
+ l->addWidget(m_webView);
+
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
+ connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ l->addWidget(m_buttons);
+
+ setLayout(l);
+
+ retranslateUi();
+}
+
+BtSearchSyntaxHelpDialog::~BtSearchSyntaxHelpDialog() {
+ // Intentionally empty
+}
+
+void BtSearchSyntaxHelpDialog::retranslateUi() {
+ namespace DU = util::directory;
+
+ QString theTitle(tr("Search Syntax Help"));
+ setWindowTitle(theTitle);
+
+ QString html("<html><head><title>");
+ html += theTitle;
+ html += "</title><style type=\"text/css\">"
+ "body{"
+ "background-color:";
+ html += palette().color(QPalette::Window).name();
+ html += ";"
+ "color:";
+ html += palette().color(QPalette::WindowText).name();
+ html +=
+ "}h3{"
+ "font-weight:bold;"
+ "text-align:center"
+ "}a{"
+ "text-decoration:underline"
+ "}a:link{"
+ "color:";
+ html += palette().color(QPalette::Link).name();
+ html +=
+ "}a:visited{"
+ "color:";
+ html += palette().color(QPalette::LinkVisited).name();
+ html +=
+ "}h1 a{"
+ "font-size:medium"
+ "}table{"
+ "margin-left:2em;"
+ "border-collapse:collapse"
+ "}td{"
+ "padding:0.2em 0.3em;"
+ "border:3px solid ";
+ html += palette().color(QPalette::Foreground).name();
+ html += ";"
+ "color:";
+ html += palette().color(QPalette::Text).name();
+ html += ";"
+ "background-color:";
+ html += palette().color(QPalette::Base).name();
+ html +=
+ "}ul#links{"
+ "list-style-type:none"
+ "}"
+ "</style></head><body><p>";
+
+ html += tr("This help is mainly for 'Full syntax' option. 'All words' and 'Some words' "
+ "options have more limited syntax; <a href='#wildcards'>wildcards</a> and "
+ "<a href='#fields'>text fields</a> are supported for them. Some other syntax "
+ "features may give strange or wrong results with All words/Some words.");
+ html += "</p><p><ul id='links'><li><a href='#allsome'>";
+ html += tr("Which words to find");
+ html += "</a></li><li><a href='#grouping'>";
+ html += tr("Grouping and order");
+ html += "</a></li><li><a href='#wildcards'>";
+ html += tr("Wildcards (partial words)");
+ html += "</a></li><li><a href='#fields'>";
+ html += tr("Text fields (different parts of text)");
+ html += "</a></li><li><a href='#lucene'>";
+ html += tr("Other syntax features");
+
+ html += "</a></li></ul></p><h1><a name='allsome'>";
+ html += tr("Which words to find");
+ html += "</a></h1><p>";
+ html += tr("Search terms are separated by spaces. <strong>AND</strong> (all words), "
+ "<strong>OR</strong> (some words) and <strong>NOT</strong> (not the following word) "
+ "can be added between the words. If none is added explicitly OR is used "
+ "automatically. '<strong>+</strong>word' means the word must be in the results, "
+ "'<strong>-</strong>word' means it must not be in the results.",
+ "Do not translate \"AND\", \"OR\" or \"NOT\".");
+ html += "</p><p><table><tr><td>";
+ html += tr("jesus AND god", "Do not translate \"AND\".");
+ html += "</td><td>";
+ html += tr("Finds verses with both 'Jesus' and 'God'");
+ html += "</td></tr><tr><td>";
+ html += tr("jesus OR god", "Do not translate \"OR\".");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' or 'God' or both");
+ html += "</td></tr><tr><td>";
+ html += tr("jesus NOT god", "Do not translate \"NOT\".");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' but with no 'God'");
+ html += "</td></tr><tr><td>";
+ html += tr("+jesus -god");
+ html += "</td><td>";
+ html += tr("Finds verses with 'Jesus' but with no 'God'");
+
+ html += "</td></tr></table></p><h1><a name='grouping'>";
+ html += tr("Grouping and order");
+ html += "</a></h1><p>";
+ html += tr("Words can be grouped with <strong>parenthesis</strong>. Strict word order "
+ "can be defined with <strong>quotes</strong>.");
+ html += "</p><p><table><tr><td>";
+ html += tr("(a AND b) OR c", "Do not translate \"AND\" or \"OR\".");
+ html += "</td><td>";
+ html += tr("Finds verses with both 'a' AND 'b', and verses with 'c'");
+ html += "</td></tr><tr><td>";
+ html += tr("\"says lord\"");
+ html += "</td><td>";
+ html += ("Finds e.g. '...Isaiah says, \"Lord...' but not '...says the LORD'");
+ html += "</td></tr><tr><td>";
+ html += tr("\"says the lord\"");
+ html += "</td><td>";
+ html += tr("Finds all verses with 'says the LORD'");
+
+ html += "</td></tr></table></p><h1><a name='wildcards'>";
+ html += tr("Wildcards (partial words)");
+ html += "</a></h1><p>";
+ html += tr("'<strong>*</strong>' matches any sequence of 0 or more characters, while "
+ "'<strong>?</strong>' matches any single character. A wildcard can not be used in "
+ "the beginning of a word.");
+ html += "</p><p><table><tr><td>";
+ html += tr("a*");
+ html += "</td><td>";
+ html += tr("All words beginning with 'a'");
+ html += "</td></tr><tr><td>";
+ html += tr("a*a");
+ html += "</td><td>";
+ html += tr("'Assyria', 'aroma', 'abba' etc.");
+ html += "</td></tr><tr><td>";
+ html += tr("a?");
+ html += "</td><td>";
+ html += tr("'at' and 'an'");
+ html += "</td></tr><tr><td>";
+ html += tr("a??a");
+ html += "</td><td>";
+ html += tr("'abba', 'area', 'Asia' etc.");
+
+ html += "</td></tr></table></p><h1><a name='fields'>";
+ html += tr("Text fields (different parts of text)");
+ html += "</a></h1><p>";
+ html += tr("Available text fields:" );
+ html += "<br/><table><tr><td>heading:</td><td>";
+ html += tr("Searches headings");
+ html += "</td></tr><tr><td>footnote:</td><td>";
+ html += tr("Searches footnotes");
+ html += "</td></tr><tr><td>strong:</td><td>";
+ html += tr("Searches Strong's numbers");
+ html += "</td></tr><tr><td>morph:</td><td>";
+ html += tr("Searches morphology codes");
+ html += "</td></tr></table></p><p>";
+ html += tr("Examples:" );
+ html += "<br/><table><tr><td>";
+ html += tr("heading:Jesus", "Do not translate \"heading:\".");
+ html += "</td><td>";
+ html += tr("Finds headings with 'Jesus'");
+ html += "</td></tr><tr><td>";
+ html += tr("footnote:Jesus AND footnote:said",
+ "Do not translate \"footnote:\" or \"AND\".");
+ html += "</td><td>";
+ html += tr("Finds footnotes with 'Jesus' and 'said'");
+ html += "</td></tr><tr><td>";
+ html += tr("strong:G846", "Do not translate \"strong:\".");
+ html += "</td><td>";
+ html += tr("Finds verses with Strong's Greek number 846");
+ html += "</td></tr><tr><td>";
+ html += tr("morph:\"N-NSF\"", "Do not translate \"morph:\".");
+ html += "</td><td>";
+ html += tr("Finds verses with morphology code 'N-NSF'");
+ html += "</td></tr></table></p><h1><a name='lucene'>";
+ html += tr("Other syntax features");
+ html += "</a></h1><p>";
+ html += tr("BibleTime uses the CLucene search engine. You can read more on the "
+ "<a href='%1'>lucene syntax web page</a> (in external browser).")
+ .arg("http://lucene.apache.org/java/1_4_3/queryparsersyntax.html");
+ html += "</p></body></html>";
+
+ m_webView->setHtml(html, QUrl::fromLocalFile(DU::getIconDir().path()));
+
+ util::prepareDialogBox(m_buttons);
+}
+
+void BtSearchSyntaxHelpDialog::linkClicked(const QUrl &url) {
+ QDesktopServices::openUrl(url);
+}
+
+} // namespace Search
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
new file mode 100644
index 0000000..89cc805
--- /dev/null
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
@@ -0,0 +1,40 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTTABDIALOG_H
+#define BTTABDIALOG_H
+
+#include <QDialog>
+
+class QDialogButtonBox;
+class QUrl;
+class QWebView;
+
+namespace Search {
+
+class BtSearchSyntaxHelpDialog: public QDialog {
+ Q_OBJECT
+ public:
+ BtSearchSyntaxHelpDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
+ ~BtSearchSyntaxHelpDialog();
+
+ protected:
+ void retranslateUi();
+
+ protected slots:
+ void linkClicked(const QUrl &url);
+
+ private:
+ QWebView *m_webView;
+ QDialogButtonBox *m_buttons;
+};
+
+} // namespace Search
+
+#endif
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index 355ed00..cf77627 100644
--- a/src/frontend/searchdialog/chistorycombobox.cpp
+++ b/src/frontend/searchdialog/chistorycombobox.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index d750e16..dffbcd8 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index ef23756..f37b4d9 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-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -38,8 +38,7 @@ CModuleResultView::CModuleResultView(QWidget* parent)
}
CModuleResultView::~CModuleResultView() {
- qDeleteAll(strongsResults);
- strongsResults.clear();
+ qDeleteAll(m_strongsResults);
}
@@ -98,32 +97,31 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-/** Setups the tree using the given list of modules. */
-void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText ) {
+void CModuleResultView::setupTree(
+ const CSwordModuleSearch::Results &results,
+ const QString &searchedText)
+{
clear();
+
+ m_results = results;
+
/// \todo this class is for sorting
//util::CSortListViewItem* item = 0;
//util::CSortListViewItem* oldItem = 0;
QTreeWidgetItem* item = 0;
- QTreeWidgetItem* oldItem = 0;
- sword::ListKey result;
-
- qDeleteAll(strongsResults);
- strongsResults.clear();
+ qDeleteAll(m_strongsResults);
+ m_strongsResults.clear();
bool strongsAvailable = false;
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- // for (modules.first(); modules.current(); modules.next()) {
- result = (*it)->searchResult();
+ Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
+ sword::ListKey result = results.value(m);
- item = new QTreeWidgetItem(this, QStringList((*it)->name()) << QString::number(result.Count()) );
+ item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
/// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
- item->setIcon(0, util::tool::getIconForModule(*it) );
- oldItem = item;
+ 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
@@ -142,7 +140,7 @@ void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QStri
sTokenIndex = searchedText.indexOf(" ", sstIndex);
sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
- setupStrongsResults((*it), item, sNumber);
+ setupStrongsResults(m, results[m], item, sNumber);
/// \todo item->setOpen(true);
strongsAvailable = true;
@@ -153,53 +151,50 @@ void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QStri
setRootIsDecorated( strongsAvailable );
}
-void CModuleResultView::setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent,
- const QString& sNumber) {
- QString lText;
- /// \todo
- //util::CSortListViewItem* item = 0;
- QTreeWidgetItem* item = 0;
-
- strongsResults[module] = new StrongsResultClass(module, sNumber);
-
- for (int cnt = 0; cnt < strongsResults[module]->Count(); ++cnt) {
- lText = strongsResults[module]->keyText(cnt);
-
- item = new QTreeWidgetItem(parent, QStringList(lText) << QString::number(strongsResults[module]->keyCount(cnt)));
- /// \todo
- //item->setColumnSorting(1, util::CSortListViewItem::Number);
+void CModuleResultView::setupStrongsResults(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ QTreeWidgetItem *parent,
+ const QString &sNumber)
+{
+ StrongsResultList *m = new StrongsResultList(module, results, sNumber);
+ m_strongsResults[module] = m;
+
+ for (int cnt = 0; cnt < m->count(); ++cnt) {
+ QStringList columns(m->at(cnt).keyText());
+ columns.append(QString::number(m->at(cnt).keyCount()));
+ new QTreeWidgetItem(parent, columns);
}
}
/// \todo
/** Is executed when an item was selected in the list. */
void CModuleResultView::executed( QTreeWidgetItem* i, QTreeWidgetItem*) {
- QString itemText, lText;
+ QString itemText;
if (!i) {
//Clear list
emit moduleChanged();
return;
}
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(i->text(0))) {
+ if (CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(i->text(0))) {
emit moduleChanged();
- emit moduleSelected(m);
+ emit moduleSelected(m, m_results.value(m));
return;
}
- StrongsResultClass* strongsResult = strongsResults[activeModule()];
+ StrongsResultList *strongsResult = m_strongsResults[activeModule()];
if (!strongsResult) {
return;
}
itemText = i->text(0);
- for (int cnt = 0; cnt < strongsResult->Count(); cnt++) {
- lText = strongsResult->keyText(cnt);
- if (lText == itemText) {
+ for (int cnt = 0; cnt < strongsResult->count(); cnt++) {
+ if (strongsResult->at(cnt).keyText() == itemText) {
//clear the verses list
emit moduleChanged();
- emit strongsSelected(activeModule(), strongsResult->getKeyList(cnt));
+ emit strongsSelected(activeModule(),
+ strongsResult->at(cnt).getKeyList());
return;
}
}
@@ -221,7 +216,7 @@ CSwordModuleInfo* CModuleResultView::activeModule() {
}
if (item) {
- return CPointers::backend()->findModuleByName(item->text(0));
+ return CSwordBackend::instance()->findModuleByName(item->text(0));
}
return 0;
@@ -236,46 +231,57 @@ void CModuleResultView::contextMenuEvent( QContextMenuEvent * event ) {
/** Copies the whole search result into the clipboard. */
void CModuleResultView::copyResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result, m, CExportManager::Text, false);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Copy search result..."), true,
+ tr("Copying search result"));
+
+ mgr.copyKeyList(m_results[m], m, CExportManager::Text, false);
};
}
/** Copies the whole search result with the text into the clipboard. */
void CModuleResultView::copyResultWithText() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- mgr.copyKeyList(&result, m, CExportManager::Text, true);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Copy search result..."), true,
+ tr("Copying search result"));
+
+ mgr.copyKeyList(m_results[m], m, CExportManager::Text, true);
};
}
/** Saves the search result keys. */
void CModuleResultView::saveResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result, m, CExportManager::Text, false);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Save search result..."), true,
+ tr("Saving search result"));
+
+ mgr.saveKeyList(m_results[m], m, CExportManager::Text, false);
};
}
/** Saves the search result with it's text. */
void CModuleResultView::saveResultWithText() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- mgr.saveKeyList(&result, m, CExportManager::Text, true);
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Save search result..."), true,
+ tr("Saving search result"));
+
+ mgr.saveKeyList(m_results[m], m, CExportManager::Text, true);
};
}
/** Appends the whole search result to the printer queue. */
void CModuleResultView::printResult() {
- if (CSwordModuleInfo* m = activeModule()) {
- sword::ListKey result = m->searchResult();
- CExportManager mgr(tr("Print search result..."), true, tr("Printing search result"));
- mgr.printKeyList(&result, m, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults());
+ CSwordModuleInfo *m = activeModule();
+ if (m != 0) {
+ CExportManager mgr(tr("Print search result..."), true,
+ tr("Printing search result"));
+
+ mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
+ CBTConfig::getFilterOptionDefaults());
};
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index ab48f60..5940859 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +22,7 @@ class QContextMenuEvent;
class QMenu;
class QPoint;
class QStringList;
-class StrongsResultClass;
+class StrongsResultList;
namespace Search {
@@ -33,9 +33,11 @@ class CModuleResultView : public QTreeWidget {
~CModuleResultView();
/**
- * Setups the tree using the given list of modules.
+ Setups the tree using the given list of modules.
*/
- void setupTree( QList<CSwordModuleInfo*> modules, const QString& searchedText );
+ void setupTree(const CSwordModuleSearch::Results &results,
+ const QString &searchedText);
+
/**
* Returns the currently active module.
*/
@@ -56,7 +58,10 @@ class CModuleResultView : public QTreeWidget {
void initConnections();
- void setupStrongsResults(CSwordModuleInfo* module, QTreeWidgetItem* parent, const QString& searchedText);
+ void setupStrongsResults(const CSwordModuleInfo *module,
+ const sword::ListKey &results,
+ QTreeWidgetItem *parent,
+ const QString &searchedText);
protected slots:
/**
@@ -89,9 +94,9 @@ class CModuleResultView : public QTreeWidget {
void saveResult();
signals:
- void moduleSelected(CSwordModuleInfo*);
+ void moduleSelected(const CSwordModuleInfo*, const sword::ListKey&);
void moduleChanged();
- void strongsSelected(CSwordModuleInfo*, QStringList*);
+ void strongsSelected(CSwordModuleInfo*, const QStringList&);
private:
struct {
@@ -119,7 +124,8 @@ class CModuleResultView : public QTreeWidget {
QMenu* m_popup;
- QHash<CSwordModuleInfo*, StrongsResultClass*> strongsResults;
+ CSwordModuleSearch::Results m_results;
+ QHash<const CSwordModuleInfo*, StrongsResultList*> m_strongsResults;
QSize m_size;
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 335fc5e..4fc2a3d 100644
--- a/src/frontend/searchdialog/crangechooserdialog.cpp
+++ b/src/frontend/searchdialog/crangechooserdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index b665a8f..8a3a91e 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 6f8214c..5461732 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +11,7 @@
#include <QDebug>
#include <QDialogButtonBox>
+#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSettings>
@@ -24,7 +25,7 @@
#include "backend/cswordmodulesearch.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "frontend/cmoduleindexdialog.h"
+#include "frontend/btmoduleindexdialog.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "frontend/searchdialog/btsearchresultarea.h"
#include "util/cresmgr.h"
@@ -36,7 +37,9 @@ namespace Search {
static CSearchDialog* m_staticDialog = 0;
-void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText, QWidget* parentDialog) {
+void CSearchDialog::openDialog(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText, QWidget *parentDialog)
+{
if (!m_staticDialog) {
m_staticDialog = new CSearchDialog(parentDialog);
};
@@ -81,7 +84,7 @@ CSearchDialog::CSearchDialog(QWidget *parent)
setWindowIcon(DU::getIcon(CResMgr::searchdialog::icon));
setWindowTitle(tr("Search"));
setAttribute(Qt::WA_DeleteOnClose);
- m_searcher.connectFinished( this, SLOT(searchFinished()));
+
initView();
initConnections();
}
@@ -91,10 +94,9 @@ CSearchDialog::~CSearchDialog() {
m_staticDialog = 0;
}
-/** Starts the search with the set modules and the set search text. */
void CSearchDialog::startSearch() {
+ typedef QList<const CSwordModuleInfo*> ML;
QString originalSearchText(m_searchOptionsArea->searchText());
- QString searchText("");
// first check the search string for errors
{
@@ -104,50 +106,72 @@ void CSearchDialog::startSearch() {
return;
}
}
-
- searchText = prepareSearchText(originalSearchText);
+ QString searchText = prepareSearchText(originalSearchText);
// Insert search text into history list of combobox
m_searchOptionsArea->addToHistory(originalSearchText);
- // check that we have the indices we need for searching
- if (!m_searcher.modulesHaveIndices( modules() ) ) {
- int result = util::showQuestion(this, tr("Missing indices"),
- tr("One or more works need indexing before they can be searched.\n"
- "This could take a long time. Proceed with indexing?"),
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
- // In SuSE 10.0 the result is the logical or of the button type, just like it is
- // inputed into the QMessageBox.
- if ( (result == (QMessageBox::Yes | QMessageBox::Default)) ||
- (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) {
- CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance();
- dlg->indexUnindexedModules( modules() );
+ // Check that we have the indices we need for searching
+ ML unindexedModules = CSwordModuleSearch::unindexedModules(modules());
+ if (unindexedModules.size() > 0) {
+ // Build the list of module names:
+ QStringList moduleNameList;
+ Q_FOREACH (const CSwordModuleInfo *m, unindexedModules) {
+ moduleNameList.append(m->name());
}
- else {
+ QString moduleNames("<br><center>");
+ moduleNames.append(moduleNameList.join(", "));
+ moduleNames.append("</center><br>");
+
+ // Ask the user about unindexed modules:
+ int result = util::showQuestion(
+ this, tr("Missing indices"),
+ tr("The following modules need to be indexed before they can be"
+ " searched in:") + moduleNames + tr("Indexing could take a l"
+ "ong time. Click \"Yes\" to index the modules and start the "
+ "search, or \"No\" to cancel the search."),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+ // User didn't press "Yes":
+ if ((result & (QMessageBox::Yes | QMessageBox::Default)) == 0x0) {
+ return;
+ }
+
+ // Show indexing dialog, and index the modules:
+ if (!BtModuleIndexDialog::indexAllModules(unindexedModules)) {
+ // Failed or user cancelled.
return;
}
}
+ // Set the search options:
+ m_searcher.setSearchedText(searchText);
+ m_searcher.setModules(modules());
if (m_searchOptionsArea->hasSearchScope()) {
- m_searcher.setSearchScope( m_searchOptionsArea->searchScope() );
- }
- else {
+ m_searcher.setSearchScope(m_searchOptionsArea->searchScope());
+ } else {
m_searcher.resetSearchScope();
}
- m_searcher.setModules( modules() );
- m_searcher.setSearchedText(searchText);
-
-
- //Just to be sure that it can't be clicked again, if the search happens to be a bit slow.
- m_searchOptionsArea->searchButton()->setEnabled(false);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(false);
+ // Disable the dialog:
+ setEnabled(false);
+ setCursor(Qt::WaitCursor);
+ // Execute search:
m_searcher.startSearch();
- m_searchOptionsArea->searchButton()->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setEnabled(true);
- m_searchOptionsArea->m_searchTextCombo->setFocus();
+ // Display the search results:
+ if (m_searcher.foundItems() > 0) {
+ m_searchResultArea->setSearchResult(m_searcher.results());
+ } else {
+ m_searchResultArea->reset();
+ }
+ m_staticDialog->raise();
+ m_staticDialog->activateWindow();
+
+ // Re-enable the dialog:
+ setEnabled(true);
+ setCursor(Qt::ArrowCursor);
}
QString CSearchDialog::prepareSearchText(const QString& orig) {
@@ -179,8 +203,9 @@ QString CSearchDialog::prepareSearchText(const QString& orig) {
return text;
}
-/** Starts the search with the given module list and given search text. */
-void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText) {
+void CSearchDialog::startSearch(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText)
+{
m_searchResultArea->reset();
m_searchOptionsArea->reset();
setModules(modules);
@@ -189,27 +214,8 @@ void CSearchDialog::startSearch( const QList<CSwordModuleInfo*> modules, const Q
startSearch();
}
-/** Returns the list of used modules. */
-QList<CSwordModuleInfo*> CSearchDialog::modules() const {
- return m_searchOptionsArea->modules();
-}
-
-/** Sets the list of modules for the search. */
-void CSearchDialog::setModules( const QList<CSwordModuleInfo*> modules ) {
- m_searchOptionsArea->setModules(modules);
-}
-
-/** Returns the search text which is set currently. */
-QString CSearchDialog::searchText() const {
- return m_searchOptionsArea->searchText();
-}
-
-sword::ListKey CSearchDialog::searchScope() {
- return m_searchOptionsArea->searchScope();
-}
-
/** Sets the search text which is used for the search. */
-void CSearchDialog::setSearchText( const QString searchText ) {
+void CSearchDialog::setSearchText( const QString &searchText ) {
m_searchOptionsArea->setSearchText(searchText);
}
@@ -224,12 +230,16 @@ void CSearchDialog::initView() {
verticalLayout->addWidget(m_searchOptionsArea);
m_searchResultArea = new BtSearchResultArea(this);
+ m_searchResultArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
verticalLayout->addWidget(m_searchResultArea);
+ QLabel* hint = new QLabel(tr("Drag any verse reference onto an open Bible window"), this);
+ verticalLayout->addWidget(hint);
+
QHBoxLayout* horizontalLayout = new QHBoxLayout();
m_analyseButton = new QPushButton(tr("&Analyze results..."), 0);
- m_analyseButton->setToolTip(tr("Show a graphical analyzis of the search result"));
+ m_analyseButton->setToolTip(tr("Show a graphical analysis of the search result"));
QSpacerItem* spacerItem = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addWidget(m_analyseButton);
horizontalLayout->addItem(spacerItem);
@@ -244,17 +254,6 @@ void CSearchDialog::initView() {
loadDialogSettings();
}
-void CSearchDialog::searchFinished() {
- if ( m_searcher.foundItems() ) {
- m_searchResultArea->setSearchResult(modules());
- }
- else {
- m_searchResultArea->reset();
- }
- m_staticDialog->raise();
- m_staticDialog->activateWindow();
-}
-
void CSearchDialog::showModulesSelector() {
m_searchOptionsArea->chooseModules();
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index 55bded4..b8c097f 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,12 +15,10 @@
#include <QString>
#include "backend/cswordmodulesearch.h"
#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-
+#include "frontend/searchdialog/btsearchoptionsarea.h"
namespace Search {
class BtSearchResultArea;
-class BtSearchOptionsArea;
}
class QPushButton;
class QWidget;
@@ -28,12 +26,15 @@ class QWidget;
namespace Search {
/**
- *@author The BibleTime team
- */
+ \note destroys itself on close
+*/
class CSearchDialog : public QDialog {
Q_OBJECT
public:
- static void openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText = QString::null, QWidget* parentDialog = 0);
+ static void openDialog(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText = QString::null,
+ QWidget *parentDialog = 0);
+
static void closeDialog();
protected:
@@ -47,10 +48,6 @@ class CSearchDialog : public QDialog {
*/
static CSearchDialog* getSearchDialog();
- /**
- * The constructor of the dialog. It's protected because you should use the static public function openDialog.
- * The dialog destroys itself if it was closed.
- */
CSearchDialog(QWidget *parent);
~CSearchDialog();
@@ -58,33 +55,48 @@ class CSearchDialog : public QDialog {
* Initializes this object.
*/
void initView();
+
/**
- * Starts the search with the given module list and given search text.
- * Doesn't wait for the start button press, starts immediately
+ Starts the search with the given module list and given search text.
*/
- void startSearch( const QList<CSwordModuleInfo*> modules, const QString& searchText);
+ void startSearch(const QList<const CSwordModuleInfo*> modules,
+ const QString &searchText);
+
/**Prepares the search string given by user for a specific search type */
QString prepareSearchText(const QString& orig);
+
/**
- * Sets the list of modules for the search.
+ Sets the list of modules for the search.
*/
- void setModules( const QList<CSwordModuleInfo*> modules );
+ void setModules(const QList<const CSwordModuleInfo*> modules) {
+ m_searchOptionsArea->setModules(modules);
+ }
+
/**
- * Returns the list of used modules.
+ Returns the list of used modules.
*/
- QList<CSwordModuleInfo*> modules() const;
+ inline QList<const CSwordModuleInfo*> modules() const {
+ return m_searchOptionsArea->modules();
+ }
+
/**
* Sets the search text which is used for the search.
*/
- void setSearchText( const QString searchText );
+ void setSearchText( const QString &searchText );
+
/**
- * Returns the search text which is set currently.
+ \returns the search text which is set currently.
*/
- QString searchText() const;
+ QString searchText() const {
+ return m_searchOptionsArea->searchText();
+ }
+
/**
- * Returns the used search scope as a list key
+ \returns the used search scope as a list key
*/
- sword::ListKey searchScope();
+ inline sword::ListKey searchScope() const {
+ return m_searchOptionsArea->searchScope();
+ }
/**
* Resets the parts to the default.
@@ -101,10 +113,10 @@ class CSearchDialog : public QDialog {
protected slots:
/**
- * Starts the search with the set modules and the set search text.
+ Starts the search with the set modules and the set search text.
*/
void startSearch();
- void searchFinished();
+
void showModulesSelector();
/**
* Initializes the signal slot connections
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp b/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
deleted file mode 100644
index d09ae2a..0000000
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2007 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/searchdialog/csearchmodulechooserdialog.h"
-
-#include <QButtonGroup>
-#include <QDebug>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QSpacerItem>
-#include <QStringList>
-#include <QTreeWidget>
-#include <QVBoxLayout>
-#include "backend/btmoduletreeitem.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/directory.h"
-
-
-namespace Search {
-
-CSearchModuleChooserDialog::CSearchModuleChooserDialog( QWidget* parent, QString title, QString label,
- QList<CSwordModuleInfo*> selectedModules)
- : CModuleChooserDialog(parent, title, label),
- m_selectedModules(selectedModules) {
- m_hiddenFilter = new BTModuleTreeItem::HiddenOff();
- QList<BTModuleTreeItem::Filter*> filters;
- filters.append(m_hiddenFilter);
- setFilters(filters);
- init();
-}
-
-CSearchModuleChooserDialog::~CSearchModuleChooserDialog() {
- //see the ctor
- delete m_hiddenFilter;
-}
-
-void CSearchModuleChooserDialog::initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem) {
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- if (m_selectedModules.contains(btItem->moduleInfo()))
- widgetItem->setCheckState(0, Qt::Checked);
- else
- widgetItem->setCheckState(0, Qt::Unchecked);
-}
-
-} //end of namespace Search
diff --git a/src/frontend/searchdialog/csearchmodulechooserdialog.h b/src/frontend/searchdialog/csearchmodulechooserdialog.h
deleted file mode 100644
index bfa6126..0000000
--- a/src/frontend/searchdialog/csearchmodulechooserdialog.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CSEARCHMODULECHOOSERDIALOG_H
-#define CSEARCHMODULECHOOSERDIALOG_H
-
-#include "frontend/cmodulechooserdialog.h"
-
-
-class BTModuleTreeItem;
-class CSwordModuleInfo;
-class QTreeWidgetItem;
-
-namespace Search {
-
-class CSearchModuleChooserDialog : public CModuleChooserDialog {
- Q_OBJECT
- public:
- CSearchModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*> selectedModules);
- ~CSearchModuleChooserDialog();
-
- protected: // Protected methods
- virtual void initModuleItem(BTModuleTreeItem* btItem, QTreeWidgetItem* widgetItem);
-
- private:
- QList<CSwordModuleInfo*> m_selectedModules;
- BTModuleTreeItem::HiddenOff* m_hiddenFilter;
-};
-
-} //end of namespace Search
-
-#endif
diff --git a/src/frontend/searchdialog/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index fc137e2..6f15b62 100644
--- a/src/frontend/searchdialog/csearchresultview.cpp
+++ b/src/frontend/searchdialog/csearchresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -93,13 +93,16 @@ void CSearchResultView::initConnections() {
}
/** Setups the list with the given module. */
-void CSearchResultView::setupTree(CSwordModuleInfo* m) {
+void CSearchResultView::setupTree(const CSwordModuleInfo *m,
+ const sword::ListKey &results)
+{
clear();
if (!m) return;
m_module = m;
- sword::ListKey& result = m->searchResult();
+ /// \warning This is a workaround for Sword constness
+ sword::ListKey &result = const_cast<sword::ListKey&>(results);
const int count = result.Count();
if (!count) return;
@@ -118,24 +121,20 @@ void CSearchResultView::setupTree(CSwordModuleInfo* m) {
this->setCurrentItem(this->topLevelItem(0), 0);
}
-void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, QStringList* vList) {
+void CSearchResultView::setupStrongsTree(CSwordModuleInfo* m, const QStringList &vList) {
clear();
- if (!m) {
- return;
- }
+ if (!m) return;
m_module = m;
- if (vList->count() <= 0) {
- return;
- }
+ if (vList.empty()) return;
setUpdatesEnabled(false);
QTreeWidgetItem* oldItem = 0;
QTreeWidgetItem* item = 0;
- foreach (QString s, *vList) {
+ foreach (QString s, vList) {
item = new QTreeWidgetItem(this, oldItem);
item->setText(0, (s));
oldItem = item;
@@ -180,13 +179,13 @@ void CSearchResultView::printItems() {
void CSearchResultView::saveItems() {
CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
}
mgr.saveKeyList( keys, CExportManager::Text, false);
@@ -198,13 +197,13 @@ void CSearchResultView::saveItems() {
void CSearchResultView::saveItemsWithText() {
CExportManager mgr(tr("Save search result..."), true, tr("Saving search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.saveKeyList( keys, CExportManager::Text, true);
@@ -216,13 +215,13 @@ void CSearchResultView::saveItemsWithText() {
void CSearchResultView::copyItems() {
CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.copyKeyList( keys, CExportManager::Text, false);
@@ -234,13 +233,13 @@ void CSearchResultView::copyItems() {
void CSearchResultView::copyItemsWithText() {
CExportManager mgr(tr("Copy search result..."), true, tr("Copying search result"));
- CSwordModuleInfo* m = module();
+ const CSwordModuleInfo *m = module();
CSwordKey* k = 0;
QList<QTreeWidgetItem*> items = selectedItems();
QList<CSwordKey*> keys;
foreach (QTreeWidgetItem* i, items) {
k = CSwordKey::createInstance( m );
- k->key(i->text(0));
+ k->setKey(i->text(0));
keys.append( k );
};
mgr.copyKeyList( keys, CExportManager::Text, true);
@@ -249,25 +248,21 @@ void CSearchResultView::copyItemsWithText() {
keys.clear(); //delete all the keys we created
}
-CSwordModuleInfo* CSearchResultView::module() {
- return m_module;
-}
-
/// \todo port this to the new d'n'd
// Q3DragObject* CSearchResultView::dragObject() {
-// //return a valid DragObject to make DnD possible!
+// //return a valid DragObject to make DnD possible!
//
-// /*
-// * First get all selected items and fill with them the dndItems list. The return the QDragObject we got from CDRagDropMgr
-// */
-// CDragDropMgr::ItemList dndItems;
+// /*
+// * First get all selected items and fill with them the dndItems list. The return the QDragObject we got from CDRagDropMgr
+// */
+// CDragDropMgr::ItemList dndItems;
//
-// Q3PtrList<Q3ListViewItem> items = selectedItems();
-// for (items.first(); items.current(); items.next()) {
-// dndItems.append( CDragDropMgr::Item(m_module->name(), items.current()->text(0), QString::null) ); //no description
-// };
+// Q3PtrList<Q3ListViewItem> items = selectedItems();
+// for (items.first(); items.current(); items.next()) {
+// dndItems.append( CDragDropMgr::Item(m_module->name(), items.current()->text(0), QString::null) ); //no description
+// };
//
-// return CDragDropMgr::dragObject(dndItems, viewport());
+// return CDragDropMgr::dragObject(dndItems, viewport());
// }
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 52e6929..b3a09ee 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,11 +10,13 @@
#ifndef CSEARCHRESULTSVIEW_H
#define CSEARCHRESULTSVIEW_H
-class CSwordModuleInfo;
-
#include <QTreeWidget>
+// Sword includes
+#include <listkey.h>
+
+class CSwordModuleInfo;
class CReadDisplay;
class QAction;
class QMenu;
@@ -26,8 +28,13 @@ class CSearchResultView : public QTreeWidget {
public:
CSearchResultView(QWidget* parent);
virtual ~CSearchResultView();
- /** Returns the module which is currently used. */
- CSwordModuleInfo* module();
+
+ /**
+ \returns the module which is currently used.
+ */
+ inline const CSwordModuleInfo *module() const {
+ return m_module;
+ }
protected: // Protected methods
/**
@@ -42,11 +49,13 @@ class CSearchResultView : public QTreeWidget {
public slots: // Public slots
void saveItems();
+
/**
- * Setups the list with the given module.
+ Setups the list with the given module.
*/
- void setupTree(CSwordModuleInfo*);
- void setupStrongsTree(CSwordModuleInfo*, QStringList*);
+ void setupTree(const CSwordModuleInfo *m, const sword::ListKey &results);
+
+ void setupStrongsTree(CSwordModuleInfo*, const QStringList&);
void copyItemsWithText();
void copyItems();
void saveItemsWithText();
@@ -88,7 +97,7 @@ class CSearchResultView : public QTreeWidget {
m_actions;
QMenu* m_popup;
- CSwordModuleInfo* m_module;
+ const CSwordModuleInfo *m_module;
signals: // Signals
void keySelected(const QString&);