Changeset 846 for trunk/tools/assistant/lib/qhelpsearchquerywidget.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
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/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)
Note:
See TracChangeset
for help on using the changeset viewer.