summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/tdefilereplacepart.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2015-01-29 13:24:20 +0900
committerMichele Calgaro <[email protected]>2015-01-29 13:24:20 +0900
commit570104ceed8613903f249f2e5768c5cceb6f0012 (patch)
tree50f4806b7a615ec7f92cd27b7d5c5df56f569eaa /tdefilereplace/tdefilereplacepart.cpp
parent08f2b5848ddd09e0da7e2d42a8743f0b40f1c717 (diff)
downloadtdeutils-570104ceed8613903f249f2e5768c5cceb6f0012.tar.gz
tdeutils-570104ceed8613903f249f2e5768c5cceb6f0012.zip
Added 'max depth' search option to TDEFileReplace. This resolves bug 1238.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdefilereplace/tdefilereplacepart.cpp')
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index 008198e..dc96db4 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -130,7 +130,7 @@ void TDEFileReplacePart::slotSearchingOperation()
uint filesNumber = 0;
if(m_option->m_recursive)
- recursiveFileSearch(currentDirectory, currentFilter, filesNumber);
+ recursiveFileSearch(currentDirectory, currentFilter, filesNumber, 0);
else
fileSearch(currentDirectory, currentFilter);
@@ -687,6 +687,8 @@ void TDEFileReplacePart::loadOptions()
m_option->m_encoding = m_config->readEntry(rcEncoding, EncodingOption);
m_option->m_recursive = m_config->readBoolEntry(rcRecursive, RecursiveOption);
+ m_option->m_limitDepth = m_config->readBoolEntry(rcLimitDepth, LimitDepthOption);
+ m_option->m_maxDepth = m_config->readNumEntry(rcMaxDepth, MaxDepthOption);
m_option->m_caseSensitive = m_config->readBoolEntry(rcCaseSensitive, CaseSensitiveOption);
m_option->m_variables = m_config->readBoolEntry(rcVariables, VariablesOption);
@@ -822,6 +824,8 @@ void TDEFileReplacePart::saveOptions()
m_config->writeEntry(rcEncoding, m_option->m_encoding);
m_config->writeEntry(rcRecursive, m_option->m_recursive);
+ m_config->writeEntry(rcLimitDepth, m_option->m_limitDepth);
+ m_config->writeEntry(rcMaxDepth, m_option->m_maxDepth);
m_config->writeEntry(rcCaseSensitive, m_option->m_caseSensitive);
m_config->writeEntry(rcVariables, m_option->m_variables);
m_config->writeEntry(rcRegularExpressions, m_option->m_regularExpressions);
@@ -1281,10 +1285,11 @@ void TDEFileReplacePart::fileSearch(const TQString& directoryName, const TQStrin
}
}
-void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, const TQString& filters, uint& filesNumber)
+void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, const TQString& filters,
+ uint& filesNumber, int depth)
{
- // if m_stop == true then interrupt recursion
- if(m_stop)
+ // if m_stop == true or the max depth level is reached, then interrupt recursion
+ if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth))
return;
else
{
@@ -1313,9 +1318,14 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
m_view->displayScannedFiles(filesNumber);
- // Searchs recursively if "filePath" is a directory
- if(fileInfo.isDir())
- recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber);
+ // Searchs recursively if "filePath" is a directory and we have not reached the max depth level
+ if (fileInfo.isDir())
+ {
+ if (!m_option->m_limitDepth || depth < m_option->m_maxDepth)
+ {
+ recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber, depth+1);
+ }
+ }
else
{
kapp->processEvents();