Commit 415b37da authored by Kåre Särs's avatar Kåre Särs

Add possibility to use filter exclude list in stead of include list

parent bb07cfa8
......@@ -181,6 +181,9 @@ m_curResults(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 the list to make it into an exclude list. example: \"-*.o,*.obj\""));
int padWidth = m_ui.folderLabel->width();
padWidth = qMax(padWidth, m_ui.filterLabel->width());
m_ui.gridLayout->setColumnMinimumWidth(0, padWidth);
......
......@@ -38,9 +38,23 @@ void SearchFolder::startSearch(const QString &folder,
m_recursive = recursive;
m_hidden = hidden;
m_symlinks = symlinks;
m_types = types.split(',');
m_folder = folder;
m_regExp = regexp;
m_excludeList.clear();
if (types.startsWith('-')) {
m_types = QStringList("*");
QString tmpStr = types;
QStringList tmpStrList((tmpStr.remove(0,1)).split(','));
for (int i=0; i<tmpStrList.size(); i++) {
QRegExp rx(tmpStrList[i]);
rx.setPatternSyntax(QRegExp::Wildcard);
m_excludeList << rx;
}
}
else {
m_types = types.split(',');
}
start();
}
......@@ -78,11 +92,21 @@ void SearchFolder::handleNextItem(const QFileInfo &item)
if (m_recursive) filter |= QDir::AllDirs;
if (!m_symlinks) filter |= QDir::NoSymLinks;
QFileInfoList currentItems = currentDir.entryInfoList (m_types, filter);
QFileInfoList currentItems = currentDir.entryInfoList(m_types, filter);
bool skip;
for (int i = 0; i<currentItems.size(); ++i) {
if (m_cancelSearch) return;
handleNextItem(currentItems[i]);
skip = false;
for (int j=0; j<m_excludeList.size(); j++) {
if (m_excludeList[j].exactMatch(currentItems[i].fileName())) {
skip = true;
break;
}
}
if (!skip) {
handleNextItem(currentItems[i]);
}
}
}
}
......
......@@ -54,13 +54,15 @@ private:
void searchFile(const QFileInfo &item);
private:
QRegExp m_regExp;
bool m_cancelSearch;
bool m_recursive;
bool m_hidden;
bool m_symlinks;
QStringList m_types;
QString m_folder;
QRegExp m_regExp;
bool m_cancelSearch;
bool m_recursive;
bool m_hidden;
bool m_symlinks;
QStringList m_types;
QString m_folder;
QVector<QRegExp> m_excludeList;
};
......
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