37 resultsBox->setPlainText("Search button clicked!"); |
37 resultsBox->setPlainText("Search button clicked!"); |
38 |
38 |
39 int hits = 0; |
39 int hits = 0; |
40 QString resultString(""); |
40 QString resultString(""); |
41 resultsBox->setPlainText( resultString ); |
41 resultsBox->setPlainText( resultString ); |
|
42 searchTime.restart(); |
|
43 QString searchString = searchBox->text(); |
|
44 |
|
45 #if STAR_SEARCH |
|
46 searchString += "*"; |
|
47 #elif NO_STAR_SEARCH |
|
48 ;//do nothing |
|
49 #elif ESCAPE_SPECIAL_CHARS |
|
50 //C-style array query - so that we dont have to hard code the length. |
|
51 //Escape '\' first so that it does not re-escape all the other escapes. |
|
52 QString escapeTheseCharacters [] = {"\\", "+", "-", "&&", "||", "!", |
|
53 "(", ")", "{", "}", "[", "]", "^", |
|
54 "~", "*", "?", ":", "\0"}; |
|
55 for( int i=0; escapeTheseCharacters[i] != "\0"; i++ ){ |
|
56 QString escapedCharacter = "\\" + escapeTheseCharacters[i]; |
|
57 searchString.replace( escapeTheseCharacters[i], escapedCharacter ); |
|
58 } |
|
59 #endif |
42 |
60 |
43 searchTime.restart(); |
61 hits = searcher->search( searchString ); |
44 hits = searcher->search( searchBox->text() + "*" ); |
62 |
45 resultString = "SearchTime: " + QString().setNum( searchTime.elapsed() ) + " ms \r\n"; |
63 resultString = "SearchTime: " + QString().setNum( searchTime.elapsed() ) + " ms \r\n"; |
46 resultString += "Hits: " + QString().setNum( hits ) + "\r\n"; |
64 resultString += "Hits: " + QString().setNum( hits ) + "\r\n"; |
47 resultsBox->setPlainText( resultString ); |
65 resultsBox->setPlainText( resultString ); |
48 |
66 |
|
67 #if !DONT_SHOW_RESULTS |
49 if( hits > 0 ) |
68 if( hits > 0 ) |
50 { |
69 { |
51 QCPixDocument* temp = QCPixDocument::newInstance(); |
70 QCPixDocument* temp = NULL; |
52 int docCount = 0; |
71 int docCount = 0; |
53 do{ |
72 do{ |
54 temp = searcher->getDocument( docCount++ ); |
73 temp = searcher->getDocument( docCount++ ); |
55 resultString += temp->baseAppClass() + " " + temp->docId() + " " + temp->excerpt() + "\r\n\r\n"; |
74 resultString += temp->baseAppClass() + " " + temp->docId() + " " + temp->excerpt() + "\r\n\r\n"; |
|
75 delete temp; |
56 }while( hits > docCount ); |
76 }while( hits > docCount ); |
57 } |
77 } |
58 resultsBox->setPlainText( resultString ); |
78 resultsBox->setPlainText( resultString ); |
|
79 #endif //DONT_SHOW_RESULTS |
59 } |
80 } |