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 | |
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')
-rw-r--r-- | tdefilereplace/tdefilereplacepart.cpp | 21 | ||||
-rw-r--r-- | tdefilereplace/tdefilereplacepart.h | 2 |
2 files changed, 14 insertions, 9 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 diff --git a/tdefilereplace/tdefilereplacepart.h b/tdefilereplace/tdefilereplacepart.h index ee5352d..579f7ab 100644 --- a/tdefilereplace/tdefilereplacepart.h +++ b/tdefilereplace/tdefilereplacepart.h @@ -133,7 +133,7 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart * Replacing methods */ void fileReplace(); - void recursiveFileReplace(const TQString& dirName, int& filesNumber); + void recursiveFileReplace(const TQString& dirName, int& filesNumber, int depth); void replaceAndBackup(const TQString& currentDir, const TQString& oldFileName); void replaceAndOverwrite(const TQString& currentDir, const TQString& oldFileName); void replacingLoop(TQString& line, TDEListViewItem** item, bool& atLeastOneStringFound, int& occur, bool regularExpression, bool& askConfirmReplace); |