Changeset 846 for trunk/tools/assistant/lib
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 76 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/assistant/lib/fulltextsearch/fulltextsearch.pro
r631 r846 32 32 CONFIG -= exceptions_off 33 33 CONFIG += exceptions 34 !win32|win32-g++ {34 !win32|win32-g++* { 35 35 QMAKE_CFLAGS -= -fno-exceptions 36 36 QMAKE_CXXFLAGS -= -fno-exceptions … … 49 49 # the following define could be set globally in case we need it elsewhere 50 50 solaris* { 51 DEFINES += Q_SOLARIS_VERSION=$$system(uname -r | sed -e 's/5\ .//')51 DEFINES += Q_SOLARIS_VERSION=$$system(uname -r | sed -e 's/5\\.//') 52 52 } -
trunk/tools/assistant/lib/fulltextsearch/qanalyzer.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qanalyzer_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qclucene-config_p.h
r769 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** … … 315 315 #endif 316 316 317 // Do not use the tchar.h that ships with mingw, this causes the qt build to 318 // fail (211547, 211401, etc...), reuse the replacement as with any other compiler 319 // #if defined(__MINGW32__) 320 // /* Define to 1 if you have the <tchar.h> header file. */ 321 // # ifndef _CL_HAVE_TCHAR_H 322 // # define _CL_HAVE_TCHAR_H 1 323 // # endif 324 // #endif 317 #if defined(__MINGW32__) 318 /* Define to 1 if you have the <tchar.h> header file. */ 319 # ifndef _CL_HAVE_TCHAR_H 320 # define _CL_HAVE_TCHAR_H 1 321 # endif 322 #endif 325 323 326 324 #if defined(__MINGW32__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C) -
trunk/tools/assistant/lib/fulltextsearch/qclucene_global_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** … … 37 37 #include <QtCore/QString> 38 38 39 #if !defined(_MSC_VER) 39 #if !defined(_MSC_VER) && !defined(__MINGW32__) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) 40 40 # if !defined(TCHAR) 41 41 # if defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) && !defined(_ASCII) -
trunk/tools/assistant/lib/fulltextsearch/qdocument.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qdocument_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qfield.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qfield_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qfilter.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qfilter_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qhits.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qhits_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qindexreader.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qindexreader_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qindexwriter.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** … … 89 89 90 90 d->writer->addIndexes(readerArray); 91 delete readerArray;91 delete [] readerArray; 92 92 } 93 93 -
trunk/tools/assistant/lib/fulltextsearch/qindexwriter_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qquery.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qquery_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qqueryparser.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qqueryparser_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qreader.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qreader_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qsearchable.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qsearchable_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qsort.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** … … 85 85 for (int i = 0; i < fieldNames.count(); ++i) 86 86 delete [] nameArray[i]; 87 delete nameArray;87 delete [] nameArray; 88 88 } 89 89 -
trunk/tools/assistant/lib/fulltextsearch/qsort_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** … … 65 65 { 66 66 public: 67 68 69 QCLuceneSort(const QString &field, bool reverse = false);67 QCLuceneSort(); 68 explicit QCLuceneSort(const QStringList &fieldNames); 69 explicit QCLuceneSort(const QString &field, bool reverse = false); 70 70 71 71 virtual ~QCLuceneSort(); … … 73 73 QString toString() const; 74 74 void setSort(const QStringList &fieldNames); 75 75 void setSort(const QString &field, bool reverse = false); 76 76 77 77 protected: -
trunk/tools/assistant/lib/fulltextsearch/qterm.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qterm_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtoken.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtoken_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtokenizer.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtokenizer_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtokenstream.cpp
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/fulltextsearch/qtokenstream_p.h
r651 r846 4 4 ** All rights reserved. 5 5 ** 6 ** Portion Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 ** All rights reserved. 8 8 ** -
trunk/tools/assistant/lib/lib.pro
r561 r846 24 24 QtXml 25 25 LIBS_PRIVATE += -l$$qclucene 26 27 26 RESOURCES += helpsystem.qrc 28 27 SOURCES += qhelpenginecore.cpp \ … … 42 41 qhelpsearchindexreader_default.cpp \ 43 42 qhelpsearchindexreader.cpp \ 43 qclucenefieldnames.cpp \ 44 44 qhelp_global.cpp 45 45 … … 64 64 qhelpsearchindexwriter_default_p.h \ 65 65 qhelpsearchindexreader_default_p.h \ 66 qhelpsearchindexreader_p.h 66 qhelpsearchindexreader_p.h \ 67 qclucenefieldnames_p.h 67 68 68 69 # access to clucene -
trunk/tools/assistant/lib/qhelp_global.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include <QtCore/QCoreApplication> 42 43 #include <QtCore/QRegExp> 43 44 #include <QtCore/QMutexLocker> … … 56 57 57 58 return QString::fromLatin1("%1-%2-%3"). 58 arg(name).arg( long(pointer)).arg(counter);59 arg(name).arg(quintptr(pointer)).arg(counter); 59 60 } 60 61 61 62 QString QHelpGlobal::documentTitle(const QString &content) 62 63 { 63 QString title = Q Object::tr("Untitled");64 QString title = QCoreApplication::translate("QHelp", "Untitled"); 64 65 if (!content.isEmpty()) { 65 66 int start = content.indexOf(QLatin1String("<title>"), 0, Qt::CaseInsensitive) + 7; … … 87 88 QString QHelpGlobal::codecFromHtmlData(const QByteArray &data) 88 89 { 89 QString content = QString::fromUtf8(data.constData(), data.size());90 int start = content.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive);90 QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size())); 91 int start = head.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive); 91 92 if (start > 0) { 92 int end;93 93 QRegExp r(QLatin1String("charset=([^\"\\s]+)")); 94 94 while (start != -1) { 95 end = content.indexOf(QLatin1Char('>'), start) + 1; 96 const QString &meta = content.mid(start, end - start).toLower(); 95 const int end = head.indexOf(QLatin1Char('>'), start) + 1; 96 if (end <= start) 97 break; 98 const QString &meta = head.mid(start, end - start).toLower(); 97 99 if (r.indexIn(meta) != -1) 98 100 return r.cap(1); 99 start = content.indexOf(QLatin1String("<meta"), end,101 start = head.indexOf(QLatin1String("<meta"), end, 100 102 Qt::CaseInsensitive); 101 103 } … … 106 108 QString QHelpGlobal::codecFromXmlData(const QByteArray &data) 107 109 { 108 QString content = QString::fromUtf8(data.constData(), data.size());110 QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size())); 109 111 const QRegExp encodingExp(QLatin1String("^\\s*<\\?xml version=" 110 112 "\"\\d\\.\\d\" encoding=\"([^\"]+)\"\\?>.*")); 111 return encodingExp.exactMatch( content) ? encodingExp.cap(1) : QString();113 return encodingExp.exactMatch(head) ? encodingExp.cap(1) : QString(); 112 114 } -
trunk/tools/assistant/lib/qhelp_global.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpcollectionhandler.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 115 115 } 116 116 117 m_query.exec(QLatin1String("PRAGMA synchronous=OFF")); 118 m_query.exec(QLatin1String("PRAGMA cache_size=3000")); 119 117 120 m_query.exec(QLatin1String("SELECT COUNT(*) FROM sqlite_master WHERE TYPE=\'table\'" 118 121 "AND Name=\'NamespaceTable\'")); … … 163 166 return false; 164 167 } 168 169 copyQuery->exec(QLatin1String("PRAGMA synchronous=OFF")); 170 copyQuery->exec(QLatin1String("PRAGMA cache_size=3000")); 165 171 166 172 if (!createTables(copyQuery)) { … … 309 315 m_query.bindValue(0, filterName); 310 316 m_query.exec(); 311 while (m_query.next()) {317 if (m_query.next()) 312 318 nameId = m_query.value(0).toInt(); 313 break;314 }315 319 316 320 m_query.exec(QLatin1String("SELECT Id, Name FROM FilterAttributeTable")); … … 585 589 586 590 QSqlQuery query(db); 591 db.exec(QLatin1String("PRAGMA synchronous=OFF")); 592 db.exec(QLatin1String("PRAGMA cache_size=3000")); 587 593 db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS NameIndex ON IndexTable(Name)")); 588 594 db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileNameIndex ON FileNameTable(Name)")); -
trunk/tools/assistant/lib/qhelpcollectionhandler_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 77 77 typedef QList<DocInfo> DocInfoList; 78 78 79 QHelpCollectionHandler(const QString &collectionFile, QObject *parent = 0); 79 explicit QHelpCollectionHandler(const QString &collectionFile, 80 QObject *parent = 0); 80 81 ~QHelpCollectionHandler(); 81 82 -
trunk/tools/assistant/lib/qhelpcontentwidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 371 371 d->rootItem = 0; 372 372 } 373 reset(); 373 if (!onShutDown) 374 reset(); 374 375 } 375 376 -
trunk/tools/assistant/lib/qhelpcontentwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpdatainterface.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpdatainterface_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpdbreader.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 206 206 "AND c.Name=? AND c.NamespaceId=d.Id AND d.Name=?")); 207 207 m_query->bindValue(0, filePath); 208 m_query->bindValue(1, Q Latin1String("./") + filePath);208 m_query->bindValue(1, QString(QLatin1String("./") + filePath)); 209 209 m_query->bindValue(2, virtualFolder); 210 210 m_query->bindValue(3, m_namespace); -
trunk/tools/assistant/lib/qhelpdbreader_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpengine.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 QHelpEngineCorePrivate::init(collectionFile, helpEngineCore); 77 77 78 contentModel = new QHelpContentModel(this); 79 indexModel = new QHelpIndexModel(this); 80 81 connect(helpEngineCore, SIGNAL(setupFinished()), 82 this, SLOT(applyCurrentFilter())); 83 connect(helpEngineCore, SIGNAL(currentFilterChanged(QString)), 84 this, SLOT(applyCurrentFilter())); 85 78 if (!contentModel) 79 contentModel = new QHelpContentModel(this); 80 if (!indexModel) 81 indexModel = new QHelpIndexModel(this); 82 83 connect(helpEngineCore, SIGNAL(setupFinished()), this, 84 SLOT(applyCurrentFilter())); 85 connect(helpEngineCore, SIGNAL(currentFilterChanged(QString)), this, 86 SLOT(applyCurrentFilter())); 86 87 } 87 88 -
trunk/tools/assistant/lib/qhelpengine.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 64 64 public: 65 QHelpEngine(const QString &collectionFile, QObject *parent = 0);65 explicit QHelpEngine(const QString &collectionFile, QObject *parent = 0); 66 66 ~QHelpEngine(); 67 67 -
trunk/tools/assistant/lib/qhelpengine_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpenginecore.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 120 120 QHelpGlobal::uniquifyConnectionName(info.fileName, this), this); 121 121 if (!reader->init()) { 122 emit q->warning( tr("Cannot open documentation file %1: %2!")122 emit q->warning(QHelpEngineCore::tr("Cannot open documentation file %1: %2!") 123 123 .arg(absFileName, reader->errorMessage())); 124 124 continue; … … 407 407 /*! 408 408 Adds the new custom filter \a filterName. The filter attributes 409 are specified by \a attributes. The function returns false if 410 the filter can not be added, e.g. when the filter already exists. 409 are specified by \a attributes. If the filter already exists, 410 its attribute set is replaced. The function returns true if 411 the operation succeeded, otherwise it returns false. 411 412 412 413 \sa customFilters(), removeCustomFilter() … … 706 707 707 708 /*! 708 Returns a description of the last error that occur ed.709 Returns a description of the last error that occurred. 709 710 */ 710 711 QString QHelpEngineCore::error() const -
trunk/tools/assistant/lib/qhelpenginecore.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 67 67 public: 68 QHelpEngineCore(const QString &collectionFile, QObject *parent = 0);68 explicit QHelpEngineCore(const QString &collectionFile, QObject *parent = 0); 69 69 virtual ~QHelpEngineCore(); 70 70 -
trunk/tools/assistant/lib/qhelpgenerator.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 48 48 #include <QtCore/QDir> 49 49 #include <QtCore/QDebug> 50 #include <QtCore/QSet> 50 51 #include <QtCore/QVariant> 51 52 #include <QtCore/QDateTime> … … 190 191 return false; 191 192 } 193 194 d->query->exec(QLatin1String("PRAGMA synchronous=OFF")); 195 d->query->exec(QLatin1String("PRAGMA cache_size=3000")); 192 196 193 197 addProgress(1.0); … … 538 542 539 543 int fileId = -1; 540 if (!d->fileMap.contains(fileName)) { 544 QMap<QString, int>::Iterator fileMapIt = d->fileMap.find(fileName); 545 if (fileMapIt == d->fileMap.end()) { 541 546 fileDataList.append(qCompress(data)); 542 547 … … 552 557 ++tableFileId; 553 558 } else { 554 fileId = d->fileMap.value(fileName); 559 fileId = fileMapIt.value(); 560 QSet<int> &fileFilterSet = d->fileFilterMap[fileId]; 561 QSet<int> &tmpFileFilterSet = tmpFileFilterMap[fileId]; 555 562 foreach (const int &filter, filterAtts) { 556 if (! d->fileFilterMap.value(fileId).contains(filter)557 && !tmpFileFilter Map.value(fileId).contains(filter)) {558 d->fileFilterMap[fileId].insert(filter);559 tmpFileFilterMap[fileId].insert(filter);563 if (!fileFilterSet.contains(filter) 564 && !tmpFileFilterSet.contains(filter)) { 565 fileFilterSet.insert(filter); 566 tmpFileFilterSet.insert(filter); 560 567 } 561 568 } … … 563 570 } 564 571 565 if ( tmpFileFilterMap.count()) {572 if (!tmpFileFilterMap.isEmpty()) { 566 573 d->query->exec(QLatin1String("BEGIN")); 567 574 QMap<int, QSet<int> >::const_iterator it = tmpFileFilterMap.constBegin(); … … 626 633 attributeMap.insert(d->query->value(1).toString(), 627 634 d->query->value(0).toInt()); 628 if (idsToInsert.contains(d->query->value(1).toString())) 629 idsToInsert.removeAll(d->query->value(1).toString()); 635 idsToInsert.removeAll(d->query->value(1).toString()); 630 636 } 631 637 … … 675 681 } 676 682 677 bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,683 bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> &keywords, 678 684 const QStringList &filterAttributes) 679 685 { … … 705 711 int i = 0; 706 712 d->query->exec(QLatin1String("BEGIN")); 713 QSet<QString> indices; 707 714 foreach (const QHelpDataIndexItem &itm, keywords) { 715 // Identical ids make no sense and just confuse the Assistant user, 716 // so we ignore all repetitions. 717 if (indices.contains(itm.identifier)) 718 continue; 719 720 // Still empty ids should be ignored, as otherwise we will include only 721 // the first keyword with an empty id. 722 if (!itm.identifier.isEmpty()) 723 indices.insert(itm.identifier); 724 708 725 pos = itm.reference.indexOf(QLatin1Char('#')); 709 726 fileName = itm.reference.left(pos); … … 717 734 fName = fName.mid(2); 718 735 719 if (d->fileMap.contains(fName)) 720 fileId = d->fileMap.value(fName); 736 QMap<QString, int>::ConstIterator it = d->fileMap.find(fName); 737 if (it != d->fileMap.end()) 738 fileId = it.value(); 721 739 else 722 740 fileId = 1; … … 750 768 751 769 d->query->exec(QLatin1String("SELECT COUNT(Id) FROM IndexTable")); 752 if (d->query->next() && d->query->value(0).toInt() >= keywords.count())770 if (d->query->next() && d->query->value(0).toInt() >= indices.count()) 753 771 return true; 754 772 return false; … … 825 843 } 826 844 845 bool QHelpGenerator::checkLinks(const QHelpDataInterface &helpData) 846 { 847 /* 848 * Step 1: Gather the canoncal file paths of all files in the project. 849 * We use a set, because there will be a lot of look-ups. 850 */ 851 QSet<QString> files; 852 foreach (const QHelpDataFilterSection &filterSection, helpData.filterSections()) { 853 foreach (const QString &file, filterSection.files()) { 854 QFileInfo fileInfo(helpData.rootPath() + QDir::separator() + file); 855 const QString &canonicalFileName = fileInfo.canonicalFilePath(); 856 if (!fileInfo.exists()) 857 emit warning(tr("File '%1' does not exist.").arg(file)); 858 else 859 files.insert(canonicalFileName); 860 } 861 } 862 863 /* 864 * Step 2: Check the hypertext and image references of all HTML files. 865 * Note that we don't parse the files, but simply grep for the 866 * respective HTML elements. Therefore. contents that are e.g. 867 * commented out can cause false warning. 868 */ 869 bool allLinksOk = true; 870 foreach (const QString &fileName, files) { 871 if (!fileName.endsWith(QLatin1String("html")) 872 && !fileName.endsWith(QLatin1String("htm"))) 873 continue; 874 QFile htmlFile(fileName); 875 if (!htmlFile.open(QIODevice::ReadOnly)) { 876 emit warning(tr("File '%1' cannot be opened.").arg(fileName)); 877 continue; 878 } 879 const QRegExp linkPattern(QLatin1String("<(?:a href|img src)=\"?([^#\">]+)[#\">]")); 880 QTextStream stream(&htmlFile); 881 const QString codec = QHelpGlobal::codecFromData(htmlFile.read(1000)); 882 stream.setCodec(QTextCodec::codecForName(codec.toLatin1().constData())); 883 const QString &content = stream.readAll(); 884 QStringList invalidLinks; 885 for (int pos = linkPattern.indexIn(content); pos != -1; 886 pos = linkPattern.indexIn(content, pos + 1)) { 887 const QString& linkedFileName = linkPattern.cap(1); 888 if (linkedFileName.contains(QLatin1String("://"))) 889 continue; 890 const QString curDir = QFileInfo(fileName).dir().path(); 891 const QString &canonicalLinkedFileName = 892 QFileInfo(curDir + QDir::separator() + linkedFileName).canonicalFilePath(); 893 if (!files.contains(canonicalLinkedFileName) 894 && !invalidLinks.contains(canonicalLinkedFileName)) { 895 emit warning(tr("File '%1' contains an invalid link to file '%2'"). 896 arg(fileName).arg(linkedFileName)); 897 allLinksOk = false; 898 invalidLinks.append(canonicalLinkedFileName); 899 } 900 } 901 } 902 903 if (!allLinksOk) 904 d->error = tr("Invalid links in HTML files."); 905 return allLinksOk; 906 } 907 827 908 QT_END_NAMESPACE 909 -
trunk/tools/assistant/lib/qhelpgenerator_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 75 75 bool generate(QHelpDataInterface *helpData, 76 76 const QString &outputFileName); 77 bool checkLinks(const QHelpDataInterface &helpData); 77 78 QString error() const; 78 79 … … 97 98 bool registerVirtualFolder(const QString &folderName, const QString &ns); 98 99 bool insertFilterAttributes(const QStringList &attributes); 99 bool insertKeywords(const QList<QHelpDataIndexItem> keywords,100 bool insertKeywords(const QList<QHelpDataIndexItem> &keywords, 100 101 const QStringList &filterAttributes); 101 102 bool insertFiles(const QStringList &files, const QString &rootPath, -
trunk/tools/assistant/lib/qhelpindexwidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 245 245 d->indexProvider->stopCollecting(); 246 246 d->indices.clear(); 247 filter(QString()); 247 if (!onShutDown) 248 filter(QString()); 248 249 } 249 250 -
trunk/tools/assistant/lib/qhelpindexwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpprojectdata.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "qhelpprojectdata_p.h" 43 43 44 #include <QtCore/QCoreApplication> 44 45 #include <QtCore/QDir> 45 46 #include <QtCore/QFileInfo> … … 47 48 #include <QtCore/QMap> 48 49 #include <QtCore/QRegExp> 50 #include <QtCore/QUrl> 49 51 #include <QtCore/QVariant> 50 52 #include <QtXml/QXmlStreamReader> … … 77 79 void raiseUnknownTokenError(); 78 80 void addMatchingFiles(const QString &pattern); 81 bool hasValidSyntax(const QString &nameSpace, const QString &vFolder) const; 79 82 80 83 QMap<QString, QStringList> dirEntriesCache; … … 83 86 void QHelpProjectDataPrivate::raiseUnknownTokenError() 84 87 { 85 raiseError(Q Object::tr("Unknown token."));88 raiseError(QCoreApplication::translate("QHelpProject", "Unknown token.")); 86 89 } 87 90 … … 96 99 readProject(); 97 100 else 98 raiseError(QObject::tr("Unknown token. Expected \"QtHelpProject\"!")); 101 raiseError(QCoreApplication::translate("QHelpProject", 102 "Unknown token. Expected \"QtHelpProject\"!")); 99 103 } 100 104 } 101 105 102 106 if (hasError()) { 103 raiseError(QObject::tr("Error in line %1: %2").arg(lineNumber()) 107 raiseError(QCoreApplication::translate("QHelpProject", 108 "Error in line %1: %2").arg(lineNumber()) 104 109 .arg(errorString())); 105 110 } … … 113 118 if (name() == QLatin1String("virtualFolder")) { 114 119 virtualFolder = readElementText(); 115 if (virtualFolder.contains(QLatin1String("/"))) 116 raiseError(QObject::tr("A virtual folder must not contain a \'/\' character!")); 120 if (!hasValidSyntax(QLatin1String("test"), virtualFolder)) 121 raiseError(QCoreApplication::translate("QHelpProject", 122 "Virtual folder has invalid syntax.")); 117 123 } else if (name() == QLatin1String("namespace")) { 118 124 namespaceName = readElementText(); 119 if (namespaceName.contains(QLatin1String("/"))) 120 raiseError(QObject::tr("A namespace must not contain a \'/\' character!")); 125 if (!hasValidSyntax(namespaceName, QLatin1String("test"))) 126 raiseError(QCoreApplication::translate("QHelpProject", 127 "Namespace has invalid syntax.")); 121 128 } else if (name() == QLatin1String("customFilter")) { 122 129 readCustomFilter(); … … 126 133 QString n = attributes().value(QLatin1String("name")).toString(); 127 134 if (!metaData.contains(n)) 128 metaData[n] = attributes().value(QLatin1String("value")).toString(); 135 metaData[n] 136 = attributes().value(QLatin1String("value")).toString(); 129 137 else 130 metaData.insert(n, attributes().value(QLatin1String("value")).toString()); 138 metaData.insert(n, attributes(). 139 value(QLatin1String("value")).toString()); 131 140 } else { 132 141 raiseUnknownTokenError(); … … 134 143 } else if (isEndElement() && name() == QLatin1String("QtHelpProject")) { 135 144 if (namespaceName.isEmpty()) 136 raiseError(QObject::tr("Missing namespace in QtHelpProject.")); 145 raiseError(QCoreApplication::translate("QHelpProject", 146 "Missing namespace in QtHelpProject.")); 137 147 else if (virtualFolder.isEmpty()) 138 raiseError(QObject::tr("Missing virtual folder in QtHelpProject")); 148 raiseError(QCoreApplication::translate("QHelpProject", 149 "Missing virtual folder in QtHelpProject")); 139 150 break; 140 151 } … … 224 235 || (attributes().value(QLatin1String("name")).toString().isEmpty() 225 236 && attributes().value(QLatin1String("id")).toString().isEmpty())) 226 raiseError(QObject::tr("Missing attribute in keyword at line %1.") 227 .arg(lineNumber())); 228 filterSectionList.last().addIndex( 229 QHelpDataIndexItem(attributes().value(QLatin1String("name")).toString(), 230 attributes().value(QLatin1String("id")).toString(), 231 attributes().value(QLatin1String("ref")).toString())); 237 raiseError(QCoreApplication::translate("QHelpProject", 238 "Missing attribute in keyword at line %1.") 239 .arg(lineNumber())); 240 filterSectionList.last() 241 .addIndex(QHelpDataIndexItem(attributes(). 242 value(QLatin1String("name")).toString(), 243 attributes().value(QLatin1String("id")).toString(), 244 attributes().value(QLatin1String("ref")).toString())); 232 245 } else { 233 246 raiseUnknownTokenError(); … … 306 319 } 307 320 321 bool QHelpProjectDataPrivate::hasValidSyntax(const QString &nameSpace, 322 const QString &vFolder) const 323 { 324 const QLatin1Char slash('/'); 325 if (nameSpace.contains(slash) || vFolder.contains(slash)) 326 return false; 327 QUrl url; 328 const QLatin1String scheme("qthelp"); 329 url.setScheme(scheme); 330 const QString canonicalNamespace = nameSpace.toLower(); 331 url.setHost(canonicalNamespace); 332 url.setPath(vFolder); 333 334 const QString expectedUrl(scheme + QLatin1String("://") 335 + canonicalNamespace + slash + vFolder); 336 return url.isValid() && url.toString() == expectedUrl; 337 } 338 308 339 /*! 309 340 \internal … … 347 378 QFile file(fileName); 348 379 if (!file.open(QIODevice::ReadOnly)) { 349 d->errorMsg = Q Object::tr("The input file %1 could not be opened!")350 .arg(fileName);380 d->errorMsg = QCoreApplication::translate("QHelpProject", 381 "The input file %1 could not be opened!").arg(fileName); 351 382 return false; 352 383 } -
trunk/tools/assistant/lib/qhelpprojectdata_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchengine.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 264 264 265 265 After starting the indexing process the signal indexingStarted() is emitted and 266 on the end of the indexing process the indexingFinished() is emit ed. To stop266 on the end of the indexing process the indexingFinished() is emitted. To stop 267 267 the indexing one can call cancelIndexing(). 268 268 … … 270 270 thru its index for a given term. To do this one may use the possibility of creating the 271 271 QHelpSearchQuery list by self or reuse the QHelpSearchQueryWidget which has the inbuild 272 functionality to set up a proper search quer ys list that get's passed to the search engines272 functionality to set up a proper search queries list that get's passed to the search engines 273 273 search() function. 274 274 275 275 After the list of querys has been passed to the search engine, the signal searchingStarted() 276 is emit ed and after the search has finished the searchingFinished() signal is emited. The276 is emitted and after the search has finished the searchingFinished() signal is emitted. The 277 277 search process can be stopped by calling cancelSearching(). 278 278 … … 319 319 The QHelpEngine's setupFinished() signal is automatically connected to the 320 320 QHelpSearchEngine's indexing function, so that new documentation will be indexed 321 after the signal is emit ed.321 after the signal is emitted. 322 322 */ 323 323 QHelpSearchEngine::QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent) … … 435 435 436 436 /*! 437 Starts the search process using the given list of quer ys \a queryList437 Starts the search process using the given list of queries \a queryList 438 438 build by the search field name and the values to search for. 439 439 */ -
trunk/tools/assistant/lib/qhelpsearchengine.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 81 81 82 82 public: 83 QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent = 0); 83 explicit QHelpSearchEngine(QHelpEngineCore *helpEngine, 84 QObject *parent = 0); 84 85 ~QHelpSearchEngine(); 85 86 -
trunk/tools/assistant/lib/qhelpsearchindex_default.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindex_default_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexreader.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include "fulltextsearch/qindexreader_p.h" 43 #include "fulltextsearch/qqueryparser_p.h" 44 #include "fulltextsearch/qsearchable_p.h" 45 #include "qclucenefieldnames_p.h" 42 46 #include "qhelpenginecore.h" 43 #include "fulltextsearch/qsearchable_p.h" 44 #include "fulltextsearch/qqueryparser_p.h" 45 #include "fulltextsearch/qindexreader_p.h" 47 46 48 #include "qhelpsearchindexreader_clucene_p.h" 47 49 … … 50 52 #include <QtCore/QString> 51 53 #include <QtCore/QFileInfo> 54 #include <QtCore/QSharedPointer> 52 55 #include <QtCore/QStringList> 53 56 #include <QtCore/QTextStream> … … 108 111 try { 109 112 #endif 110 QCLuceneBooleanQuery booleanQuery; 113 QCLuceneBooleanQuery booleanQueryTitle; 114 QCLuceneBooleanQuery booleanQueryContent; 111 115 QCLuceneStandardAnalyzer analyzer; 112 if (!buildQuery(booleanQuery, queryList, analyzer)) { 116 const QStringList& attribList = 117 engine.filterAttributes(engine.currentFilter()); 118 bool titleQueryIsValid = buildQuery(queryList, TitleTokenizedField, 119 attribList, booleanQueryTitle, analyzer); 120 bool contentQueryIsValid = buildQuery(queryList, ContentField, 121 attribList, booleanQueryContent, analyzer); 122 if (!titleQueryIsValid && !contentQueryIsValid) { 113 123 emit searchingFinished(0); 114 124 return; 115 125 } 116 126 117 const QStringList attribList = engine.filterAttributes(engine.currentFilter()); 118 if (!attribList.isEmpty()) { 119 QCLuceneQuery* query = QCLuceneQueryParser::parse(QLatin1String("+") 120 + attribList.join(QLatin1String(" +")), QLatin1String("attribute"), analyzer); 121 122 if (!query) { 127 QCLuceneIndexSearcher indexSearcher(indexPath); 128 129 // QCLuceneHits object must be allocated on the heap, because 130 // there is no default constructor. 131 QSharedPointer<QCLuceneHits> titleHits; 132 QSharedPointer<QCLuceneHits> contentHits; 133 if (titleQueryIsValid) { 134 titleHits = QSharedPointer<QCLuceneHits>(new QCLuceneHits( 135 indexSearcher.search(booleanQueryTitle))); 136 } 137 if (contentQueryIsValid) { 138 contentHits = QSharedPointer<QCLuceneHits>(new QCLuceneHits( 139 indexSearcher.search(booleanQueryContent))); 140 } 141 bool boost = true; 142 if ((titleHits.isNull() || titleHits->length() == 0) 143 && (contentHits.isNull() || contentHits->length() == 0)) { 144 booleanQueryTitle = QCLuceneBooleanQuery(); 145 booleanQueryContent = QCLuceneBooleanQuery(); 146 titleQueryIsValid = 147 buildTryHarderQuery(queryList, TitleTokenizedField, 148 attribList, booleanQueryTitle, analyzer); 149 contentQueryIsValid = 150 buildTryHarderQuery(queryList, ContentField, attribList, 151 booleanQueryContent, analyzer); 152 if (!titleQueryIsValid && !contentQueryIsValid) { 123 153 emit searchingFinished(0); 124 154 return; 125 155 } 126 booleanQuery.add(query, true, true, false); 127 } 128 129 QCLuceneIndexSearcher indexSearcher(indexPath); 130 QCLuceneHits hits = indexSearcher.search(booleanQuery); 131 132 bool boost = true; 133 QCLuceneBooleanQuery tryHarderQuery; 134 if (hits.length() == 0) { 135 if (buildTryHarderQuery(tryHarderQuery, queryList, analyzer)) { 136 if (!attribList.isEmpty()) { 137 QCLuceneQuery* query = QCLuceneQueryParser::parse(QLatin1String("+") 138 + attribList.join(QLatin1String(" +")), QLatin1String("attribute"), 139 analyzer); 140 tryHarderQuery.add(query, true, true, false); 141 } 142 hits = indexSearcher.search(tryHarderQuery); 143 boost = (hits.length() == 0); 156 if (titleQueryIsValid) { 157 titleHits = QSharedPointer<QCLuceneHits>(new QCLuceneHits( 158 indexSearcher.search(booleanQueryTitle))); 144 159 } 145 } 160 if (contentQueryIsValid) { 161 contentHits = QSharedPointer<QCLuceneHits>(new QCLuceneHits( 162 indexSearcher.search(booleanQueryContent))); 163 } 164 boost = false; 165 } 166 QList<QSharedPointer<QCLuceneHits> > cluceneHitsList; 167 if (!titleHits.isNull()) 168 cluceneHitsList.append(titleHits); 169 if (!contentHits.isNull()) 170 cluceneHitsList.append(contentHits); 146 171 147 172 QSet<QString> pathSet; … … 149 174 const QStringList namespaceList = engine.registeredDocumentations(); 150 175 151 for (qint32 i = 0; i < hits.length(); i++) { 152 document = hits.document(i); 153 const QString path = document.get(QLatin1String("path")); 154 if (!pathSet.contains(path) && namespaceList.contains( 155 document.get(QLatin1String("namespace")), Qt::CaseInsensitive)) { 156 pathSet.insert(path); 157 hitList.append(qMakePair(path, document.get(QLatin1String("title")))); 176 foreach (const QSharedPointer<QCLuceneHits> &hits, cluceneHitsList) { 177 for (qint32 i = 0; i < hits->length(); i++) { 178 document = hits->document(i); 179 const QString path = document.get(PathField); 180 if (!pathSet.contains(path) && namespaceList.contains( 181 document.get(NamespaceField), Qt::CaseInsensitive)) { 182 pathSet.insert(path); 183 hitList.append(qMakePair(path, document.get(TitleField))); 184 } 185 document.clear(); 186 187 mutex.lock(); 188 if (m_cancel) { 189 mutex.unlock(); 190 emit searchingFinished(0); 191 return; 192 } 193 mutex.unlock(); 158 194 } 159 document.clear();160 161 mutex.lock();162 if (m_cancel) {163 mutex.unlock();164 emit searchingFinished(0);165 return;166 }167 mutex.unlock();168 195 } 169 196 … … 185 212 } 186 213 187 bool QHelpSearchIndexReaderClucene::defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery, 188 QCLuceneStandardAnalyzer &analyzer) 189 { 190 const QLatin1String c("content"); 191 const QLatin1String t("titleTokenized"); 192 193 QCLuceneQuery *query = QCLuceneQueryParser::parse(term, c, analyzer); 194 QCLuceneQuery *query2 = QCLuceneQueryParser::parse(term, t, analyzer); 195 if (query && query2) { 196 booleanQuery.add(query, true, false, false); 197 booleanQuery.add(query2, true, false, false); 214 bool QHelpSearchIndexReaderClucene::buildQuery( 215 const QList<QHelpSearchQuery> &queries, const QString &fieldName, 216 const QStringList &filterAttributes, QCLuceneBooleanQuery &booleanQuery, 217 QCLuceneAnalyzer &analyzer) 218 { 219 bool queryIsValid = false; 220 foreach (const QHelpSearchQuery &query, queries) { 221 if (fieldName != ContentField && isNegativeQuery(query)) { 222 queryIsValid = false; 223 break; 224 } 225 switch (query.fieldName) { 226 case QHelpSearchQuery::FUZZY: 227 if (addFuzzyQuery(query, fieldName, booleanQuery, analyzer)) 228 queryIsValid = true; 229 break; 230 case QHelpSearchQuery::WITHOUT: 231 if (fieldName != ContentField) 232 return false; 233 if (addWithoutQuery(query, fieldName, booleanQuery)) 234 queryIsValid = true; 235 break; 236 case QHelpSearchQuery::PHRASE: 237 if (addPhraseQuery(query, fieldName, booleanQuery)) 238 queryIsValid = true; 239 break; 240 case QHelpSearchQuery::ALL: 241 if (addAllQuery(query, fieldName, booleanQuery)) 242 queryIsValid = true; 243 break; 244 case QHelpSearchQuery::DEFAULT: 245 if (addDefaultQuery(query, fieldName, true, booleanQuery, analyzer)) 246 queryIsValid = true; 247 break; 248 case QHelpSearchQuery::ATLEAST: 249 if (addAtLeastQuery(query, fieldName, booleanQuery, analyzer)) 250 queryIsValid = true; 251 break; 252 default: 253 Q_ASSERT(!"Invalid field name"); 254 } 255 } 256 257 if (queryIsValid && !filterAttributes.isEmpty()) { 258 queryIsValid = 259 addAttributesQuery(filterAttributes, booleanQuery, analyzer); 260 } 261 262 return queryIsValid; 263 } 264 265 bool QHelpSearchIndexReaderClucene::buildTryHarderQuery( 266 const QList<QHelpSearchQuery> &queries, const QString &fieldName, 267 const QStringList &filterAttributes, QCLuceneBooleanQuery &booleanQuery, 268 QCLuceneAnalyzer &analyzer) 269 { 270 if (queries.isEmpty()) 271 return false; 272 const QHelpSearchQuery &query = queries.front(); 273 if (query.fieldName != QHelpSearchQuery::DEFAULT) 274 return false; 275 if (isNegativeQuery(query)) 276 return false; 277 if (!addDefaultQuery(query, fieldName, false, booleanQuery, analyzer)) 278 return false; 279 if (filterAttributes.isEmpty()) 198 280 return true; 199 } 200 201 return false; 202 } 203 204 bool QHelpSearchIndexReaderClucene::buildQuery(QCLuceneBooleanQuery &booleanQuery, 205 const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer) 206 { 207 foreach (const QHelpSearchQuery query, queryList) { 208 switch (query.fieldName) { 209 case QHelpSearchQuery::FUZZY: { 210 const QLatin1String fuzzy("~"); 211 foreach (const QString &term, query.wordList) { 212 if (term.isEmpty() 213 || !defaultQuery(term.toLower() + fuzzy, booleanQuery, analyzer)) { 214 return false; 215 } 216 } 217 } break; 218 219 case QHelpSearchQuery::WITHOUT: { 220 QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); 221 foreach (const QString &term, query.wordList) { 222 if (stopWords.contains(term, Qt::CaseInsensitive)) 223 continue; 224 225 QCLuceneQuery *query = new QCLuceneTermQuery(QCLuceneTerm( 226 QLatin1String("content"), term.toLower())); 227 QCLuceneQuery *query2 = new QCLuceneTermQuery(QCLuceneTerm( 228 QLatin1String("titleTokenized"), term.toLower())); 229 230 if (query && query2) { 231 booleanQuery.add(query, true, false, true); 232 booleanQuery.add(query2, true, false, true); 233 } else { 234 return false; 235 } 236 } 237 } break; 238 239 case QHelpSearchQuery::PHRASE: { 240 const QString &term = query.wordList.at(0).toLower(); 241 if (term.contains(QLatin1Char(' '))) { 242 QStringList termList = term.split(QLatin1String(" ")); 243 QCLucenePhraseQuery *q = new QCLucenePhraseQuery(); 244 QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); 245 foreach (const QString &term, termList) { 246 if (!stopWords.contains(term, Qt::CaseInsensitive)) 247 q->addTerm(QCLuceneTerm(QLatin1String("content"), term.toLower())); 248 } 249 booleanQuery.add(q, true, true, false); 250 } else { 251 QCLuceneQuery *query = new QCLuceneTermQuery(QCLuceneTerm( 252 QLatin1String("content"), term.toLower())); 253 QCLuceneQuery *query2 = new QCLuceneTermQuery(QCLuceneTerm( 254 QLatin1String("titleTokenized"), term.toLower())); 255 256 if (query && query2) { 257 booleanQuery.add(query, true, true, false); 258 booleanQuery.add(query2, true, false, false); 259 } else { 260 return false; 261 } 262 } 263 } break; 264 265 case QHelpSearchQuery::ALL: { 266 QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); 267 foreach (const QString &term, query.wordList) { 268 if (stopWords.contains(term, Qt::CaseInsensitive)) 269 continue; 270 271 QCLuceneQuery *query = new QCLuceneTermQuery(QCLuceneTerm( 272 QLatin1String("content"), term.toLower())); 273 274 if (query) { 275 booleanQuery.add(query, true, true, false); 276 } else { 277 return false; 278 } 279 } 280 } break; 281 282 case QHelpSearchQuery::DEFAULT: { 283 foreach (const QString &term, query.wordList) { 284 QCLuceneQuery *query = QCLuceneQueryParser::parse(term.toLower(), 285 QLatin1String("content"), analyzer); 286 287 if (query) 288 booleanQuery.add(query, true, true, false); 289 } 290 } break; 291 292 case QHelpSearchQuery::ATLEAST: { 293 foreach (const QString &term, query.wordList) { 294 if (term.isEmpty() || !defaultQuery(term.toLower(), booleanQuery, analyzer)) 295 return false; 296 } 297 } 298 } 299 } 300 281 return addAttributesQuery(filterAttributes, booleanQuery, analyzer); 282 } 283 284 bool QHelpSearchIndexReaderClucene::isNegativeQuery(const QHelpSearchQuery &query) const 285 { 286 const QString &search = query.wordList.join(" "); 287 return search.contains('!') || search.contains('-') 288 || search.contains(QLatin1String(" NOT ")); 289 } 290 291 bool QHelpSearchIndexReaderClucene::addFuzzyQuery(const QHelpSearchQuery &query, 292 const QString &fieldName, QCLuceneBooleanQuery &booleanQuery, 293 QCLuceneAnalyzer &analyzer) 294 { 295 bool queryIsValid = false; 296 const QLatin1String fuzzy("~"); 297 foreach (const QString &term, query.wordList) { 298 if (!term.isEmpty()) { 299 QCLuceneQuery *lQuery = 300 QCLuceneQueryParser::parse(term + fuzzy, fieldName, analyzer); 301 if (lQuery != 0) { 302 booleanQuery.add(lQuery, true, false, false); 303 queryIsValid = true; 304 } 305 } 306 } 307 return queryIsValid; 308 } 309 310 bool QHelpSearchIndexReaderClucene::addWithoutQuery(const QHelpSearchQuery &query, 311 const QString &fieldName, QCLuceneBooleanQuery &booleanQuery) 312 { 313 bool queryIsValid = false; 314 const QStringList &stopWords = QCLuceneStopAnalyzer().englishStopWords(); 315 foreach (const QString &term, query.wordList) { 316 if (stopWords.contains(term, Qt::CaseInsensitive)) 317 continue; 318 QCLuceneQuery *lQuery = new QCLuceneTermQuery(QCLuceneTerm( 319 fieldName, term.toLower())); 320 booleanQuery.add(lQuery, true, false, true); 321 queryIsValid = true; 322 } 323 return queryIsValid; 324 } 325 326 bool QHelpSearchIndexReaderClucene::addPhraseQuery(const QHelpSearchQuery &query, 327 const QString &fieldName, QCLuceneBooleanQuery &booleanQuery) 328 { 329 bool queryIsValid = false; 330 const QString &term = query.wordList.at(0).toLower(); 331 if (term.contains(QLatin1Char(' '))) { 332 const QStringList termList = term.split(QLatin1String(" ")); 333 QCLucenePhraseQuery *q = new QCLucenePhraseQuery(); 334 const QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); 335 foreach (const QString &term, termList) { 336 if (!stopWords.contains(term, Qt::CaseInsensitive)) 337 q->addTerm(QCLuceneTerm(fieldName, term.toLower())); 338 } 339 if (!q->getTerms().isEmpty()) { 340 booleanQuery.add(q, true, true, false); 341 queryIsValid = true; 342 } 343 } else { 344 QCLuceneQuery *lQuery = new QCLuceneTermQuery(QCLuceneTerm( 345 fieldName, term.toLower())); 346 booleanQuery.add(lQuery, true, true, false); 347 queryIsValid = true; 348 } 349 return queryIsValid; 350 } 351 352 bool QHelpSearchIndexReaderClucene::addAllQuery(const QHelpSearchQuery &query, 353 const QString &fieldName, QCLuceneBooleanQuery &booleanQuery) 354 { 355 bool queryIsValid = false; 356 const QStringList &stopWords = QCLuceneStopAnalyzer().englishStopWords(); 357 foreach (const QString &term, query.wordList) { 358 if (stopWords.contains(term, Qt::CaseInsensitive)) 359 continue; 360 QCLuceneQuery *lQuery = new QCLuceneTermQuery(QCLuceneTerm( 361 fieldName, term.toLower())); 362 booleanQuery.add(lQuery, true, true, false); 363 queryIsValid = true; 364 } 365 return queryIsValid; 366 } 367 368 bool QHelpSearchIndexReaderClucene::addDefaultQuery(const QHelpSearchQuery &query, 369 const QString &fieldName, bool allTermsRequired, 370 QCLuceneBooleanQuery &booleanQuery, 371 QCLuceneAnalyzer &analyzer) 372 { 373 bool queryIsValid = false; 374 foreach (const QString &term, query.wordList) { 375 QCLuceneQuery *lQuery = 376 QCLuceneQueryParser::parse(term.toLower(), fieldName, analyzer); 377 if (lQuery) { 378 booleanQuery.add(lQuery, true, allTermsRequired, false); 379 queryIsValid = true; 380 } 381 } 382 return queryIsValid; 383 } 384 385 bool QHelpSearchIndexReaderClucene::addAtLeastQuery( 386 const QHelpSearchQuery &query, const QString &fieldName, 387 QCLuceneBooleanQuery &booleanQuery, QCLuceneAnalyzer &analyzer) 388 { 389 bool queryIsValid = false; 390 foreach (const QString &term, query.wordList) { 391 if (!term.isEmpty()) { 392 QCLuceneQuery *lQuery = 393 QCLuceneQueryParser::parse(term, fieldName, analyzer); 394 if (lQuery) { 395 booleanQuery.add(lQuery, true, false, false); 396 queryIsValid = true; 397 } 398 } 399 } 400 return queryIsValid; 401 } 402 403 bool QHelpSearchIndexReaderClucene::addAttributesQuery( 404 const QStringList &filterAttributes, QCLuceneBooleanQuery &booleanQuery, 405 QCLuceneAnalyzer &analyzer) 406 { 407 QCLuceneQuery* lQuery = QCLuceneQueryParser::parse(QLatin1String("+") 408 + filterAttributes.join(QLatin1String(" +")), AttributeField, analyzer); 409 if (!lQuery) 410 return false; 411 booleanQuery.add(lQuery, true, true, false); 301 412 return true; 302 }303 304 bool QHelpSearchIndexReaderClucene::buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery,305 const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer)306 {307 bool retVal = false;308 foreach (const QHelpSearchQuery query, queryList) {309 switch (query.fieldName) {310 default: break;311 case QHelpSearchQuery::DEFAULT: {312 foreach (const QString &term, query.wordList) {313 QCLuceneQuery *query = QCLuceneQueryParser::parse(term.toLower(),314 QLatin1String("content"), analyzer);315 316 if (query) {317 retVal = true;318 booleanQuery.add(query, true, false, false);319 }320 }321 } break;322 }323 }324 return retVal;325 413 } 326 414 … … 328 416 QList<QHelpSearchEngine::SearchHit> &hitList, const QList<QHelpSearchQuery> &queryList) 329 417 { 330 foreach (const QHelpSearchQuery query, queryList) {418 foreach (const QHelpSearchQuery &query, queryList) { 331 419 if (query.fieldName != QHelpSearchQuery::DEFAULT) 332 420 continue; … … 336 424 QCLuceneStandardAnalyzer analyzer; 337 425 QCLuceneQuery *parsedQuery = QCLuceneQueryParser::parse( 338 joinedQuery, QLatin1String("content"), analyzer);426 joinedQuery, ContentField, analyzer); 339 427 340 428 if (parsedQuery) { … … 343 431 } 344 432 345 int length = QString(QLatin1String("content:")).length(); 346 int index = joinedQuery.indexOf(QLatin1String("content:")); 433 const QString contentString(ContentField + QLatin1String(":")); 434 int length = contentString.length(); 435 int index = joinedQuery.indexOf(contentString); 347 436 348 437 QString term; … … 350 439 QStringList searchTerms; 351 440 while (index != -1) { 352 nextIndex = joinedQuery.indexOf( QLatin1String("content:"), index + 1);441 nextIndex = joinedQuery.indexOf(contentString, index + 1); 353 442 term = joinedQuery.mid(index + length, nextIndex - (length + index)).simplified(); 354 443 if (term.startsWith(QLatin1String("\"")) -
trunk/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 54 54 // 55 55 56 #include "qhelpsearchindexreader_p.h" 56 #include <QtCore/QList> 57 #include <QtCore/QString> 58 #include <QtCore/QStringList> 57 59 58 60 #include "fulltextsearch/qanalyzer_p.h" 59 61 #include "fulltextsearch/qquery_p.h" 62 #include "qhelpsearchindexreader_p.h" 60 63 61 64 QT_BEGIN_NAMESPACE … … 74 77 private: 75 78 void run(); 76 bool defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery,77 QCLuceneStandardAnalyzer &analyzer);78 bool buildQuery(QCLuceneBooleanQuery &booleanQuery, const QList<QHelpSearchQuery> &queryList,79 QCLuceneStandardAnalyzer &analyzer);80 bool buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery,81 const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer);82 79 void boostSearchHits(const QHelpEngineCore &engine, QList<QHelpSearchEngine::SearchHit> &hitList, 83 80 const QList<QHelpSearchQuery> &queryList); 81 bool buildQuery(const QList<QHelpSearchQuery> &queries, 82 const QString &fieldName, 83 const QStringList &filterAttributes, 84 QCLuceneBooleanQuery &booleanQuery, 85 QCLuceneAnalyzer &analyzer); 86 bool buildTryHarderQuery(const QList<QHelpSearchQuery> &queries, 87 const QString &fieldName, 88 const QStringList &filterAttributes, 89 QCLuceneBooleanQuery &booleanQuery, 90 QCLuceneAnalyzer &analyzer); 91 bool addFuzzyQuery(const QHelpSearchQuery &query, const QString &fieldName, 92 QCLuceneBooleanQuery &booleanQuery, QCLuceneAnalyzer &analyzer); 93 bool addWithoutQuery(const QHelpSearchQuery &query, const QString &fieldName, 94 QCLuceneBooleanQuery &booleanQuery); 95 bool addPhraseQuery(const QHelpSearchQuery &query, const QString &fieldName, 96 QCLuceneBooleanQuery &booleanQuery); 97 bool addAllQuery(const QHelpSearchQuery &query, const QString &fieldName, 98 QCLuceneBooleanQuery &booleanQuery); 99 bool addDefaultQuery(const QHelpSearchQuery &query, const QString &fieldName, 100 bool allTermsRequired, QCLuceneBooleanQuery &booleanQuery, 101 QCLuceneAnalyzer &analyzer); 102 bool addAtLeastQuery(const QHelpSearchQuery &query, const QString &fieldName, 103 QCLuceneBooleanQuery &booleanQuery, QCLuceneAnalyzer &analyzer); 104 bool addAttributesQuery(const QStringList &filterAttributes, 105 QCLuceneBooleanQuery &booleanQuery, QCLuceneAnalyzer &analyzer); 106 bool isNegativeQuery(const QHelpSearchQuery &query) const; 84 107 }; 85 108 -
trunk/tools/assistant/lib/qhelpsearchindexreader_default.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexreader_default_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 61 61 62 62 QT_BEGIN_NAMESPACE 63 64 struct Entry;65 struct PosEntry;66 63 67 64 namespace fulltextsearch { -
trunk/tools/assistant/lib/qhelpsearchindexreader_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include "qclucenefieldnames_p.h" 42 43 #include "qhelpenginecore.h" 43 44 #include "qhelp_global.h" … … 407 408 408 409 if(!parsedData.isEmpty()) { 409 document->add(new QCLuceneField( QLatin1String("content"),410 document->add(new QCLuceneField(ContentField, 410 411 parsedData,QCLuceneField::INDEX_TOKENIZED)); 411 document->add(new QCLuceneField( QLatin1String("path"), fileName,412 document->add(new QCLuceneField(PathField, fileName, 412 413 QCLuceneField::STORE_YES | QCLuceneField::INDEX_UNTOKENIZED)); 413 document->add(new QCLuceneField( QLatin1String("title"), parsedTitle,414 document->add(new QCLuceneField(TitleField, parsedTitle, 414 415 QCLuceneField::STORE_YES | QCLuceneField::INDEX_UNTOKENIZED)); 415 document->add(new QCLuceneField( QLatin1String("titleTokenized"), parsedTitle,416 document->add(new QCLuceneField(TitleTokenizedField, parsedTitle, 416 417 QCLuceneField::STORE_YES | QCLuceneField::INDEX_TOKENIZED)); 417 document->add(new QCLuceneField( QLatin1String("namespace"), namespaceName,418 document->add(new QCLuceneField(NamespaceField, namespaceName, 418 419 QCLuceneField::STORE_YES | QCLuceneField::INDEX_UNTOKENIZED)); 419 document->add(new QCLuceneField( QLatin1String("attribute"), attributes,420 document->add(new QCLuceneField(AttributeField, attributes, 420 421 QCLuceneField::STORE_YES | QCLuceneField::INDEX_TOKENIZED)); 421 422 return true; … … 716 717 if (indexMap.contains(namespaceName)) { 717 718 // make sure we really have content indexed for namespace 718 // NOTE: Extra variable just for GCC 3.3.5 719 QLatin1String key("namespace"); 720 QCLuceneTermQuery query(QCLuceneTerm(key, namespaceName)); 719 QCLuceneTermQuery query(QCLuceneTerm(NamespaceField, namespaceName)); 721 720 QCLuceneIndexSearcher indexSearcher(indexPath); 722 721 QCLuceneHits hits = indexSearcher.search(query); … … 852 851 853 852 QCLuceneIndexReader reader = QCLuceneIndexReader::open(indexPath); 854 reader.deleteDocuments(QCLuceneTerm(QLatin1String("namespace"), 855 namespaceName)); 853 reader.deleteDocuments(QCLuceneTerm(NamespaceField, namespaceName)); 856 854 857 855 reader.close(); -
trunk/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexwriter_default.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchindexwriter_default_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchquerywidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "qhelpsearchquerywidget.h" 43 43 44 #include <QtCore/QDebug>45 46 44 #include <QtCore/QAbstractListModel> 47 45 #include <QtCore/QObject> … … 102 100 103 101 QHelpSearchQueryWidgetPrivate() 104 : QObject(), simpleSearch(true), 105 searchCompleter(new CompleterModel(this), this) 102 : QObject() 103 , simpleSearch(true) 104 , searchCompleter(new CompleterModel(this), this) 106 105 { 107 106 searchButton = 0; … … 135 134 atLeastLabel->setText(QHelpSearchQueryWidget::tr("with <B>at least one</B> of the words:")); 136 135 #endif 137 }138 139 QString escapeString(const QString &text)140 {141 QString retValue = text;142 const QString escape(QLatin1String("\\"));143 QStringList escapableCharsList;144 escapableCharsList << QLatin1String("\\") << QLatin1String("+")145 << QLatin1String("-") << QLatin1String("!") << QLatin1String("(")146 << QLatin1String(")") << QLatin1String(":") << QLatin1String("^")147 << QLatin1String("[") << QLatin1String("]") << QLatin1String("{")148 << QLatin1String("}") << QLatin1String("~");149 150 // make sure we won't end up with an empty string151 foreach (const QString &escapeChar, escapableCharsList) {152 if (retValue.contains(escapeChar))153 retValue.replace(escapeChar, QLatin1String(""));154 }155 if (retValue.trimmed().isEmpty())156 return retValue;157 158 retValue = text; // now really escape the string...159 foreach (const QString &escapeChar, escapableCharsList) {160 if (retValue.contains(escapeChar))161 retValue.replace(escapeChar, escape + escapeChar);162 }163 return retValue;164 136 } 165 137 … … 223 195 } 224 196 225 void nextOrPrevQuery(int maxOrMinIndex, int addend, 226 QToolButton *thisButton,QToolButton *otherButton)197 void nextOrPrevQuery(int maxOrMinIndex, int addend, QToolButton *thisButton, 198 QToolButton *otherButton) 227 199 { 228 200 QueryHistory *queryHist; … … 234 206 queryHist = &complexQueries; 235 207 lineEdits << allQuery << atLeastQuery << similarQuery 236 208 << withoutQuery << exactQuery; 237 209 } 238 210 foreach (QLineEdit *lineEdit, lineEdits) … … 279 251 void enableOrDisableToolButtons() 280 252 { 281 const QueryHistory &queryHist = 282 simpleSearch ? simpleQueries: complexQueries;253 const QueryHistory &queryHist = simpleSearch ? simpleQueries 254 : complexQueries; 283 255 prevQueryButton->setEnabled(queryHist.curQuery > 0); 284 nextQueryButton->setEnabled(queryHist.curQuery <285 256 nextQueryButton->setEnabled(queryHist.curQuery 257 < queryHist.queries.size() - 1); 286 258 } 287 259 … … 307 279 #if !defined(QT_CLUCENE_SUPPORT) 308 280 queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, 309 281 QStringList(defaultQuery->text()))); 310 282 311 283 #else 312 284 if (defaultQuery->isEnabled()) { 313 285 queryList.append(QHelpSearchQuery(QHelpSearchQuery::DEFAULT, 314 buildTermList(escapeString(defaultQuery->text()))));286 buildTermList(defaultQuery->text()))); 315 287 } else { 316 288 const QRegExp exp(QLatin1String("\\s+")); 317 QStringList lst = similarQuery->text().split(exp, QString::SkipEmptyParts); 289 QStringList lst = similarQuery->text().split(exp, 290 QString::SkipEmptyParts); 318 291 if (!lst.isEmpty()) { 319 292 QStringList fuzzy; 320 293 foreach (const QString &term, lst) 321 fuzzy += buildTermList(escapeString(term)); 322 queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, fuzzy)); 294 fuzzy += buildTermList(term); 295 queryList.append(QHelpSearchQuery(QHelpSearchQuery::FUZZY, 296 fuzzy)); 323 297 } 324 298 … … 327 301 QStringList without; 328 302 foreach (const QString &term, lst) 329 without.append(escapeString(term)); 330 queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, without)); 303 without.append(term); 304 queryList.append(QHelpSearchQuery(QHelpSearchQuery::WITHOUT, 305 without)); 331 306 } 332 307 333 308 if (!exactQuery->text().isEmpty()) { 334 309 QString phrase = exactQuery->text().remove(QLatin1Char('\"')); 335 phrase = escapeString(phrase.simplified()); 336 queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, QStringList(phrase))); 310 phrase = phrase.simplified(); 311 queryList.append(QHelpSearchQuery(QHelpSearchQuery::PHRASE, 312 QStringList(phrase))); 337 313 } 338 314 … … 341 317 QStringList all; 342 318 foreach (const QString &term, lst) 343 all.append( escapeString(term));319 all.append(term); 344 320 queryList.append(QHelpSearchQuery(QHelpSearchQuery::ALL, all)); 345 321 } … … 349 325 QStringList atLeast; 350 326 foreach (const QString &term, lst) 351 atLeast += buildTermList(escapeString(term)); 352 queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, atLeast)); 327 atLeast += buildTermList(term); 328 queryList.append(QHelpSearchQuery(QHelpSearchQuery::ATLEAST, 329 atLeast)); 353 330 } 354 331 } … … 364 341 void nextQuery() 365 342 { 366 nextOrPrevQuery((simpleSearch ? simpleQueries : complexQueries).queries.size() - 1, 367 1, nextQueryButton, prevQueryButton); 343 nextOrPrevQuery((simpleSearch ? simpleQueries 344 : complexQueries).queries.size() - 1, 1, nextQueryButton, 345 prevQueryButton); 368 346 } 369 347 … … 416 394 417 395 This signal is emitted when a the user has the search button invoked. 418 After reciving the signal you can ask the QHelpSearchQueryWidget for the build list 419 of QHelpSearchQuery's that you may pass to the QHelpSearchEngine's search() function. 396 After reciving the signal you can ask the QHelpSearchQueryWidget for the 397 build list of QHelpSearchQuery's that you may pass to the QHelpSearchEngine's 398 search() function. 420 399 */ 421 400 … … 545 524 } 546 525 547 /*! \reimp 526 /*! 527 \reimp 548 528 */ 549 529 void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent) -
trunk/tools/assistant/lib/qhelpsearchquerywidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/tools/assistant/lib/qhelpsearchresultwidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 305 305 } 306 306 } 307 hitsLabel->setText( tr("%1 - %2 of %3 Hits").arg(first).arg(last).arg(count));307 hitsLabel->setText(QHelpSearchResultWidget::tr("%1 - %2 of %n Hits", 0, count).arg(first).arg(last)); 308 308 } 309 309 -
trunk/tools/assistant/lib/qhelpsearchresultwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.