summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog/btsearchresultarea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/searchdialog/btsearchresultarea.cpp')
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp59
1 files changed, 35 insertions, 24 deletions
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 04e0415..f56c1b1 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -7,38 +7,37 @@
*
**********/
-#include "btsearchresultarea.h"
-#include "cmoduleresultview.h"
-#include "csearchresultview.h"
-#include "csearchdialog.h"
-#include "frontend/searchdialog/analysis/csearchanalysisdialog.h"
-
-#include "util/ctoolclass.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "backend/rendering/cdisplayrendering.h"
-#include "backend/keys/cswordversekey.h"
+#include "frontend/searchdialog/btsearchresultarea.h"
-#include <QWidget>
-#include <QStringList>
-#include <QVBoxLayout>
-#include <QSize>
-#include <QSplitter>
-#include <QFrame>
#include <QApplication>
+#include <QDebug>
+#include <QFrame>
#include <QProgressDialog>
#include <QPushButton>
+#include <QSize>
+#include <QSplitter>
+#include <QStringList>
+#include <QVBoxLayout>
+#include <QWidget>
+#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"
+#include "util/tool.h"
-#include <QDebug>
namespace Search {
BtSearchResultArea::BtSearchResultArea(QWidget *parent)
: QWidget(parent) {
- qDebug("BtSearchResultArea::BtSearchResultArea");
+ qDebug() << "BtSearchResultArea::BtSearchResultArea";
initView();
initConnections();
- qDebug("BtSearchResultArea::BtSearchResultArea end");
+ qDebug() << "BtSearchResultArea::BtSearchResultArea end";
}
BtSearchResultArea::~BtSearchResultArea() {
@@ -52,7 +51,7 @@ void BtSearchResultArea::initView() {
//Size is calculated from the font rather than set in pixels,
// maybe this is better in different kinds of displays?
- int mWidth = CToolClass::mWidth(this, 1);
+ int mWidth = util::tool::mWidth(this, 1);
this->setMinimumSize(QSize(mWidth*40, mWidth*15));
mainLayout = new QVBoxLayout(this);
mainSplitter = new QSplitter(this);
@@ -207,6 +206,10 @@ QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
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();
@@ -347,7 +350,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
int length = searchedText.length();
// Highlighting constants -
- // TODO: We need to make the highlight color configurable.
+ // \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();
@@ -364,7 +367,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
QStringList list;
// split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
- // TODO: find all possible seperators
+ // \todo find all possible seperators
QString regExp = "\\s";
list = searchedText.split(QRegExp(regExp));
foreach (QString newSearchText, list) {
@@ -434,6 +437,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
// 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("*")) {
@@ -442,6 +446,12 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
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");
@@ -453,7 +463,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
//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 (!CToolClass::inHTMLTag(index, ret)) {
+ if (!util::tool::inHTMLTag(index, ret)) {
length = matchLen;
ret = ret.insert( index + length, rep2 );
ret = ret.insert( index, rep1 );
@@ -462,6 +472,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
index += length;
}
}
+ qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
//qWarning("\n\n\n%s", ret.latin1());
return ret;
}