Patch for GrepDialog

Harald Fernengel harry at bnro.de
Sun Apr 29 20:15:46 UTC 2001


Hello,

this patch enables the GrepDialog to remeber the last 10 search items.

It also prevents the GrepDialog from searching in case the user entered no 
search pattern (searching for an empty string is quite silly).

It's for KDEVELOP_1_4.

Harry
-------------- next part --------------
Index: kdevelop/grepdialog.cpp
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/Attic/grepdialog.cpp,v
retrieving revision 1.8.2.3.2.5
diff -r1.8.2.3.2.5 grepdialog.cpp
60c60,64
<     
---
> 
>     config = KGlobal::config();
>     config->setGroup("GrepDialog");
>     lastSearchItems = config->readListEntry("LastSearchItems");
> 
81,85c85,92
<     pattern_edit = new QLineEdit(this);
<     pattern_label->setBuddy(pattern_edit);
<     pattern_edit->setFocus();
<     pattern_edit->setMinimumSize(pattern_edit->sizeHint());
<     input_layout->addWidget(pattern_edit, 0, 1);
---
>     pattern_combo = new QComboBox(true, this);
>     pattern_combo->insertStringList(lastSearchItems);
>     pattern_combo->setEditText(QString::null);
>     pattern_combo->setInsertionPolicy(QComboBox::NoInsertion);
>     pattern_label->setBuddy(pattern_combo);
>     pattern_combo->setFocus();
>     pattern_combo->setMinimumSize(pattern_combo->sizeHint());
>     input_layout->addWidget(pattern_combo, 0, 1);
183c190
<     QWhatsThis::add(pattern_edit,
---
>     QWhatsThis::add(pattern_combo,
295a303,305
>     if (pattern_combo->currentText().isEmpty())
>         return;
> 
315c325
<     pattern.replace(QRegExp("%s"), pattern_edit->text());
---
>     pattern.replace(QRegExp("%s"), pattern_combo->lineEdit()->text());
345,346c355
<     pattern_edit->clear();
<     pattern_edit->setText(pattern);
---
>     pattern_combo->lineEdit()->setText(pattern);
359a369,380
> 
>     config->setGroup("GrepDialog");
>     if (lastSearchItems.contains(pattern_combo->lineEdit()->text()) == 0) {
>         pattern_combo->insertItem(pattern_combo->lineEdit()->text(), 0);
>         lastSearchItems.prepend(pattern_combo->lineEdit()->text());
>         if (lastSearchItems.count() > 10) {
>             lastSearchItems.remove(lastSearchItems.fromLast());
>             pattern_combo->removeItem(pattern_combo->count() - 1);
>         }
>         config->writeEntry("LastSearchItems", lastSearchItems);
>     }
> 
Index: kdevelop/grepdialog.h
===================================================================
RCS file: /home/kde/kdevelop/kdevelop/Attic/grepdialog.h,v
retrieving revision 1.3.4.1
diff -r1.3.4.1 grepdialog.h
29a30
> class KConfig;
61,62c62,63
<     QLineEdit *pattern_edit, *template_edit, *dir_edit;
<     QComboBox *files_combo;
---
>     QLineEdit *template_edit, *dir_edit;
>     QComboBox *files_combo, *pattern_combo;
68a70,71
>     KConfig* config;
>     QStringList lastSearchItems;


More information about the KDevelop-devel mailing list