Commit 7996a4e9 authored by Alex Neundorf's avatar Alex Neundorf

search&replace plugin: add separate exclude-filter

This patch adds a separate exclude filter to the search&replace plugin
in folder-mode.
It is handled similar to the normal filter, including history, etc.
The "-" feature is removed from the normal filter.

Alex
parent 33d7ecab
......@@ -194,8 +194,8 @@ m_projectPluginView(0)
m_ui.currentFolderButton->setIcon(KIcon("view-refresh"));
m_ui.newTabButton->setIcon(KIcon("tab-new"));
m_ui.filterCombo->setToolTip(i18n("Comma separated list of file types to search in. example: \"*.cpp,*.h\"\n"
"NOTE: Put a minus sign ('-') in front of an element to exclude those files and directories. example: \"*.cpp,*.h,-build*\""));
m_ui.filterCombo->setToolTip(i18n("Comma separated list of file types to search in. Example: \"*.cpp,*.h\"\n"));
m_ui.excludeCombo->setToolTip(i18n("Comma separated list of files and directories to exclude from the search. Example: \"build*\""));
int padWidth = m_ui.folderLabel->sizeHint().width();
padWidth = qMax(padWidth, m_ui.filterLabel->sizeHint().width());
......@@ -226,6 +226,7 @@ m_projectPluginView(0)
connect(m_ui.currentFolderButton, SIGNAL(clicked()), this, SLOT(setCurrentFolder()));
connect(m_ui.filterCombo, SIGNAL(returnPressed()), this, SLOT(startSearch()));
connect(m_ui.excludeCombo, SIGNAL(returnPressed()), this, SLOT(startSearch()));
connect(m_ui.displayOptions, SIGNAL(toggled(bool)), this, SLOT(toggleOptions(bool)));
connect(m_ui.searchPlaceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(searchPlaceChanged()));
......@@ -389,6 +390,10 @@ void KatePluginSearchView::startSearch()
m_ui.filterCombo->insertItem(0, m_ui.filterCombo->currentText());
m_ui.filterCombo->setCurrentIndex(0);
}
if(m_ui.excludeCombo->findText(m_ui.excludeCombo->currentText()) == -1) {
m_ui.excludeCombo->insertItem(0, m_ui.excludeCombo->currentText());
m_ui.excludeCombo->setCurrentIndex(0);
}
m_curResults = qobject_cast<Results *>(m_ui.resultTabWidget->currentWidget());
if (!m_curResults) {
kWarning() << "This is a bug";
......@@ -428,6 +433,7 @@ void KatePluginSearchView::startSearch()
m_ui.symLinkCheckBox->isChecked(),
m_ui.binaryCheckBox->isChecked(),
m_ui.filterCombo->currentText(),
m_ui.excludeCombo->currentText(),
reg);
} else {
/**
......@@ -860,6 +866,9 @@ void KatePluginSearchView::readSessionConfig(KConfigBase* config, const QString&
m_ui.filterCombo->clear();
m_ui.filterCombo->addItems(cg.readEntry("Filters", QStringList()));
m_ui.filterCombo->setCurrentIndex(cg.readEntry("CurrentFilter", 0));
m_ui.excludeCombo->clear();
m_ui.excludeCombo->addItems(cg.readEntry("ExcludeFilters", QStringList()));
m_ui.excludeCombo->setCurrentIndex(cg.readEntry("CurrentExcludeFilter", 0));
}
void KatePluginSearchView::writeSessionConfig(KConfigBase* config, const QString& groupPrefix)
......@@ -887,6 +896,13 @@ void KatePluginSearchView::writeSessionConfig(KConfigBase* config, const QString
}
cg.writeEntry("Filters", filterItems);
cg.writeEntry("CurrentFilter", m_ui.filterCombo->currentIndex());
QStringList excludeFilterItems;
for (int i=0; i<qMin(m_ui.excludeCombo->count(), 10); i++) {
excludeFilterItems << m_ui.excludeCombo->itemText(i);
}
cg.writeEntry("ExcludeFilters", excludeFilterItems);
cg.writeEntry("CurrentExcludeFilter", m_ui.excludeCombo->currentIndex());
}
void KatePluginSearchView::addTab()
......
......@@ -158,7 +158,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QCheckBox" name="recursiveCheckBox">
<property name="text">
<string>Recursive</string>
......@@ -168,14 +168,14 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QCheckBox" name="hiddenCheckBox">
<property name="text">
<string>Include hidden</string>
</property>
</widget>
</item>
<item row="3" column="5">
<item row="4" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -188,20 +188,34 @@
</property>
</spacer>
</item>
<item row="3" column="3">
<item row="4" column="3">
<widget class="QCheckBox" name="symLinkCheckBox">
<property name="text">
<string>Follow symbolic links</string>
</property>
</widget>
</item>
<item row="3" column="4">
<item row="4" column="4">
<widget class="QCheckBox" name="binaryCheckBox">
<property name="text">
<string>Include binary files</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="excludeLabel">
<property name="text">
<string>Exclude</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="7">
<widget class="KComboBox" name="excludeCombo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -393,6 +407,7 @@
<tabstop>folderUpButton</tabstop>
<tabstop>currentFolderButton</tabstop>
<tabstop>filterCombo</tabstop>
<tabstop>excludeCombo</tabstop>
<tabstop>recursiveCheckBox</tabstop>
<tabstop>hiddenCheckBox</tabstop>
<tabstop>symLinkCheckBox</tabstop>
......
......@@ -34,6 +34,7 @@ void SearchFolder::startSearch(const QString &folder,
bool symlinks,
bool binary,
const QString &types,
const QString &excludes,
const QRegExp &regexp)
{
m_cancelSearch = false;
......@@ -43,19 +44,14 @@ void SearchFolder::startSearch(const QString &folder,
m_binary = binary;
m_folder = folder;
m_regExp = regexp;
m_excludeList.clear();
m_types = types.split(',');
for (int i=0; i<m_types.size(); i++) {
if (m_types[i].startsWith('-')) {
m_types[i].remove(0, 1);
QRegExp rx(m_types[i]);
QStringList tmpExcludes = excludes.split(',');
m_excludeList.clear();
for (int i=0; i<tmpExcludes.size(); i++) {
QRegExp rx(tmpExcludes[i]);
rx.setPatternSyntax(QRegExp::Wildcard);
m_excludeList << rx;
m_types.removeAt(i);
i=0;
}
}
start();
......
......@@ -39,6 +39,7 @@ public:
bool symlinks,
bool binary,
const QString &types,
const QString &excludes,
const QRegExp &regexp);
void run();
......
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