diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2015-01-30 16:44:45 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2015-01-30 16:44:45 +0900 |
commit | 23b906b576c51c02770bc9645c4b7291f5f3d6a7 (patch) | |
tree | f76f74ac49a49513a47a2c003e2113327a2d4072 /tdefilereplace/tdefilereplacepart.cpp | |
parent | 52c1190b1b96e88d17e1669993771192f1e3b724 (diff) | |
download | tdeutils-23b906b576c51c02770bc9645c4b7291f5f3d6a7.tar.gz tdeutils-23b906b576c51c02770bc9645c4b7291f5f3d6a7.zip |
Fixed maxDepth option in search-n-replace in TDEFileRelace. This relates to bug 1238.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdefilereplace/tdefilereplacepart.cpp')
-rw-r--r-- | tdefilereplace/tdefilereplacepart.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp index dc96db4..d4433b6 100644 --- a/tdefilereplace/tdefilereplacepart.cpp +++ b/tdefilereplace/tdefilereplacepart.cpp @@ -196,7 +196,7 @@ void TDEFileReplacePart::slotReplacingOperation() if(m_option->m_recursive) { int filesNumber = 0; - recursiveFileReplace(currentDirectory, filesNumber); + recursiveFileReplace(currentDirectory, filesNumber, 0); } else { @@ -967,10 +967,10 @@ void TDEFileReplacePart::fileReplace() } } -void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber) +void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber, int depth) { - //if m_stop == true then interrupts 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 { @@ -1001,12 +1001,17 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int m_view->displayScannedFiles(filesNumber); - //if filePath is a directory then recursion - if(qi.isDir()) - recursiveFileReplace(filePath, filesNumber); + // Replace recursively if "filePath" is a directory and we have not reached the max depth level + if (qi.isDir()) + { + if (!m_option->m_limitDepth || depth < m_option->m_maxDepth) + { + recursiveFileReplace(filePath, filesNumber, depth+1); + } + } else { - kapp->processEvents(); + kapp->processEvents(); if(m_option->m_backup) replaceAndBackup(d.canonicalPath(), fileName); else |