Changeset View
Changeset View
Standalone View
Standalone View
krusader/Search/krsearchdialog.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 157 | connect(searchTextToClipboard, &QCheckBox::stateChanged, this, [=](int state) { | |||
---|---|---|---|---|---|
158 | KConfigGroup group(krConfig, "Search"); | 158 | KConfigGroup group(krConfig, "Search"); | ||
159 | group.writeEntry("QueryToClipboard", state); | 159 | group.writeEntry("QueryToClipboard", state); | ||
160 | }); | 160 | }); | ||
161 | buttonsLayout->addWidget(searchTextToClipboard); | 161 | buttonsLayout->addWidget(searchTextToClipboard); | ||
162 | 162 | | |||
163 | QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); | 163 | QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); | ||
164 | buttonsLayout->addItem(spacer); | 164 | buttonsLayout->addItem(spacer); | ||
165 | 165 | | |||
166 | mainFeedToListBoxBtn = new QPushButton(this); | | |||
167 | mainFeedToListBoxBtn->setText(i18n("Feed to listbox")); | | |||
168 | mainFeedToListBoxBtn->setIcon(Icon("list-add")); | | |||
169 | mainFeedToListBoxBtn->setEnabled(false); | | |||
170 | buttonsLayout->addWidget(mainFeedToListBoxBtn); | | |||
171 | | ||||
172 | mainSearchBtn = new QPushButton(this); | 166 | mainSearchBtn = new QPushButton(this); | ||
173 | mainSearchBtn->setText(i18n("Search")); | 167 | mainSearchBtn->setText(i18n("Search")); | ||
174 | mainSearchBtn->setIcon(Icon("edit-find")); | 168 | mainSearchBtn->setIcon(Icon("edit-find")); | ||
175 | mainSearchBtn->setDefault(true); | 169 | mainSearchBtn->setDefault(true); | ||
176 | buttonsLayout->addWidget(mainSearchBtn); | 170 | buttonsLayout->addWidget(mainSearchBtn); | ||
177 | 171 | | |||
178 | mainStopBtn = new QPushButton(this); | 172 | mainStopBtn = new QPushButton(this); | ||
179 | mainStopBtn->setEnabled(false); | 173 | mainStopBtn->setEnabled(false); | ||
Show All 17 Lines | |||||
197 | 191 | | |||
198 | QWidget* resultTab = new QWidget(searcherTabs); | 192 | QWidget* resultTab = new QWidget(searcherTabs); | ||
199 | QGridLayout* resultLayout = new QGridLayout(resultTab); | 193 | QGridLayout* resultLayout = new QGridLayout(resultTab); | ||
200 | resultLayout->setSpacing(6); | 194 | resultLayout->setSpacing(6); | ||
201 | resultLayout->setContentsMargins(6, 6, 6, 6); | 195 | resultLayout->setContentsMargins(6, 6, 6, 6); | ||
202 | 196 | | |||
203 | // creating the result tab | 197 | // creating the result tab | ||
204 | 198 | | |||
205 | QHBoxLayout* resultLabelLayout = new QHBoxLayout(); | | |||
206 | resultLabelLayout->setSpacing(6); | | |||
207 | resultLabelLayout->setContentsMargins(0, 0, 0, 0); | | |||
208 | | ||||
209 | foundLabel = new QLabel(resultTab); | | |||
210 | QSizePolicy foundpolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | | |||
211 | foundpolicy.setHeightForWidth(foundLabel->sizePolicy().hasHeightForWidth()); | | |||
212 | foundLabel->setSizePolicy(foundpolicy); | | |||
213 | foundLabel->setFrameShape(QLabel::StyledPanel); | | |||
214 | foundLabel->setFrameShadow(QLabel::Sunken); | | |||
215 | foundLabel->setText(i18n("Found 0 matches.")); | | |||
216 | resultLabelLayout->addWidget(foundLabel); | | |||
217 | | ||||
218 | searchingLabel = new KSqueezedTextLabel(resultTab); | | |||
219 | searchingLabel->setFrameShape(QLabel::StyledPanel); | | |||
220 | searchingLabel->setFrameShadow(QLabel::Sunken); | | |||
221 | searchingLabel->setText(""); | | |||
222 | resultLabelLayout->addWidget(searchingLabel); | | |||
223 | | ||||
224 | resultLayout->addLayout(resultLabelLayout, 2, 0); | | |||
225 | | ||||
226 | // creating the result list view | 199 | // creating the result list view | ||
227 | result = new SearchResultContainer(this); | 200 | result = new SearchResultContainer(this); | ||
228 | // the view | 201 | // the view | ||
229 | resultView = KrViewFactory::createView(RESULTVIEW_TYPE, resultTab, krConfig); | 202 | resultView = KrViewFactory::createView(RESULTVIEW_TYPE, resultTab, krConfig); | ||
230 | resultView->init(false); | 203 | resultView->init(false); | ||
231 | resultView->restoreSettings(KConfigGroup(&group, "ResultView")); | 204 | resultView->restoreSettings(KConfigGroup(&group, "ResultView")); | ||
232 | resultView->setMainWindow(this); | 205 | resultView->setMainWindow(this); | ||
233 | resultView->prepareForActive(); | 206 | resultView->prepareForActive(); | ||
234 | resultView->refreshColors(); | 207 | resultView->refreshColors(); | ||
235 | resultView->setFiles(result); | 208 | resultView->setFiles(result); | ||
236 | resultView->refresh(); | 209 | resultView->refresh(); | ||
237 | resultLayout->addWidget(resultView->widget(), 0, 0); | 210 | resultLayout->addWidget(resultView->widget(), 0, 0); | ||
238 | // search bar | 211 | // search bar - hidden by default | ||
239 | searchBar = new KrSearchBar(resultView, this); | 212 | searchBar = new KrSearchBar(resultView, this); | ||
240 | searchBar->hide(); | 213 | searchBar->hide(); | ||
241 | resultLayout->addWidget(searchBar, 1, 0); | 214 | resultLayout->addWidget(searchBar, 1, 0); | ||
242 | 215 | | |||
216 | // text found row | ||||
217 | foundTextFrame = new QFrame(resultTab); | ||||
218 | foundTextFrame->setFrameShape(QLabel::StyledPanel); | ||||
219 | foundTextFrame->setFrameShadow(QLabel::Sunken); | ||||
220 | | ||||
243 | QHBoxLayout* foundTextLayout = new QHBoxLayout(); | 221 | QHBoxLayout* foundTextLayout = new QHBoxLayout(); | ||
244 | foundTextLayout->setSpacing(6); | 222 | foundTextLayout->setSpacing(6); | ||
245 | foundTextLayout->setContentsMargins(0, 0, 0, 0); | | |||
246 | | ||||
247 | QLabel *l1 = new QLabel(resultTab); | | |||
248 | QSizePolicy l1policy(QSizePolicy::Minimum, QSizePolicy::Minimum); | | |||
249 | l1policy.setHeightForWidth(l1->sizePolicy().hasHeightForWidth()); | | |||
250 | l1->setSizePolicy(l1policy); | | |||
251 | l1->setFrameShape(QLabel::StyledPanel); | | |||
252 | l1->setFrameShadow(QLabel::Sunken); | | |||
253 | l1->setText(i18n("Text found:")); | | |||
254 | foundTextLayout->addWidget(l1); | | |||
255 | 223 | | |||
224 | QLabel *textFoundLabel = new QLabel(i18n("Text found:"), resultTab); | ||||
225 | foundTextLayout->addWidget(textFoundLabel); | ||||
256 | foundTextLabel = new KrSqueezedTextLabel(resultTab); | 226 | foundTextLabel = new KrSqueezedTextLabel(resultTab); | ||
257 | foundTextLabel->setFrameShape(QLabel::StyledPanel); | | |||
258 | foundTextLabel->setFrameShadow(QLabel::Sunken); | | |||
259 | foundTextLabel->setText(""); | | |||
260 | foundTextLayout->addWidget(foundTextLabel); | 227 | foundTextLayout->addWidget(foundTextLabel); | ||
261 | resultLayout->addLayout(foundTextLayout, 3, 0); | 228 | | ||
229 | foundTextFrame->setLayout(foundTextLayout); | ||||
230 | foundTextFrame->hide(); | ||||
231 | | ||||
232 | resultLayout->addWidget(foundTextFrame, 2, 0); | ||||
233 | | ||||
234 | // result info row | ||||
235 | QHBoxLayout* resultLabelLayout = new QHBoxLayout(); | ||||
236 | resultLabelLayout->setSpacing(6); | ||||
237 | resultLabelLayout->setContentsMargins(0, 0, 0, 0); | ||||
238 | | ||||
239 | searchingLabel = new KSqueezedTextLabel(i18n("Idle"), resultTab); | ||||
240 | resultLabelLayout->addWidget(searchingLabel); | ||||
241 | | ||||
242 | foundLabel = new QLabel("", resultTab); | ||||
243 | resultLabelLayout->addWidget(foundLabel); | ||||
244 | | ||||
245 | mainFeedToListBoxBtn = new QPushButton(QIcon::fromTheme("list-add"), i18n("Feed to listbox"), this); | ||||
246 | mainFeedToListBoxBtn->setEnabled(false); | ||||
247 | resultLabelLayout->addWidget(mainFeedToListBoxBtn); | ||||
248 | | ||||
249 | resultLayout->addLayout(resultLabelLayout, 3, 0); | ||||
262 | 250 | | |||
263 | searcherTabs->addTab(resultTab, i18n("&Results")); | 251 | searcherTabs->addTab(resultTab, i18n("&Results")); | ||
264 | 252 | | |||
265 | searchBaseLayout->addWidget(searcherTabs, 0, 0); | 253 | searchBaseLayout->addWidget(searcherTabs, 0, 0); | ||
266 | 254 | | |||
267 | // signals and slots connections | 255 | // signals and slots connections | ||
268 | 256 | | |||
269 | connect(mainSearchBtn, SIGNAL(clicked()), this, SLOT(startSearch())); | 257 | connect(mainSearchBtn, SIGNAL(clicked()), this, SLOT(startSearch())); | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 392 | { | |||
412 | if (query->searchInArchives()) { | 400 | if (query->searchInArchives()) { | ||
413 | KMessageBox::information(this, i18n("Since you chose to also search in archives, " | 401 | KMessageBox::information(this, i18n("Since you chose to also search in archives, " | ||
414 | "note the following limitations:\n" | 402 | "note the following limitations:\n" | ||
415 | "You cannot search for text (grep) while doing" | 403 | "You cannot search for text (grep) while doing" | ||
416 | " a search that includes archives."), 0, "searchInArchives"); | 404 | " a search that includes archives."), 0, "searchInArchives"); | ||
417 | } | 405 | } | ||
418 | 406 | | |||
419 | // prepare the gui /////////////////////////////////////////////// | 407 | // prepare the gui /////////////////////////////////////////////// | ||
420 | mainSearchBtn->setEnabled(false); | | |||
421 | mainCloseBtn->setEnabled(false); | | |||
422 | mainStopBtn->setEnabled(true); | | |||
423 | mainFeedToListBoxBtn->setEnabled(false); | | |||
424 | result->clear(); | 408 | result->clear(); | ||
425 | resultView->setSortMode(KrViewProperties::NoColumn, 0); | 409 | resultView->setSortMode(KrViewProperties::NoColumn, 0); | ||
410 | | ||||
411 | foundTextFrame->setVisible(!query->content().isEmpty()); | ||||
412 | foundTextLabel->setText(""); | ||||
413 | | ||||
426 | searchingLabel->setText(""); | 414 | searchingLabel->setText(""); | ||
427 | foundLabel->setText(i18n("Found 0 matches.")); | 415 | foundLabel->setText(i18n("Found 0 matches.")); | ||
416 | mainFeedToListBoxBtn->setEnabled(false); | ||||
417 | | ||||
418 | mainSearchBtn->setEnabled(false); | ||||
419 | mainStopBtn->setEnabled(true); | ||||
420 | mainCloseBtn->setEnabled(false); | ||||
421 | | ||||
428 | searcherTabs->setCurrentIndex(2); // show the results page | 422 | searcherTabs->setCurrentIndex(2); // show the results page | ||
429 | foundTextLabel->setText(""); | | |||
430 | 423 | | |||
431 | isBusy = true; | 424 | isBusy = true; | ||
432 | 425 | | |||
433 | qApp->processEvents(); | 426 | qApp->processEvents(); | ||
434 | 427 | | |||
435 | // start the search. | 428 | // start the search. | ||
436 | if (searcher != 0) | 429 | if (searcher != 0) | ||
437 | abort(); | 430 | abort(); | ||
438 | searcher = new KRSearchMod(query); | 431 | searcher = new KRSearchMod(query); | ||
439 | connect(searcher, SIGNAL(searching(QString)), | 432 | connect(searcher, &KRSearchMod::searching, searchingLabel, &KSqueezedTextLabel::setText); | ||
440 | searchingLabel, SLOT(setText(QString))); | | |||
441 | connect(searcher, &KRSearchMod::found, this, &KrSearchDialog::slotFound); | 433 | connect(searcher, &KRSearchMod::found, this, &KrSearchDialog::slotFound); | ||
442 | connect(searcher, SIGNAL(finished()), this, SLOT(stopSearch())); | 434 | connect(searcher, &KRSearchMod::finished, this, &KrSearchDialog::stopSearch); | ||
443 | 435 | | |||
444 | searcher->start(); | 436 | searcher->start(); | ||
445 | 437 | | |||
446 | isBusy = false; | 438 | isBusy = false; | ||
447 | 439 | | |||
448 | delete searcher; | 440 | delete searcher; | ||
449 | searcher = 0; | 441 | searcher = 0; | ||
450 | 442 | | |||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | |||||
596 | { | 588 | { | ||
597 | VirtualFileSystem virtFilesystem; | 589 | VirtualFileSystem virtFilesystem; | ||
598 | virtFilesystem.scanDir(QUrl::fromLocalFile("/")); | 590 | virtFilesystem.scanDir(QUrl::fromLocalFile("/")); | ||
599 | 591 | | |||
600 | KConfigGroup group(krConfig, "Search"); | 592 | KConfigGroup group(krConfig, "Search"); | ||
601 | int listBoxNum = group.readEntry("Feed To Listbox Counter", 1); | 593 | int listBoxNum = group.readEntry("Feed To Listbox Counter", 1); | ||
602 | QString queryName; | 594 | QString queryName; | ||
603 | if(query) { | 595 | if(query) { | ||
604 | QString where = KrServices::toStringList(query->searchInDirs()).join(", "); | 596 | const QString where = KrServices::toStringList(query->searchInDirs()).join(", "); | ||
605 | if(query->content().isEmpty()) | 597 | queryName = query->content().isEmpty() ? | ||
606 | queryName = i18n("Search results for \"%1\" in %2", query->nameFilter(), where); | 598 | i18n("Search results for \"%1\" in %2", query->nameFilter(), where) : | ||
607 | else | 599 | i18n("Search results for \"%1\" containing \"%2\" in %3", query->nameFilter(), query->content(), where); | ||
608 | queryName = i18n("Search results for \"%1\" containing \"%2\" in %3", query->nameFilter(), query->content(), where); | | |||
609 | } | 600 | } | ||
610 | QString fileSystemName; | 601 | QString fileSystemName; | ||
611 | do { | 602 | do { | ||
612 | fileSystemName = i18n("Search results") + QString(" %1").arg(listBoxNum++); | 603 | fileSystemName = i18n("Search results") + QString(" %1").arg(listBoxNum++); | ||
613 | } while (virtFilesystem.getFileItem(fileSystemName) != 0); | 604 | } while (virtFilesystem.getFileItem(fileSystemName) != 0); | ||
614 | group.writeEntry("Feed To Listbox Counter", listBoxNum); | 605 | group.writeEntry("Feed To Listbox Counter", listBoxNum); | ||
615 | 606 | | |||
616 | KConfigGroup ga(krConfig, "Advanced"); | 607 | KConfigGroup ga(krConfig, "Advanced"); | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |