FileFinder::FileFinder() :
m_lines(0),
m_patterns(),
+ m_antiPatterns(),
m_minSize(0),
m_maxSize(-1),
m_youngerThan(),
}
/**
* Returns the type of the file.
+ *
* @param info the file info
* @return a string describing the text
*/
-QString typeOf(QFileInfo& info){
+QString typeOf(const QFileInfo& info){
QString rc;
if (info.isSymLink()){
if (info.isDir())
entries = dir.entryInfoList(filters, QDir::NoSort);
else
entries = dir.entryInfoList(m_patterns, filters, QDir::NoSort);
- QList <QFileInfo>::iterator it;
QString relativePath = ReQStringUtil::nativePath(
path.mid(1 + m_baseDir.length()));
QString node, ext;
-
+ QList<QRegExp*> antiPatterns;
+ QStringList::const_iterator it3;
+ for (it3 = m_antiPatterns.begin(); it3 != m_antiPatterns.end(); ++it3){
+ QString pattern(*it3);
+ antiPatterns.append(new QRegExp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard));
+ }
+ QList<QRegExp*>::const_iterator it2;
+ QList <QFileInfo>::const_iterator it;
for (it = entries.begin(); it != entries.end(); ++it){
node = it->fileName();
if (node == "." || node == "..")
continue;
+ bool ignore = false;
+ for (it2 = antiPatterns.begin(); it2 != antiPatterns.end(); ++it2){
+ if ((*it2)->indexIn(node) >= 0){
+ ignore = true;
+ break;
+ }
+ }
+ if (ignore)
+ continue;
if (depth >= m_minDepth && isValid(*it)){
if (m_lines >= table->rowCount()){
table->setRowCount(m_lines + 500);
m_lines++;
}
}
+ for (it2 = antiPatterns.begin(); it2 != antiPatterns.end(); ++it2){
+ delete *it2;
+ }
if (depth < m_maxDepth || m_maxDepth < 0){
entries = dir.entryInfoList(
QDir::NoSymLinks | QDir::NoDotAndDotDot | QDir::AllDirs, QDir::NoSort);
* @param patterns the patterns to set
*/
void FileFinder::setPatterns(const QStringList& patterns){
- m_patterns = patterns;
+ m_patterns.clear();
+ m_antiPatterns.clear();
+ QStringList::const_iterator it;
+ for (it = patterns.begin(); it != patterns.end(); ++it){
+ QString pattern = *it;
+ if (pattern.startsWith("-")){
+ if (pattern.length() > 1)
+ m_antiPatterns.append(pattern.mid(1));
+ } else {
+ if (pattern.length() > 0)
+ m_patterns.append(pattern);
+ }
+ }
}
/**
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxFilePatterns">
<property name="toolTip">
- <string><html><head/><body><p>A comma (',') separated list of filename patterns</p><p>Example: *.txt,*.odt</p></body></html></string>
+ <string><html><head/><body><p>A comma (',') separated list of filename patterns. A prefix of '-' means inversion: if a filename matches it will not be found.</p><p>Example: *.txt,*.odt</p></body></html></string>
</property>
<property name="editable">
<bool>true</bool>