Commit db514027 authored by Milian Wolff's avatar Milian Wolff
Browse files

use combo box instead of line edit for patterns in find in files dialog

This patch replaces the "line edit" in the "find in files" dialog by a KComboBox,
 so that all used patterns are saved between sessions, not only the last used one.

Thanks for the patch go to Steffen Ohrendorf

CCBUG: 112381
REVIEW: 100877
parent da6e96fa
......@@ -131,8 +131,20 @@ GrepDialog::GrepDialog( GrepViewPlugin * plugin, QWidget *parent, bool setLastUs
templateTypeCombo->addItems(template_desc);
templateTypeCombo->setCurrentIndex( cg.readEntry("LastUsedTemplateIndex", 0) );
templateEdit->setText( cg.readEntry("LastUsedTemplateString", template_str[0]) );
replacementTemplateEdit->setText( cg.readEntry("LastUsedReplacementTemplateString", repl_template[0]) );
templateEdit->addItems( cg.readEntry("LastUsedTemplateString", template_str) );
templateEdit->setEditable(true);
templateEdit->setCompletionMode(KGlobalSettings::CompletionPopup);
KCompletion* comp = templateEdit->completionObject();
connect(templateEdit, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));
for(int i=0; i<templateEdit->count(); i++)
comp->addItem(templateEdit->itemText(i));
replacementTemplateEdit->addItems( cg.readEntry("LastUsedReplacementTemplateString", repl_template) );
replacementTemplateEdit->setEditable(true);
replacementTemplateEdit->setCompletionMode(KGlobalSettings::CompletionPopup);
comp = replacementTemplateEdit->completionObject();
connect(replacementTemplateEdit, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));
for(int i=0; i<replacementTemplateEdit->count(); i++)
comp->addItem(replacementTemplateEdit->itemText(i));
regexCheck->setChecked(cg.readEntry("regexp", false ));
......@@ -261,15 +273,15 @@ GrepDialog::~GrepDialog()
cg.writeEntry("exclude_patterns", qCombo2StringList(excludeCombo));
cg.writeEntry("file_patterns", qCombo2StringList(filesCombo));
cg.writeEntry("LastUsedTemplateIndex", templateTypeCombo->currentIndex());
cg.writeEntry("LastUsedTemplateString", templateEdit->text());
cg.writeEntry("LastUsedReplacementTemplateString", replacementTemplateEdit->text());
cg.writeEntry("LastUsedTemplateString", qCombo2StringList(templateEdit));
cg.writeEntry("LastUsedReplacementTemplateString", qCombo2StringList(templateEdit));
cg.sync();
}
void GrepDialog::templateTypeComboActivated(int index)
{
templateEdit->setText(template_str[index]);
replacementTemplateEdit->setText(repl_template[index]);
templateEdit->setCurrentItem( template_str[index], true );
replacementTemplateEdit->setCurrentItem( repl_template[index], true );
}
void GrepDialog::setEnableProjectBox(bool enable)
......@@ -300,12 +312,12 @@ QString GrepDialog::patternString() const
QString GrepDialog::templateString() const
{
return templateEdit->text().isEmpty() ? "%s" : templateEdit->text();
return templateEdit->currentText().isEmpty() ? "%s" : templateEdit->currentText();
}
QString GrepDialog::replacementTemplateString() const
{
return replacementTemplateEdit->text();
return replacementTemplateEdit->currentText();
}
QString GrepDialog::filesString() const
......
......@@ -102,16 +102,13 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="KLineEdit" name="templateEdit">
<widget class="KComboBox" name="templateEdit">
<property name="toolTip">
<string>This is the regular expression template.</string>
</property>
<property name="whatsThis">
<string>This is the regular expression template. &lt;i&gt;%s&lt;/i&gt; will be replaced by the pattern, while &lt;i&gt;%%&lt;/i&gt; will be replaced by &lt;i&gt;%&lt;/i&gt;.</string>
</property>
<property name="text">
<string>%s</string>
</property>
</widget>
</item>
<item row="1" column="4" colspan="2">
......@@ -389,7 +386,7 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item row="2" column="1" colspan="3">
<widget class="KLineEdit" name="replacementTemplateEdit">
<widget class="KComboBox" name="replacementTemplateEdit">
<property name="toolTip">
<string>Enter the replacement template.</string>
</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment