summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:58:34 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:58:34 -0400
commit1ea03c0fce8066c1e22188447b4a6ca4dcef1201 (patch)
tree1ad46980fdca402062502b20b7e16468b89393f8 /src/frontend/searchdialog
parent579657c8cb4ecd8a313221e70bdbbc7267f20286 (diff)
Imported Upstream version 2.10.1
Diffstat (limited to 'src/frontend/searchdialog')
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp6
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp57
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h18
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp136
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h4
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp6
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h3
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h6
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp332
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h14
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp11
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h5
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h4
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp81
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h4
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp26
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp32
-rw-r--r--src/frontend/searchdialog/csearchdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp22
-rw-r--r--src/frontend/searchdialog/csearchresultview.h4
28 files changed, 296 insertions, 559 deletions
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index ece0ced..10e4566 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,7 +18,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
#include "frontend/searchdialog/analysis/csearchanalysisview.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
namespace Search {
@@ -59,7 +59,7 @@ void CSearchAnalysisDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
m_buttonBox->addButton(QDialogButtonBox::Save);
//tr("Save as HTML"),
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
vboxLayout->addWidget(m_buttonBox);
bool ok = QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index b4edcad..454e105 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index 23b2962..c516184 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,6 +17,7 @@
#include <QRect>
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
+#include "util/htmlescape.h"
namespace Search {
@@ -61,17 +62,6 @@ CSearchAnalysisItem::~CSearchAnalysisItem() {
delete m_bufferPixmap;
}
-/** Sets the resultcount of this item for the given module */
-void CSearchAnalysisItem::setCountForModule( const int moduleIndex, const int count) {
- m_resultCountArray[moduleIndex] = count;
-}
-
-/** Returns the resultcount of this item for the given module */
-int CSearchAnalysisItem::getCountForModule( const int moduleIndex) {
- return m_resultCountArray[moduleIndex];
-}
-
-
bool CSearchAnalysisItem::hasHitsInAnyModule() {
foreach (const int hits, m_resultCountArray) {
if (hits) return true;
@@ -142,33 +132,36 @@ int CSearchAnalysisItem::width() {
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
typedef CSwordModuleSearch::Results::const_iterator RCI;
+ using util::htmlEscape;
- QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
- toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
+ QString toolTipString("<center><b>");
+ toolTipString.append(htmlEscape(m_bookName)).append("</b></center><hr/>")
+ .append("<table cellspacing=\"0\" cellpadding=\"3\" width=\"10"
+ "0%\" height=\"100%\" align=\"center\">");
/// \todo Fix that loop
int i = 0;
- 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());
-
- 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(c.name())
- .arg(info ? info->name() : QString::null)
- .arg( m_resultCountArray[i] )
- .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)results.Count())*(double)100 : 0.0, 0, 'g', 2)
- );
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ const CSwordModuleInfo * const info = it.key();
+
+ const int count = it.value().getCount();
+ const double percent = (info && count)
+ ? ((static_cast<double>(m_resultCountArray.at(i))
+ * static_cast<double>(100.0))
+ / static_cast<double>(count))
+ : 0.0;
+ toolTipString.append("<tr bgcolor=\"white\"><td><b><font color=\"")
+ .append(CSearchAnalysisScene::getColor(i).name()).append("\">")
+ .append(info ? info->name() : QString::null)
+ .append("</font></b></td><td>")
+ .append(m_resultCountArray.at(i))
+ .append(" (")
+ .append(QString::number(percent, 'g', 2))
+ .append("%)</td></tr>");
++i;
}
- toolTipString += "</table>";
-
- return toolTipString;
+ return toolTipString.append("</table>");
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index 7db96a9..ec2cd03 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -27,15 +29,21 @@ class CSearchAnalysisItem : public QGraphicsRectItem {
const CSwordModuleSearch::Results &results);
~CSearchAnalysisItem();
+
/**
- * Sets the resultcount of this item
+ Sets the resultcount of this item.
*/
- void setCountForModule( const int moduleIndex, const int count);
+ inline void setCountForModule(const int moduleIndex, const int count) {
+ m_resultCountArray[moduleIndex] = count;
+ }
/**
- * Returns the resultcount of this item
+ Returns the resultcount of this item.
*/
- int getCountForModule( const int moduleIndex);
+ inline int getCountForModule(const int moduleIndex) const {
+ return m_resultCountArray[moduleIndex];
+ }
+
/**
* Does one of the modules contain hits?
*/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index c5b9d02..e630846 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index 232fe64..f199aaf 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index a039e19..9b375e8 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,12 @@
#include <QFileDialog>
#include <QHashIterator>
#include <QTextCodec>
+#include <QTextDocument>
#include "backend/keys/cswordversekey.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"
#include "frontend/searchdialog/analysis/csearchanalysislegenditem.h"
#include "frontend/searchdialog/csearchdialog.h"
+#include "util/htmlescape.h"
#include "util/tool.h"
@@ -88,7 +90,7 @@ void CSearchAnalysisScene::analyse(
bool ok = true;
while (ok && analysisItem) {
moduleIndex = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
qApp->processEvents( QEventLoop::AllEvents );
if (!m_lastPosList.contains(it.key())) {
m_lastPosList.insert(it.key(), 0);
@@ -120,7 +122,7 @@ void CSearchAnalysisScene::setResults(
typedef CSwordModuleSearch::Results::const_iterator RCI;
m_results.clear();
- for (RCI it = results.begin(); it != results.end(); it++) {
+ 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());
@@ -205,13 +207,12 @@ QColor CSearchAnalysisScene::getColor(int index) {
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 sword::ListKey & result = m_results[module];
const int length = book.length();
unsigned int i = m_lastPosList[module];
unsigned int count = 0;
- const unsigned int resultCount = result.Count();
+ const unsigned int resultCount = result.getCount();
while (i < resultCount) {
if (strncmp(book.toUtf8(), (const char *) *result.getElement(i), length))
break;
@@ -223,67 +224,86 @@ unsigned int CSearchAnalysisScene::getCount(const QString &book,
}
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;
-
- int count = 0;
- QString countStr = "";
- QString m_searchAnalysisHTML = "";
- QString tableTitle = "";
- QString tableTotals = "";
- QString VerseRange = "";
- 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);
+ using util::htmlEscape;
- key.setKey("Genesis 1:1");
-
- CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
-
- QString text = "<html>\n<head>\n<title>" + tr("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
- text += "<table>\n<tr><th>" + tr("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";
-
- tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
- tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
-
- 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>");
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
- /// \warning This is a workaround for sword constness
- sword::ListKey searchResult = it.value();
- countStr.setNum(searchResult.Count());
+ const QString fileName = QFileDialog::getSaveFileName(0,
+ tr("Save Search Analysis"),
+ QString::null,
+ tr("XHTML files (*.html *.HTML *.HTM *.htm);;All files (*)"));
+ if (fileName.isEmpty())
+ return;
- tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
+ QString text("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>");
+ {
+ const QString title(tr("BibleTime Search Analysis"));
+ text += title;
+ text += "</title>"
+ "<style type=\"text/css\">"
+ "body{background-color:#fff;color:#000}"
+ "table{border-collapse:collapse}"
+ "td{border:1px solid #333}"
+ "th{font-size:130%;text-align:left;vertical-align:top}"
+ "td,th{text-align:left;padding:0.2em 0.5em}"
+ ".r{text-align:right}"
+ "</style>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
+ "</head><body><h1>";
+ text += title;
}
- tableTitle += QString("</tr>\n");
- tableTotals += QString("</tr>\n");
-
- m_searchAnalysisHTML = "";
- bool ok = true;
- while (ok) {
- m_searchAnalysisHTML += QString("<tr><td>") + key.book() + QString("</td>");
- analysisItem = m_itemList.value( key.book() );
+ text += "</h1><p><span style=\"font-weight:bold\">";
+ text += tr("Search text:");
+ text += "</span>&nbsp;";
+ text += htmlEscape(CSearchDialog::getSearchDialog()->searchText());
+ text += "</p><table><caption>";
+ text += tr("Results by work and book");
+ text += "</caption><tr><th>";
+ text += tr("Book");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<th>";
+ text += htmlEscape(it.key()->name());
+ text += "</th>";
+ }
+ text += "</tr>";
- int moduleIndex = 0;
- 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>");
+ CSwordVerseKey key(0);
+ key.setKey("Genesis 1:1");
- ++moduleIndex;
+ do {
+ text += "<tr><td>";
+ const QString keyBook(key.book());
+ text += htmlEscape(keyBook);
+ text += "</td>";
+
+ int mi = 0; // Module index
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it, ++mi) {
+ text += "<td class=\"r\">";
+ text += QString::number(m_itemList.value(keyBook)->getCountForModule(mi));
+ text += "</td>";
}
- m_searchAnalysisHTML += QString("</tr>\n");
- ok = key.next(CSwordVerseKey::UseBook);
+ text += "</tr>";
+ } while (key.next(CSwordVerseKey::UseBook));
+ text += "<tr><th class=\"r\">";
+ text += tr("Total hits");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<td class=\"r\">";
+ text += QString::number(it.value().getCount());
+ text += "</td>";
}
- text += QString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + QString("</table>\n");
- text += QString("<center>") + tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>") + QString("</center>");
- text += QString("</body></html>");
+ text += "</tr></table><p style=\"text-align:center;font-size:x-small\">";
+ text += tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>");
+ text += "</p></body></html>";
- util::tool::savePlainFile(fileName, text, false, QTextCodec::codecForName("UTF8"));
+ util::tool::savePlainFile(fileName, text, true, QTextCodec::codecForName("UTF8"));
}
void CSearchAnalysisScene::resizeHeight(int height) {
@@ -291,4 +311,4 @@ void CSearchAnalysisScene::resizeHeight(int height) {
slotResized();
}
-}
+} // namespace Search {
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index f8bb966..d1927d5 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index d177f63..277c1a3 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index 19d53c1..4b072f3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btsearchmodulechooserdialog.cpp b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
index 1d5f556..a5bfd2c 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -43,10 +43,6 @@ BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
retranslateUi();
}
-BtSearchModuleChooserDialog::~BtSearchModuleChooserDialog() {
- // Intentionally empty
-}
-
void BtSearchModuleChooserDialog::retranslateUi() {
setWindowTitle(tr("Works to Search in"));
util::tool::initExplanationLabel(label(), QString::null,
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.h b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
index 103682c..79802b5 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.h
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -26,7 +26,6 @@ class BtSearchModuleChooserDialog: public BtModuleChooserDialog {
public:
BtSearchModuleChooserDialog(QWidget *parent = 0,
Qt::WindowFlags flags = 0);
- ~BtSearchModuleChooserDialog();
inline void setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
bookshelfWidget()->treeModel()->setCheckedModules(modules);
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index 902666b..d850344 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,20 +16,25 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
-#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
#include "frontend/searchdialog/crangechooserdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+namespace {
+const QString SearchTypeKey = "GUI/SearchDialog/searchType";
+} // anonymous namespace
+
namespace Search {
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
@@ -57,10 +62,6 @@ BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType() {
return BtSearchOptionsArea::FullType;
}
-QPushButton* BtSearchOptionsArea::searchButton() const {
- return m_searchButton;
-}
-
void BtSearchOptionsArea::setSearchText(const QString& text) {
bool found = false;
int i = 0;
@@ -82,8 +83,6 @@ void BtSearchOptionsArea::setSearchText(const QString& text) {
}
void BtSearchOptionsArea::initView() {
- namespace DU = util::directory;
-
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
this->setSizePolicy(sizePolicy);
hboxLayout = new QHBoxLayout(this);
@@ -103,17 +102,17 @@ void BtSearchOptionsArea::initView() {
m_searchButton = new QPushButton(this);
m_searchButton->setText(tr("&Search"));
- m_searchButton->setIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ m_searchButton->setIcon(util::getIcon(CResMgr::searchdialog::icon));
m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
gridLayout->addWidget(m_searchButton, 0, 2);
m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
- m_chooseModulesButton->setIcon(DU::getIcon(CResMgr::searchdialog::chooseworks_icon));
+ m_chooseModulesButton->setIcon(util::getIcon(CResMgr::searchdialog::chooseworks_icon));
m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
gridLayout->addWidget(m_chooseModulesButton, 2, 2);
m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
- m_chooseRangeButton->setIcon(DU::getIcon(CResMgr::searchdialog::setupscope_icon));
+ m_chooseRangeButton->setIcon(util::getIcon(CResMgr::searchdialog::setupscope_icon));
m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
gridLayout->addWidget(m_chooseRangeButton, 3, 2);
@@ -243,7 +242,7 @@ void BtSearchOptionsArea::setModules(const QList<const CSwordModuleInfo*> &modul
for (int i = 0; i < m_modulesCombo->count(); ++i) {
historyList.append(m_modulesCombo->itemText(i));
}
- CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
+ btConfig().setValue("history/searchModuleHistory", historyList);
emit sigSetSearchButtonStatus(!modules.isEmpty());
}
@@ -284,7 +283,7 @@ void BtSearchOptionsArea::reset() {
}
void BtSearchOptionsArea::saveSettings() {
- CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
+ btConfig().setValue("properties/searchTexts", m_searchTextCombo->historyItems());
SearchType t = FullType;
if (m_typeAndButton->isChecked()) {
t = AndType;
@@ -292,25 +291,25 @@ void BtSearchOptionsArea::saveSettings() {
if (m_typeOrButton->isChecked()) {
t = OrType;
}
- CBTConfig::set(CBTConfig::searchType, t);
+ btConfig().setValue(SearchTypeKey, t);
}
void BtSearchOptionsArea::readSettings() {
- QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
+ const QStringList texts = btConfig().value<QStringList>("properties/searchTexts", QStringList());
//for some reason the slot was called when setting the upmost item
disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- for (int i = 0; i < texts.size(); i++) {
- if (texts.at(i).size() > 0)
- m_searchTextCombo->addItem(texts.at(i));
+ Q_FOREACH (const QString & text, texts) {
+ if (text.size() > 0)
+ m_searchTextCombo->addItem(text);
}
connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
+ m_modulesCombo->insertItems(0, btConfig().value<QStringList>("history/searchModuleHistory", QStringList()));
for (int i = 0; i < m_modulesCombo->count(); ++i) {
m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
}
- int stype = CBTConfig::get(CBTConfig::searchType);
+ int stype = btConfig().value<int>(SearchTypeKey, AndType);
switch (stype) {
case AndType:
m_typeAndButton->setChecked(true);
@@ -336,8 +335,8 @@ void BtSearchOptionsArea::setupRanges() {
}
void BtSearchOptionsArea::syntaxHelp() {
- // The dialog is deleted on close:
- BtSearchSyntaxHelpDialog *dlg = new BtSearchSyntaxHelpDialog(this);
+ BtSearchSyntaxHelpDialog * dlg = new BtSearchSyntaxHelpDialog(this);
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
}
@@ -349,23 +348,22 @@ void BtSearchOptionsArea::refreshRanges() {
//m_rangeChooserCombo->insertItem(tr("Last search result"));
//insert the user-defined ranges
- m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
-
+ m_rangeChooserCombo->insertItems(1, btConfig().getSearchScopesForCurrentLocale().keys());
}
sword::ListKey BtSearchOptionsArea::searchScope() {
if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
QString scope = map[ m_rangeChooserCombo->currentText() ];
if (!scope.isEmpty()) {
- return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
+ return sword::VerseKey().parseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
}
}
return sword::ListKey();
}
bool BtSearchOptionsArea::hasSearchScope() {
- return (searchScope().Count() > 0);
+ return (searchScope().getCount() > 0);
}
void BtSearchOptionsArea::addToHistory(const QString& text) {
@@ -419,7 +417,7 @@ void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
} // namespace Search
QDataStream &operator<<(QDataStream &out, const Search::BtSearchOptionsArea::SearchType &searchType) {
- out << (qint8) searchType;
+ out << static_cast<qint8>(searchType);
return out;
}
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index 375b5e7..a6483ac 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -56,7 +58,7 @@ class BtSearchOptionsArea : public QWidget {
SearchType searchType();
- QPushButton* searchButton() const;
+ inline QPushButton * searchButton() const { return m_searchButton; }
/**
Returns the list of used modules.
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 262ff23..6a82a4f 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,6 @@
#include "frontend/searchdialog/btsearchresultarea.h"
#include <QApplication>
-#include <QDebug>
#include <QFrame>
#include <QMenu>
#include <QProgressDialog>
@@ -22,13 +21,19 @@
#include <QWidget>
#include "backend/keys/cswordversekey.h"
#include "backend/rendering/cdisplayrendering.h"
-#include "frontend/display/cdisplay.h"
+#include "backend/config/btconfig.h"
+#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/searchdialog/cmoduleresultview.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/searchdialog/csearchresultview.h"
#include "util/tool.h"
+namespace {
+const QString MainSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/mainSplitterSizes";
+const QString ResultSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/resultSplitterSizes";
+} // anonymous namespace
+
namespace Search {
BtSearchResultArea::BtSearchResultArea(QWidget *parent)
@@ -76,7 +81,7 @@ void BtSearchResultArea::initView() {
QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
frameLayout->setContentsMargins(0, 0, 0, 0);
- m_previewDisplay = CDisplay::createReadInstance(0, m_displayFrame);
+ m_previewDisplay = new BtHtmlReadDisplay(0, m_displayFrame);
m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
frameLayout->addWidget(m_previewDisplay->view());
@@ -143,10 +148,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for bibles render 5 context verses
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//first go back and then go forward the keys to be in context
vk.previous(CSwordVerseKey::UseVerse);
@@ -174,10 +179,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for commentaries only one verse, but with heading
else if (module->type() == CSwordModuleInfo::Commentary) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//include Headings in display, they are indexed and searched too
if (vk.getVerse() == 1) {
@@ -198,295 +203,11 @@ void BtSearchResultArea::updatePreview(const QString& key) {
text = render.renderSingleKey(key, modules, settings);
}
- m_previewDisplay->setText( highlightSearchedText(text, searchedText) );
+ m_previewDisplay->setText( CSwordModuleSearch::highlightSearchedText(text, searchedText) );
m_previewDisplay->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key) );
}
}
-QStringList BtSearchResultArea::queryParser(const QString& queryString) {
- QString token;
- QStringList tokenList;
- int cnt, pos;
-
- token = "";
- cnt = 0;
- while (cnt < queryString.length()) {
- // add to token
- if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
- token = token + queryString[cnt];
- cnt++;
- }
- else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
- token = token + queryString[cnt];
- cnt++;
- }
- // token break
- else if (queryString[cnt] == ' ') {
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- token = "";
- cnt++;
- }
- // clucene appears to ignore quoted strings in the sence
- // that it treats all the words within quoted strings as
- // regular tokens and not as a single token.
- else if (queryString[cnt] == '"') {
- cnt++;
- }
- // 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++;
- //}
- // the ! token is also a token break
- else if (queryString[cnt] == '!') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("!");
- token = "";
- cnt++;
- }
- // the - token is also a token break
- else if (queryString[cnt] == '-') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("-");
- token = "";
- cnt++;
- }
- // the + token is also a token break
- else if (queryString[cnt] == '+') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the + token
- tokenList.append("+");
- token = "";
- cnt++;
- }
- // the || token is also a token break
- else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("||");
- token = "";
- cnt += 2;
- }
- // the && token is also a token break
- else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("&&");
- token = "";
- cnt += 2;
- }
- else cnt++;
- }
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
-
- cnt = 0;
- QStringList::iterator it;
- for ( it = tokenList.begin(); it != tokenList.end(); it++ ) {
- //-----------------------------------------------------------
- // remove all the NOT(!) tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- //-----------------------------------------------------------
- // remove all the operator tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
- ((*it) == "AND") || ((*it) == "&&") ) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- // if the token contains a ^ then trim the remainder of the
- // token from the ^
- //What??? error: invalid conversion from ‘const void*’ to ‘int’
- // and how come "contains" returns bool but is used as int?
- //else if ( (pos = (*it).contains("^")) >= 0 ) {
- else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
- (*it) = (*it).left(pos - 1);
- }
- // if the token contains a ~ then trim the remainder of the
- // token from the ~
- else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
- (*it) = (*it).left(pos - 2) + "*";
- }
- }
- return(tokenList);
-}
-
-QString BtSearchResultArea::highlightSearchedText(const QString& content, const QString& searchedText) {
- QString ret = content;
-
- const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-
- // int index = 0;
- int index = ret.indexOf("<body", 0);
- int matchLen = 0;
- int length = searchedText.length();
-
- // Highlighting constants -
- // \todo We need to make the highlight color configurable.
- const QString rep1("<span style=\"background-color:#FFFF66;\">");
- const QString rep2("</span>");
- const unsigned int repLength = rep1.length() + rep1.length();
- const QString rep3("style=\"background-color:#FFFF66;\" ");
- const unsigned int rep3Length = rep3.length();
-
-
- QString newSearchText;
-
- newSearchText = searchedText;
-
- // find the strongs search lemma and highlight it
- // search the searched text for "strong:" until it is not found anymore
- QStringList list;
-
- // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
- // \todo find all possible seperators
- QString regExp = "\\s";
- list = searchedText.split(QRegExp(regExp));
- foreach (QString newSearchText, list) {
- int sstIndex; // strong search text index for finding "strong:"
- int idx1, idx2;
- QString sNumber, lemmaText;
-
- sstIndex = newSearchText.indexOf("strong:");
- if (sstIndex == -1)
- continue;
-
- // set the start index to the start of <body>
- int strongIndex = index;
-
- // Get the strongs number from the search text.
- // First, find the first space after "strong:"
- sstIndex = sstIndex + 7;
- // get the strongs number -> the text following "strong:" to the end of the string.
- sNumber = newSearchText.mid(sstIndex, -1);
- // find all the "lemma=" inside the the content
- while ((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
- // get the strongs number after the lemma and compare it with the
- // strongs number we are looking for
- idx1 = ret.indexOf("\"", strongIndex) + 1;
- idx2 = ret.indexOf("\"", idx1 + 1);
- lemmaText = ret.mid(idx1, idx2 - idx1);
-
- // this is interesting because we could have a strongs number like: G3218|G300
- // To handle this we will use some extra cpu cycles and do a partial match against
- // the lemmaText
- if (lemmaText.contains(sNumber)) {
- // strongs number is found now we need to highlight it
- // I believe the easiest way is to insert rep3 just before "lemma="
- ret = ret.insert(strongIndex, rep3);
- strongIndex += rep3Length;
- }
- strongIndex += 6; // 6 is the length of "lemma="
- }
- }
- //---------------------------------------------------------------------
- // now that the strong: stuff is out of the way continue with
- // other search options
- //---------------------------------------------------------------------
-
- // try to figure out how to use the lucene query parser
-
- //using namespace lucene::queryParser;
- //using namespace lucene::search;
- //using namespace lucene::analysis;
- //using namespace lucene::util;
-
- //wchar_t *buf;
- //char buf8[1000];
- //standard::WhitespaceAnalyzer analyzer;
- //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //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);
- //}
-
- //===========================================================
- // since I could not figure out the lucene query parser, I
- // made a simple parser.
- //===========================================================
- QStringList words = queryParser(newSearchText);
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- foreach (QString word, words) { //search for every word in the list
- QRegExp findExp;
- if (word.contains("*")) {
- length = word.length() - 1;
- word.replace('*', "\\S*"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else if (word.contains("?")) {
- length = word.length() - 1;
- word.replace('?', "\\S?"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else {
- length = word.length();
- findExp = QRegExp("\\b" + word + "\\b");
- }
-
- // index = 0; //for every word start at the beginning
- index = ret.indexOf("<body", 0);
- findExp.setCaseSensitivity(cs);
- //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
- while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
- matchLen = findExp.matchedLength();
- if (!util::tool::inHTMLTag(index, ret)) {
- length = matchLen;
- ret = ret.insert( index + length, rep2 );
- ret = ret.insert( index, rep1 );
- index += repLength;
- }
- index += length;
- }
- }
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- //qWarning("\n\n\n%s", ret.latin1());
- return ret;
-}
-
/** Initializes the signal slot conections of the child widgets, */
void BtSearchResultArea::initConnections() {
connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
@@ -506,26 +227,28 @@ void BtSearchResultArea::initConnections() {
* Load the settings from the resource file
*/
void BtSearchResultArea::loadDialogSettings() {
- QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
- if (mainSplitterSizes.count() > 0) {
+ QList<int> mainSplitterSizes = btConfig().value< QList<int> >(MainSplitterSizesKey, QList<int>());
+ if (mainSplitterSizes.count() > 0)
m_mainSplitter->setSizes(mainSplitterSizes);
- }
- else {
+ else
+ {
int w = this->size().width();
int w2 = m_moduleListBox->sizeHint().width();
mainSplitterSizes << w2 << w - w2;
m_mainSplitter->setSizes(mainSplitterSizes);
}
- QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) m_resultListSplitter->setSizes(resultSplitterSizes);
+
+ QList<int> resultSplitterSizes = btConfig().value< QList<int> >(ResultSplitterSizesKey, QList<int>());
+ if (resultSplitterSizes.count() > 0)
+ m_resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
void BtSearchResultArea::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, m_mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, m_resultListSplitter->sizes());
+ btConfig().setValue(MainSplitterSizesKey, m_mainSplitter->sizes());
+ btConfig().setValue(ResultSplitterSizesKey, m_resultListSplitter->sizes());
}
/******************************************************************************
@@ -533,15 +256,12 @@ void BtSearchResultArea::saveDialogSettings() const {
******************************************************************************/
StrongsResultList::StrongsResultList(const CSwordModuleInfo *module,
- const sword::ListKey &results,
+ const sword::ListKey & result,
const QString &strongsNumber)
{
using namespace Rendering;
- /// \warning This is a workaround for Sword constness
- sword::ListKey result = results;
-
- int count = result.Count();
+ int count = result.getCount();
if (!count)
return;
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index bd75a02..e7a167d 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -134,16 +136,6 @@ class BtSearchResultArea : public QWidget {
void initConnections();
/**
- * This function breakes the queryString into clucene tokens
- */
- QStringList queryParser(const QString& queryString);
-
- /**
- * This function highlights the searched text in the content using the search type given by search flags
- */
- QString highlightSearchedText(const QString& content, const QString& searchedText);
-
- /**
* Load the settings from the resource file
*/
void loadDialogSettings();
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
index a1debc3..f1acddc 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,7 +13,7 @@
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QWebView>
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
@@ -22,7 +22,6 @@ namespace Search {
BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- setAttribute(Qt::WA_DeleteOnClose);
resize(550, 340);
QVBoxLayout *l = new QVBoxLayout;
@@ -42,10 +41,6 @@ BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFl
retranslateUi();
}
-BtSearchSyntaxHelpDialog::~BtSearchSyntaxHelpDialog() {
- // Intentionally empty
-}
-
void BtSearchSyntaxHelpDialog::retranslateUi() {
namespace DU = util::directory;
@@ -219,7 +214,7 @@ void BtSearchSyntaxHelpDialog::retranslateUi() {
m_webView->setHtml(html, QUrl::fromLocalFile(DU::getIconDir().path()));
- util::prepareDialogBox(m_buttons);
+ message::prepareDialogBox(m_buttons);
}
void BtSearchSyntaxHelpDialog::linkClicked(const QUrl &url) {
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
index 89cc805..74b74b5 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +24,6 @@ class BtSearchSyntaxHelpDialog: public QDialog {
Q_OBJECT
public:
BtSearchSyntaxHelpDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtSearchSyntaxHelpDialog();
protected:
void retranslateUi();
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index cf77627..231bd65 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index dffbcd8..922b042 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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 ab4810b..5bbc32f 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,10 +18,12 @@
#include <QtAlgorithms>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -43,8 +45,6 @@ CModuleResultView::~CModuleResultView() {
/** Initializes this widget. */
void CModuleResultView::initView() {
- namespace DU = util::directory;
-
// see also csearchresultview.cpp
setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
@@ -62,7 +62,7 @@ void CModuleResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
+ m_actions.copyMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
m_actions.copyMenu->addAction(m_actions.copy.result);
@@ -72,7 +72,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
+ m_actions.saveMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
m_actions.saveMenu->addAction(m_actions.save.result);
@@ -82,7 +82,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
m_actions.printMenu->addAction(m_actions.print.result);
@@ -96,48 +96,45 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-void CModuleResultView::setupTree(
- const CSwordModuleSearch::Results &results,
- const QString &searchedText)
+void CModuleResultView::setupTree(const CSwordModuleSearch::Results & results,
+ const QString & searchedText)
{
+ /// \todo implement sorting in this method.
+
clear();
m_results = results;
- /// \todo this class is for sorting
- //util::CSortListViewItem* item = 0;
- //util::CSortListViewItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
-
qDeleteAll(m_strongsResults);
m_strongsResults.clear();
bool strongsAvailable = false;
- Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
- sword::ListKey result = results.value(m);
-
- item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
- /// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
-
- item->setIcon(0, util::tool::getIconForModule(m) );
- //----------------------------------------------------------------------
- // we need to make a decision here. Either don't show any Strong's
- // number translations, or show the first one in the search text, or
- // figure out how to show them all.
- // I choose option number 2 at this time.
- //----------------------------------------------------------------------
- int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
- if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
- QString sNumber;
- //--------------------------------------------------
- // get the strongs number from the search text
- //--------------------------------------------------
- // first find the first space after "strong:"
- // this should indicate a change in search token
- sstIndex = sstIndex + 7;
- sTokenIndex = searchedText.indexOf(" ", sstIndex);
- sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
+ Q_FOREACH(const CSwordModuleInfo * m, results.keys()) {
+ /// \todo Remove this constructor hack once sword gets it right:
+ const int count = sword::ListKey(results.value(m)).getCount();
+ QTreeWidgetItem * item = new QTreeWidgetItem(this,
+ QStringList(m->name())
+ << QString::number(count));
+
+ item->setIcon(0, util::tool::getIconForModule(m));
+ /*
+ We need to make a decision here. Either don't show any Strong's
+ number translations, or show the first one in the search text, or
+ figure out how to show them all. I choose option number 2 at this time.
+ */
+
+ // strong search text index for finding "strong:"
+ int sstIndex = searchedText.indexOf("strong:", 0);
+ if (sstIndex != -1) {
+ /*
+ Get the strongs number from the search text. First find the first
+ space after "strong:". This should indicate a change in search
+ token
+ */
+ sstIndex += 7;
+ const int sTokenIndex = searchedText.indexOf(" ", sstIndex);
+ const QString sNumber(searchedText.mid(sstIndex, sTokenIndex - sstIndex));
setupStrongsResults(m, results[m], item, sNumber);
@@ -146,7 +143,7 @@ void CModuleResultView::setupTree(
}
};
- //Allow to hide the module strongs if there are any available
+ // Allow to hide the module strongs if there are any available
setRootIsDecorated( strongsAvailable );
}
@@ -269,8 +266,8 @@ void CModuleResultView::printResult() {
CSwordModuleInfo *m = activeModule();
if (m != 0) {
CExportManager mgr(true, tr("Printing search result"));
- mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
- CBTConfig::getFilterOptionDefaults());
+ mgr.printKeyList(m_results[m], m, btConfig().getDisplayOptions(),
+ btConfig().getFilterOptions());
};
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index 526ac16..24571d9 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 6a8c89d..efece49 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,8 +19,8 @@
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
-#include "util/dialogutil.h"
+#include "backend/config/btconfig.h"
+#include "frontend/messagedialog.h"
// Sword includes:
#include "versekey.h"
@@ -37,8 +37,8 @@ CRangeChooserDialog::CRangeChooserDialog(QWidget *parentDialog)
retranslateUi();
// Add the existing scopes
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
- CBTConfig::StringMap::Iterator it;
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
+ BtConfig::StringMap::Iterator it;
for (it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
}
@@ -74,7 +74,7 @@ void CRangeChooserDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
| QDialogButtonBox::RestoreDefaults);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
QHBoxLayout *rangeButtonsLayout = new QHBoxLayout();
rangeButtonsLayout->addWidget(m_newRangeButton);
@@ -176,6 +176,7 @@ void CRangeChooserDialog::addNewRange() {
void CRangeChooserDialog::selectedRangeChanged(QListWidgetItem * current,
QListWidgetItem * previous)
{
+ Q_UNUSED(current);
if (previous) {
Q_ASSERT(dynamic_cast<RangeItem*>(previous) != 0);
saveCurrentToRange(static_cast<RangeItem*>(previous));
@@ -211,9 +212,9 @@ void CRangeChooserDialog::updateResultList() {
//HACK: repair range to work with Sword 1.5.6
const QString range = m_rangeEdit->toPlainText().replace(QRegExp("\\s{0,}-\\s{0,}"), "-");
- sword::ListKey verses = VK().ParseVerseList(range.toUtf8().constData(),
+ sword::ListKey verses = VK().parseVerseList(range.toUtf8().constData(),
"Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
+ for (int i = 0; i < verses.getCount(); i++) {
new QListWidgetItem(QString::fromUtf8(verses.getElement(i)->getRangeText()),
m_resultList);
}
@@ -238,22 +239,23 @@ void CRangeChooserDialog::accept() {
// Save the new sorted map of search scopes:
m_rangeList->sortItems();
- CBTConfig::StringMap map;
+ BtConfig::StringMap map;
for (int i = 0; i < m_rangeList->count(); i++) {
Q_ASSERT(dynamic_cast<RangeItem*>(m_rangeList->item(i)) != 0);
const RangeItem * item = static_cast<RangeItem*>(m_rangeList->item(i));
map[item->caption()] = item->range();
}
- CBTConfig::set(CBTConfig::searchScopes, map);
+ btConfig().setSearchScopesWithCurrentLocale(map);
QDialog::accept();
}
void CRangeChooserDialog::restoreDefaults() {
- typedef CBTConfig::StringMap::ConstIterator SMCI;
+ typedef BtConfig::StringMap::ConstIterator SMCI;
m_rangeList->clear();
- const CBTConfig::StringMap map = CBTConfig::getDefault(CBTConfig::searchScopes);
+ btConfig().deleteSearchScopesWithCurrentLocale();
+ const BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
for (SMCI it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index db2ad30..a9cbaf4 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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 8ce55d4..54981e3 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,18 +20,23 @@
#include <QVBoxLayout>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/cswordmodulesearch.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/btmoduleindexdialog.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "frontend/searchdialog/btsearchresultarea.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
+namespace {
+const QString GeometryKey = "GUI/SearchDialog/geometry";
+} // anonymous namespace
+
namespace Search {
static CSearchDialog* m_staticDialog = 0;
@@ -78,9 +83,7 @@ CSearchDialog* CSearchDialog::getSearchDialog() {
CSearchDialog::CSearchDialog(QWidget *parent)
: QDialog(parent), /*m_searchButton(0),*/ m_closeButton(0),
m_searchResultArea(0), m_searchOptionsArea(0) {
- namespace DU = util::directory;
-
- setWindowIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ setWindowIcon(util::getIcon(CResMgr::searchdialog::icon));
setWindowTitle(tr("Search"));
setAttribute(Qt::WA_DeleteOnClose);
@@ -123,7 +126,7 @@ void CSearchDialog::startSearch() {
moduleNames.append("</center><br>");
// Ask the user about unindexed modules:
- int result = util::showQuestion(
+ int result = message::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"
@@ -185,7 +188,7 @@ QString CSearchDialog::prepareSearchText(const QString& orig) {
qDebug() << "After syntax characters removed:" << text;
text.replace(andWords, "\"and\"");
text.replace(orWords, "\"or\"");
- qDebug() << "After andor repclaced:" << text;
+ qDebug() << "After \"and\" and \"or\" replaced:" << text;
text.replace(" ", " AND ");
}
if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::OrType) {
@@ -219,7 +222,6 @@ void CSearchDialog::setSearchText( const QString &searchText ) {
/** Initializes this object. */
void CSearchDialog::initView() {
- namespace DU = util::directory;
QVBoxLayout* verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
@@ -244,7 +246,7 @@ void CSearchDialog::initView() {
m_closeButton = new QPushButton(this);
m_closeButton->setText(tr("&Close"));
- m_closeButton->setIcon(DU::getIcon(CResMgr::searchdialog::close_icon));
+ m_closeButton->setIcon(util::getIcon(CResMgr::searchdialog::close_icon));
horizontalLayout->addWidget(m_closeButton);
verticalLayout->addLayout(horizontalLayout);
@@ -283,15 +285,11 @@ void CSearchDialog::closeButtonClicked() {
}
void CSearchDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::searchDialogWidth), CBTConfig::get(CBTConfig::searchDialogHeight));
- move(CBTConfig::get(CBTConfig::searchDialogX), CBTConfig::get(CBTConfig::searchDialogY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void CSearchDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchDialogWidth, size().width());
- CBTConfig::set(CBTConfig::searchDialogHeight, size().height());
- CBTConfig::set(CBTConfig::searchDialogX, x());
- CBTConfig::set(CBTConfig::searchDialogY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index dd2fcd2..dde8537 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index 7966e56..c08e5cc 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +16,12 @@
#include <QTreeWidgetItem>
#include <QWidget>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/cdragdrop.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -33,8 +35,6 @@ CSearchResultView::CSearchResultView(QWidget* parent)
/** Initializes the view of this widget. */
void CSearchResultView::initView() {
- namespace DU = util::directory;
-
setToolTip(tr("Search result of the selected work"));
setHeaderLabel(tr("Results"));
setDragEnabled(true);
@@ -45,7 +45,7 @@ void CSearchResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
+ m_actions.copyMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyItems()) );
@@ -59,7 +59,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
+ m_actions.saveMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveItems()) );
@@ -71,7 +71,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printItems()) );
@@ -91,16 +91,14 @@ void CSearchResultView::initConnections() {
/** Setups the list with the given module. */
void CSearchResultView::setupTree(const CSwordModuleInfo *m,
- const sword::ListKey &results)
+ const sword::ListKey & result)
{
clear();
if (!m) return;
m_module = m;
- /// \warning This is a workaround for Sword constness
- sword::ListKey &result = const_cast<sword::ListKey&>(results);
- const int count = result.Count();
+ const int count = result.getCount();
if (!count) return;
setUpdatesEnabled(false);
@@ -169,7 +167,7 @@ void CSearchResultView::printItems() {
foreach (QTreeWidgetItem* k, items) {
list.append( k->text(0) );
}
- mgr.printKeyList( list, module(), CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() );
+ mgr.printKeyList( list, module(), btConfig().getDisplayOptions(), btConfig().getFilterOptions() );
}
void CSearchResultView::saveItems() {
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 1d37cbd..76b6d38 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/