Changeset View
Changeset View
Standalone View
Standalone View
krusader/Filter/generalfilter.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 91 | { | |||
---|---|---|---|---|---|
119 | searchFor->setSizePolicy(searchForPolicy); | 119 | searchFor->setSizePolicy(searchForPolicy); | ||
120 | searchFor->setEditable(true); | 120 | searchFor->setEditable(true); | ||
121 | searchFor->setDuplicatesEnabled(false); | 121 | searchFor->setDuplicatesEnabled(false); | ||
122 | searchFor->setMaxCount(25); | 122 | searchFor->setMaxCount(25); | ||
123 | searchFor->setMinimumContentsLength(10); | 123 | searchFor->setMinimumContentsLength(10); | ||
124 | searchForLabel->setBuddy(searchFor); | 124 | searchForLabel->setBuddy(searchFor); | ||
125 | nameGroupLayout->addWidget(searchFor, 0, 1, 1, 2); | 125 | nameGroupLayout->addWidget(searchFor, 0, 1, 1, 2); | ||
126 | 126 | | |||
127 | QString s = "<p><img src='toolbar|find'></p>" + i18n("<p>The filename filtering criteria is defined here.</p><p>You can make use of wildcards. Multiple patterns are separated by space (means logical OR) and patterns are excluded from the search using the pipe symbol.</p><p>If the pattern is ended with a slash (<code>*pattern*/</code>), that means that pattern relates to recursive search of folders.<ul><li><code>pattern</code> - means to search those files/folders that name is <code>pattern</code>, recursive search goes through all subfolders independently of the value of <code>pattern</code></li><li><code>pattern/</code> - means to search all files/folders, but recursive search goes through/excludes the folders that name is <code>pattern</code></li></ul></p><p>It is allowed to use quotation marks for names that contain space. Filter <code>\"Program Files\"</code> searches out those files/folders that name is <code>Program Files</code>.</p><p>Examples:</p><ul><li><code>*.o</code></li><li><code>*.h *.c\?\?</code></li><li><code>*.cpp *.h | *.moc.cpp</code></li><li><code>* | .svn/ .git/</code></li></ul><p><b>Note</b>: the search term '<code>text</code>' is equivalent to '<code>*text*</code>'.</p>"); | 127 | const QString s = "<p><img src='toolbar|find'></p>" | ||
128 | + i18n("<p>The filename filtering criteria is defined here.</p>" | ||||
129 | "<p>You can make use of wildcards. Multiple patterns are separated by " | ||||
130 | "space (means logical OR) and patterns are excluded from the search " | ||||
131 | "using the pipe symbol.</p>" | ||||
132 | "<p>If the pattern is ended with a slash (<code>*pattern*/</code>), " | ||||
133 | "that means that pattern relates to recursive search of folders." | ||||
134 | "<ul><li><code>pattern</code> - means to search those files/folders " | ||||
135 | "that name is <code>pattern</code>, recursive search goes through all " | ||||
136 | "subfolders independently of the value of <code>pattern</code></li>" | ||||
137 | "<li><code>pattern/</code> - means to search all files/folders, but " | ||||
138 | "recursive search goes through/excludes the folders that name is " | ||||
139 | "<code>pattern</code></li></ul></p>" | ||||
140 | "<p>It is allowed to use quotation marks for names that contain space." | ||||
141 | " Filter <code>\"Program Files\"</code> searches out those " | ||||
142 | "files/folders that name is <code>Program Files</code>.</p>" | ||||
143 | "<p>Examples:</p><ul>" | ||||
144 | "<li><code>*.o</code></li>" | ||||
145 | "<li><code>*.h *.c\?\?</code></li>" | ||||
146 | "<li><code>*.cpp *.h | *.moc.cpp</code></li>" | ||||
147 | "<li><code>* | .svn/ .git/</code></li></ul><p>" | ||||
148 | "<b>Note</b>: the search term '<code>text</code>' is equivalent to " | ||||
149 | "'<code>*text*</code>'.</p>"); | ||||
128 | searchFor->setWhatsThis(s); | 150 | searchFor->setWhatsThis(s); | ||
129 | searchForLabel->setWhatsThis(s); | 151 | searchForLabel->setWhatsThis(s); | ||
130 | 152 | | |||
131 | QLabel *searchType = new QLabel(nameGroup); | 153 | QLabel *searchType = new QLabel(nameGroup); | ||
132 | searchType->setText(i18n("&Of type:")); | 154 | searchType->setText(i18n("&Of type:")); | ||
133 | nameGroupLayout->addWidget(searchType, 1, 0); | 155 | nameGroupLayout->addWidget(searchType, 1, 0); | ||
134 | 156 | | |||
135 | ofType = new KComboBox(false, nameGroup); | 157 | ofType = new KComboBox(false, nameGroup); | ||
Show All 13 Lines | |||||
149 | connect(ofType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotDisable())); | 171 | connect(ofType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotDisable())); | ||
150 | 172 | | |||
151 | nameGroupLayout->addWidget(ofType, 1, 1); | 173 | nameGroupLayout->addWidget(ofType, 1, 1); | ||
152 | filterLayout->addWidget(nameGroup, 0, 0); | 174 | filterLayout->addWidget(nameGroup, 0, 0); | ||
153 | 175 | | |||
154 | middleLayout = new QHBoxLayout(); | 176 | middleLayout = new QHBoxLayout(); | ||
155 | middleLayout->setSpacing(6); | 177 | middleLayout->setSpacing(6); | ||
156 | middleLayout->setContentsMargins(0, 0, 0, 0); | 178 | middleLayout->setContentsMargins(0, 0, 0, 0); | ||
157 | QSpacerItem* middleSpacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Fixed); | | |||
158 | middleLayout->addItem(middleSpacer); | | |||
159 | 179 | | |||
160 | if (properties & FilterTabs::HasProfileHandler) { | 180 | if (properties & FilterTabs::HasProfileHandler) { | ||
161 | // The profile handler | 181 | // The profile handler | ||
162 | 182 | | |||
163 | QGroupBox *profileHandler = new QGroupBox(this); | 183 | QGroupBox *profileHandler = new QGroupBox(this); | ||
164 | profileHandler->setTitle(i18n("&Profile handler")); | 184 | profileHandler->setTitle(i18n("&Profile handler")); | ||
165 | QGridLayout *profileLayout = new QGridLayout(profileHandler); | 185 | QGridLayout *profileLayout = new QGridLayout(profileHandler); | ||
166 | profileLayout->setAlignment(Qt::AlignTop); | 186 | profileLayout->setAlignment(Qt::AlignTop); | ||
Show All 26 Lines | |||||
193 | 213 | | |||
194 | middleLayout->addWidget(profileHandler); | 214 | middleLayout->addWidget(profileHandler); | ||
195 | 215 | | |||
196 | refreshProfileListBox(); | 216 | refreshProfileListBox(); | ||
197 | } | 217 | } | ||
198 | 218 | | |||
199 | if (properties & FilterTabs::HasSearchIn) { | 219 | if (properties & FilterTabs::HasSearchIn) { | ||
200 | // Options for search in | 220 | // Options for search in | ||
221 | QGroupBox *searchGroupBox = new QGroupBox(i18n("Searc&h in"), this); | ||||
222 | QGridLayout *searchLayout = new QGridLayout(searchGroupBox); | ||||
223 | searchLayout->setAlignment(Qt::AlignTop); | ||||
224 | searchLayout->setSpacing(6); | ||||
225 | searchLayout->setContentsMargins(11, 11, 11, 11); | ||||
226 | | ||||
227 | searchIn = new KURLListRequester(KURLListRequester::RequestDirs, searchGroupBox); | ||||
228 | searchLayout->addWidget(searchIn, 0, 0); | ||||
229 | connect(searchIn, &KURLListRequester::changed, this, &GeneralFilter::slotDisable); | ||||
201 | 230 | | |||
202 | QGroupBox *searchInGroup = new QGroupBox(this); | 231 | middleLayout->addWidget(searchGroupBox); | ||
203 | searchInGroup->setTitle(i18n("Searc&h in")); | | |||
204 | QGridLayout *searchInLayout = new QGridLayout(searchInGroup); | | |||
205 | searchInLayout->setAlignment(Qt::AlignTop); | | |||
206 | searchInLayout->setSpacing(6); | | |||
207 | searchInLayout->setContentsMargins(11, 11, 11, 11); | | |||
208 | | ||||
209 | searchIn = new KURLListRequester(KURLListRequester::RequestDirs, searchInGroup); | | |||
210 | searchInLayout->addWidget(searchIn, 0, 0); | | |||
211 | connect(searchIn, SIGNAL(changed()), this, SLOT(slotDisable())); | | |||
212 | | ||||
213 | middleLayout->addWidget(searchInGroup); | | |||
214 | } | 232 | } | ||
215 | 233 | | |||
216 | if (properties & FilterTabs::HasDontSearchIn) { | 234 | if (properties & FilterTabs::HasDontSearchIn) { | ||
217 | // Options for don't search in | 235 | // Options for don't search in | ||
236 | QGroupBox *searchGroupBox = new QGroupBox(i18n("&Do not search in"), this); | ||||
237 | QGridLayout *searchLayout = new QGridLayout(searchGroupBox); | ||||
238 | searchLayout->setAlignment(Qt::AlignTop); | ||||
239 | searchLayout->setSpacing(6); | ||||
240 | searchLayout->setContentsMargins(11, 11, 11, 11); | ||||
218 | 241 | | |||
219 | QGroupBox *dontSearchInGroup = new QGroupBox(this); | 242 | dontSearchIn = new KURLListRequester(KURLListRequester::RequestDirs, searchGroupBox); | ||
220 | dontSearchInGroup->setTitle(i18n("&Do not search in")); | 243 | searchLayout->addWidget(dontSearchIn, 0, 0, 1, 2); | ||
221 | QGridLayout *dontSearchInLayout = new QGridLayout(dontSearchInGroup); | | |||
222 | dontSearchInLayout->setAlignment(Qt::AlignTop); | | |||
223 | dontSearchInLayout->setSpacing(6); | | |||
224 | dontSearchInLayout->setContentsMargins(11, 11, 11, 11); | | |||
225 | | ||||
226 | dontSearchIn = new KURLListRequester(KURLListRequester::RequestDirs, dontSearchInGroup); | | |||
227 | dontSearchInLayout->addWidget(dontSearchIn, 0, 0, 1, 2); | | |||
228 | 244 | | |||
229 | if (properties & FilterTabs::HasRecurseOptions) { | 245 | if (properties & FilterTabs::HasRecurseOptions) { | ||
230 | KConfigGroup group(krConfig, "Search"); | 246 | KConfigGroup group(krConfig, "Search"); | ||
231 | 247 | | |||
232 | useExcludeFolderNames = new QCheckBox(this); | 248 | useExcludeFolderNames = createExcludeCheckBox(group); | ||
233 | useExcludeFolderNames->setText(i18n("Exclude Folder Names")); | 249 | searchLayout->addWidget(useExcludeFolderNames, 1, 0, 1, 1); | ||
234 | useExcludeFolderNames->setToolTip(i18n("Filters out specified directory names from the results.")); | 250 | | ||
235 | useExcludeFolderNames->setChecked(static_cast<Qt::CheckState>(group.readEntry("ExcludeFolderNamesUse", 0))); | 251 | excludeFolderNames = createExcludeComboBox(group); | ||
236 | dontSearchInLayout->addWidget(useExcludeFolderNames, 1, 0, 1, 1); | 252 | searchLayout->addWidget(excludeFolderNames, 1, 1, 1, 1); | ||
237 | 253 | | |||
238 | excludeFolderNames = new KHistoryComboBox(false, dontSearchInGroup); | | |||
239 | QSizePolicy excludeFolderNamesPolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | | |||
240 | excludeFolderNamesPolicy.setHeightForWidth(excludeFolderNames->sizePolicy().hasHeightForWidth()); | | |||
241 | excludeFolderNames->setSizePolicy(excludeFolderNamesPolicy); | | |||
242 | excludeFolderNames->setEditable(true); | | |||
243 | excludeFolderNames->setDuplicatesEnabled(false); | | |||
244 | excludeFolderNames->setMaxCount(25); | | |||
245 | excludeFolderNames->setMinimumContentsLength(10); | | |||
246 | excludeFolderNames->lineEdit()->setPlaceholderText(i18n("Enter space-separated folder names")); | | |||
247 | excludeFolderNames->lineEdit()->setWhatsThis(i18n("You can insert names with escaped spaces or quoted.\nExample: .git \"target build\" build\\ krusader")); | | |||
248 | dontSearchInLayout->addWidget(excludeFolderNames, 1, 1, 1, 1); | | |||
249 | excludeFolderNames->setHistoryItems(group.readEntry("ExcludeFolderNamesHistory", QStringList())); | | |||
250 | excludeFolderNames->setEditText(group.readEntry("ExcludeFolderNames", "")); | | |||
251 | if (!useExcludeFolderNames->isChecked()) { | 254 | if (!useExcludeFolderNames->isChecked()) { | ||
252 | excludeFolderNames->setDisabled(true); | 255 | excludeFolderNames->setDisabled(true); | ||
253 | } | 256 | } | ||
254 | 257 | | |||
255 | connect(useExcludeFolderNames, &QCheckBox::toggled, excludeFolderNames, &KHistoryComboBox::setEnabled); | 258 | connect(useExcludeFolderNames, &QCheckBox::toggled, excludeFolderNames, &KHistoryComboBox::setEnabled); | ||
256 | } | 259 | } | ||
257 | 260 | | |||
258 | middleLayout->addWidget(dontSearchInGroup); | 261 | middleLayout->addWidget(searchGroupBox); | ||
259 | } | 262 | } | ||
260 | 263 | | |||
261 | filterLayout->addLayout(middleLayout, 1, 0); | 264 | filterLayout->addLayout(middleLayout, 1, 0); | ||
262 | 265 | | |||
263 | // Options for containing text | 266 | // Options for containing text | ||
264 | 267 | | |||
265 | QGroupBox *containsGroup = new QGroupBox(this); | 268 | QGroupBox *containsGroup = new QGroupBox(this); | ||
266 | containsGroup->setTitle(i18n("Containing text")); | 269 | containsGroup->setTitle(i18n("Containing text")); | ||
Show All 28 Lines | |||||
295 | containsRegExp->setCheckable(true); | 298 | containsRegExp->setCheckable(true); | ||
296 | containsRegExp->setText(i18n("RegExp")); | 299 | containsRegExp->setText(i18n("RegExp")); | ||
297 | // Populate the popup menu. | 300 | // Populate the popup menu. | ||
298 | QMenu *patterns = new QMenu(containsRegExp); | 301 | QMenu *patterns = new QMenu(containsRegExp); | ||
299 | for (int i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) { | 302 | for (int i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) { | ||
300 | patterns->addAction(new RegExpAction(patterns, i18n(items[i].description), | 303 | patterns->addAction(new RegExpAction(patterns, i18n(items[i].description), | ||
301 | items[i].regExp, items[i].cursorAdjustment)); | 304 | items[i].regExp, items[i].cursorAdjustment)); | ||
302 | } | 305 | } | ||
303 | connect(containsRegExp, SIGNAL(toggled(bool)), this, SLOT(slotDisable())); | 306 | connect(containsRegExp, &QToolButton::toggled, this, &GeneralFilter::slotDisable); | ||
304 | connect(containsRegExp, SIGNAL(triggered(QAction*)), this, SLOT(slotRegExpTriggered(QAction*))); | 307 | connect(containsRegExp, &QToolButton::triggered, this, &GeneralFilter::slotRegExpTriggered); | ||
305 | containsRegExp->setMenu(patterns); | 308 | containsRegExp->setMenu(patterns); | ||
306 | patterns->setEnabled(false); | 309 | patterns->setEnabled(false); | ||
307 | 310 | | |||
308 | containsTextLayout->addWidget(containsRegExp); | 311 | containsTextLayout->addWidget(containsRegExp); | ||
309 | 312 | | |||
310 | containsLayout->addLayout(containsTextLayout, 0, 0); | 313 | containsLayout->addLayout(containsTextLayout, 0, 0); | ||
311 | 314 | | |||
312 | QHBoxLayout *containsCbsLayout = new QHBoxLayout(); | 315 | QHBoxLayout *containsCbsLayout = new QHBoxLayout(); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 374 | for(int i = 0; i < extraOptions.length(); i++) { | |||
373 | option->setText(extraOptions[i]); | 376 | option->setText(extraOptions[i]); | ||
374 | recurseLayout->addWidget(option); | 377 | recurseLayout->addWidget(option); | ||
375 | this->extraOptions.insert(extraOptions[i], option); | 378 | this->extraOptions.insert(extraOptions[i], option); | ||
376 | } | 379 | } | ||
377 | 380 | | |||
378 | // Connection table | 381 | // Connection table | ||
379 | 382 | | |||
380 | if (properties & FilterTabs::HasProfileHandler) { | 383 | if (properties & FilterTabs::HasProfileHandler) { | ||
381 | connect(profileAddBtn, SIGNAL(clicked()) , this, SLOT(slotAddBtnClicked())); | 384 | connect(profileAddBtn, &QPushButton::clicked, this, &GeneralFilter::slotAddBtnClicked); | ||
382 | connect(profileLoadBtn, SIGNAL(clicked()) , this, SLOT(slotLoadBtnClicked())); | 385 | connect(profileLoadBtn, &QPushButton::clicked, this, &GeneralFilter::slotLoadBtnClicked); | ||
383 | connect(profileOverwriteBtn, SIGNAL(clicked()) , this, SLOT(slotOverwriteBtnClicked())); | 386 | connect(profileOverwriteBtn, &QPushButton::clicked, this, &GeneralFilter::slotOverwriteBtnClicked); | ||
384 | connect(profileRemoveBtn, SIGNAL(clicked()) , this, SLOT(slotRemoveBtnClicked())); | 387 | connect(profileRemoveBtn, &QPushButton::clicked, this, &GeneralFilter::slotRemoveBtnClicked); | ||
385 | connect(profileListBox, SIGNAL(itemDoubleClicked(QListWidgetItem*)) , this, SLOT(slotProfileDoubleClicked(QListWidgetItem*))); | 388 | connect(profileListBox, &KrListWidget::itemDoubleClicked, this, &GeneralFilter::slotProfileDoubleClicked); | ||
386 | connect(profileManager, SIGNAL(loadFromProfile(QString)), fltTabs, SLOT(loadFromProfile(QString))); | 389 | connect(profileManager, &ProfileManager::loadFromProfile, fltTabs, &FilterTabs::loadFromProfile); | ||
387 | connect(profileManager, SIGNAL(saveToProfile(QString)), fltTabs, SLOT(saveToProfile(QString))); | 390 | connect(profileManager, &ProfileManager::saveToProfile, fltTabs, &FilterTabs::saveToProfile); | ||
388 | } | 391 | } | ||
389 | 392 | | |||
390 | connect(searchFor, SIGNAL(activated(QString)), searchFor, SLOT(addToHistory(QString))); | 393 | connect(searchFor, SIGNAL(activated(QString)), searchFor, SLOT(addToHistory(QString))); | ||
391 | connect(containsText, SIGNAL(activated(QString)), containsText, SLOT(addToHistory(QString))); | 394 | connect(containsText, SIGNAL(activated(QString)), containsText, SLOT(addToHistory(QString))); | ||
392 | 395 | | |||
393 | // load the completion and history lists | 396 | // load the completion and history lists | ||
394 | // ==> search for | 397 | // ==> search for | ||
395 | KConfigGroup group(krConfig, "Search"); | 398 | KConfigGroup group(krConfig, "Search"); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 465 | if (profileListBox->count() != 0) { | |||
465 | profileRemoveBtn->setEnabled(true); | 468 | profileRemoveBtn->setEnabled(true); | ||
466 | } else { | 469 | } else { | ||
467 | profileLoadBtn->setEnabled(false); | 470 | profileLoadBtn->setEnabled(false); | ||
468 | profileOverwriteBtn->setEnabled(false); | 471 | profileOverwriteBtn->setEnabled(false); | ||
469 | profileRemoveBtn->setEnabled(false); | 472 | profileRemoveBtn->setEnabled(false); | ||
470 | } | 473 | } | ||
471 | } | 474 | } | ||
472 | 475 | | |||
476 | QCheckBox *GeneralFilter::createExcludeCheckBox(const KConfigGroup &group) | ||||
477 | { | ||||
478 | QCheckBox *excludeCheckBox = new QCheckBox(this); | ||||
479 | excludeCheckBox->setText(i18n("Exclude Folder Names")); | ||||
480 | excludeCheckBox->setToolTip(i18n("Filters out specified directory names from the results.")); | ||||
481 | excludeCheckBox->setChecked(static_cast<Qt::CheckState>(group.readEntry("ExcludeFolderNamesUse", 0))); | ||||
482 | return excludeCheckBox; | ||||
483 | } | ||||
484 | | ||||
485 | KHistoryComboBox *GeneralFilter::createExcludeComboBox(const KConfigGroup &group) | ||||
486 | { | ||||
487 | KHistoryComboBox *excludeComboBox = new KHistoryComboBox(false, this); | ||||
488 | QSizePolicy excludeFolderNamesPolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||||
489 | excludeFolderNamesPolicy.setHeightForWidth(excludeComboBox->sizePolicy().hasHeightForWidth()); | ||||
490 | excludeComboBox->setSizePolicy(excludeFolderNamesPolicy); | ||||
491 | excludeComboBox->setEditable(true); | ||||
492 | excludeComboBox->setDuplicatesEnabled(false); | ||||
493 | excludeComboBox->setMaxCount(25); | ||||
494 | excludeComboBox->setMinimumContentsLength(10); | ||||
495 | excludeComboBox->lineEdit()->setPlaceholderText(i18n("Enter space-separated folder names")); | ||||
496 | excludeComboBox->lineEdit()->setWhatsThis( | ||||
497 | i18n("You can insert names with escaped spaces or quoted.\nExample: .git \"target " | ||||
498 | "build\" build\\ krusader")); | ||||
499 | excludeComboBox->setHistoryItems(group.readEntry("ExcludeFolderNamesHistory", QStringList())); | ||||
500 | excludeComboBox->setEditText(group.readEntry("ExcludeFolderNames", "")); | ||||
501 | return excludeComboBox; | ||||
502 | } | ||||
503 | | ||||
473 | void GeneralFilter::slotAddBtnClicked() | 504 | void GeneralFilter::slotAddBtnClicked() | ||
474 | { | 505 | { | ||
475 | profileManager->newProfile(searchFor->currentText().simplified()); | 506 | profileManager->newProfile(searchFor->currentText().simplified()); | ||
476 | refreshProfileListBox(); | 507 | refreshProfileListBox(); | ||
477 | } | 508 | } | ||
478 | 509 | | |||
479 | void GeneralFilter::slotOverwriteBtnClicked() | 510 | void GeneralFilter::slotOverwriteBtnClicked() | ||
480 | { | 511 | { | ||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |