summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp169
-rw-r--r--tdefilereplace/tdefilereplacepart.h8
-rw-r--r--tdefilereplace/tdefilereplaceview.cpp6
-rw-r--r--tdefilereplace/tdefilereplaceview.h2
-rw-r--r--tdefilereplace/tdefilereplaceviewwdg.ui33
5 files changed, 131 insertions, 87 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index e3f1c42..f9aec23 100644
--- a/tdefilereplace/tdefilereplacepart.cpp
+++ b/tdefilereplace/tdefilereplacepart.cpp
@@ -131,12 +131,12 @@ void TDEFileReplacePart::slotSearchingOperation()
m_view->showSemaphore("red");
- uint filesNumber = 0;
-
if(m_option->m_recursive)
{
+ int foldersNumber = 0;
+ int filesNumber = 0;
m_circ_ref_warning_shown = false;
- recursiveFileSearch(currentDirectory, currentFilter, filesNumber, 0);
+ recursiveFileSearch(currentDirectory, currentFilter, foldersNumber, filesNumber, 0);
}
else
fileSearch(currentDirectory, currentFilter);
@@ -202,9 +202,10 @@ void TDEFileReplacePart::slotReplacingOperation()
if(m_option->m_recursive)
{
+ int foldersNumber = 0;
int filesNumber = 0;
m_circ_ref_warning_shown = false;
- recursiveFileReplace(currentDirectory, filesNumber, 0);
+ recursiveFileReplace(currentDirectory, foldersNumber, filesNumber, 0);
}
else
{
@@ -951,7 +952,7 @@ void TDEFileReplacePart::fileReplace()
TQStringList::iterator filesIt;
int filesNumber = 0;
- m_view->displayScannedFiles(filesNumber);
+ m_view->displayScannedFiles(0, filesNumber);
for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
{
@@ -971,11 +972,13 @@ void TDEFileReplacePart::fileReplace()
replaceAndOverwrite(d.canonicalPath(), fileName);
filesNumber++;
- m_view->displayScannedFiles(filesNumber);
+ m_view->displayScannedFiles(0, filesNumber);
}
+ m_view->displayScannedFiles(1, filesNumber);
}
-void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber, int depth)
+void TDEFileReplacePart::recursiveFileReplace(const TQString &directoryName, int &foldersNumber, int &filesNumber,
+ int depth)
{
// 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))
@@ -993,55 +996,55 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
}
return;
}
- else
- {
- TQDir d(directoryName);
-
- d.setMatchAllDirs(true);
- d.setFilter(m_optionMask);
-
- TQString currentFilter = m_option->m_filters[0];
- TQStringList filesList = d.entryList(currentFilter);
- TQStringList::iterator filesIt;
+
+ TQDir d(directoryName);
- for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
- {
- if(m_stop)
- break;
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
- TQString fileName = (*filesIt);
+ TQString currentFilter = m_option->m_filters[0];
+ TQStringList filesList = d.entryList(currentFilter);
+ TQStringList::iterator filesIt;
- // Avoids files that not match requirements
- if(!TDEFileReplaceLib::isAnAccessibleFile(d.canonicalPath(),fileName, m_option))
- continue;
+ for (filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
+ {
+ if (m_stop)
+ break;
- TQString filePath = d.canonicalPath()+"/"+fileName;
+ TQString fileName = (*filesIt);
+ // Avoids files that not match requirements
+ if(!TDEFileReplaceLib::isAnAccessibleFile(d.canonicalPath(), fileName, m_option))
+ continue;
- TQFileInfo qi(filePath);
+ TQString filePath = d.canonicalPath()+"/"+fileName;
- m_view->displayScannedFiles(filesNumber);
+ TQFileInfo qi(filePath);
- kapp->processEvents();
- // 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
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
+ kapp->processEvents();
+
+ // 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)
{
- if(m_option->m_backup)
- replaceAndBackup(d.canonicalPath(), fileName);
- else
- replaceAndOverwrite(d.canonicalPath(), fileName);
-
- filesNumber++;
- m_view->displayScannedFiles(filesNumber);
+ recursiveFileReplace(filePath, foldersNumber, filesNumber, depth+1);
}
+ }
+ else
+ {
+ if(m_option->m_backup)
+ replaceAndBackup(d.canonicalPath(), fileName);
+ else
+ replaceAndOverwrite(d.canonicalPath(), fileName);
+
+ filesNumber++;
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
}
}
+
+ foldersNumber++;
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
}
void TDEFileReplacePart::replaceAndBackup(const TQString& currentDir, const TQString& oldFileName)
@@ -1286,7 +1289,7 @@ void TDEFileReplacePart::fileSearch(const TQString& directoryName, const TQStrin
TQStringList::iterator filesIt;
uint filesNumber = 0;
- m_view->displayScannedFiles(filesNumber);
+ m_view->displayScannedFiles(0, filesNumber);
for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
{
@@ -1306,12 +1309,13 @@ void TDEFileReplacePart::fileSearch(const TQString& directoryName, const TQStrin
kapp->processEvents();
search(filePath, fileName);
filesNumber++;
- m_view->displayScannedFiles(filesNumber);
+ m_view->displayScannedFiles(0, filesNumber);
}
+ m_view->displayScannedFiles(1, filesNumber);
}
-void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, const TQString& filters,
- uint& filesNumber, int depth)
+void TDEFileReplacePart::recursiveFileSearch(const TQString &directoryName, const TQString &filters,
+ int &foldersNumber, int &filesNumber, int depth)
{
// 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))
@@ -1329,49 +1333,50 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
}
return;
}
- else
- {
- TQDir d(directoryName);
+
+ TQDir d(directoryName);
- d.setMatchAllDirs(true);
- d.setFilter(m_optionMask);
+ d.setMatchAllDirs(true);
+ d.setFilter(m_optionMask);
- TQStringList filesList = d.entryList(filters);
- TQString filePath = d.canonicalPath();
- TQStringList::iterator filesIt;
+ TQStringList filesList = d.entryList(filters);
+ TQString filePath = d.canonicalPath();
+ TQStringList::iterator filesIt;
- for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
- {
- if(m_stop)
- break;
+ for (filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt)
+ {
+ if (m_stop)
+ break;
- TQString fileName = (*filesIt);
- // Avoids files that not match
- if(!TDEFileReplaceLib::isAnAccessibleFile(filePath, fileName, m_option))
- continue;
+ TQString fileName = (*filesIt);
+ // Avoids files that not match
+ if (!TDEFileReplaceLib::isAnAccessibleFile(filePath, fileName, m_option))
+ continue;
- // Composes file path string
- TQFileInfo fileInfo(filePath+"/"+fileName);
+ // Composes file path string
+ TQFileInfo fileInfo(filePath+"/"+fileName);
- m_view->displayScannedFiles(filesNumber);
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
- kapp->processEvents();
- // 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();
+ // 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)
{
- search(filePath, fileName);
- filesNumber++;
- m_view->displayScannedFiles(filesNumber);
+ recursiveFileSearch(filePath+"/"+fileName, filters, foldersNumber, filesNumber, depth+1);
}
- }
+ }
+ else
+ {
+ search(filePath, fileName);
+ filesNumber++;
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
+ }
}
+
+ foldersNumber++;
+ m_view->displayScannedFiles(foldersNumber, filesNumber);
}
void TDEFileReplacePart::search(const TQString& currentDir, const TQString& fileName)
diff --git a/tdefilereplace/tdefilereplacepart.h b/tdefilereplace/tdefilereplacepart.h
index 34a91da..27ad916 100644
--- a/tdefilereplace/tdefilereplacepart.h
+++ b/tdefilereplace/tdefilereplacepart.h
@@ -134,16 +134,18 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart
* Replacing methods
*/
void fileReplace();
- void recursiveFileReplace(const TQString& dirName, int& filesNumber, int depth);
+ void recursiveFileReplace(const TQString &directoryName, int &foldersNumber, 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);
+ void replacingLoop(TQString& line, TDEListViewItem** item, bool& atLeastOneStringFound, int& occur,
+ bool regularExpression, bool& askConfirmReplace);
/**
* Searching methods
*/
void fileSearch(const TQString& dirName, const TQString& filters);
- void recursiveFileSearch(const TQString& dirName, const TQString& filters, uint& filesNumber, int depth);
+ void recursiveFileSearch(const TQString &dirName, const TQString &filters, int &foldersNumber,
+ int &filesNumber, int depth);
void search(const TQString& currentDir, const TQString& fileName);
/**
diff --git a/tdefilereplace/tdefilereplaceview.cpp b/tdefilereplace/tdefilereplaceview.cpp
index 3dcbe79..4bf7319 100644
--- a/tdefilereplace/tdefilereplaceview.cpp
+++ b/tdefilereplace/tdefilereplaceview.cpp
@@ -111,6 +111,12 @@ void TDEFileReplaceView::showSemaphore(TQString s)
}
}
+void TDEFileReplaceView::displayScannedFiles(int foldersNumber, int filesNumber)
+{
+ m_lcdFoldersNumber->display(TQString::number(foldersNumber,10));
+ m_lcdFilesNumber->display(TQString::number(filesNumber,10));
+}
+
void TDEFileReplaceView::stringsInvert(bool invertAll)
{
TQListViewItem* lviCurItem,
diff --git a/tdefilereplace/tdefilereplaceview.h b/tdefilereplace/tdefilereplaceview.h
index 6081347..6eae3d4 100644
--- a/tdefilereplace/tdefilereplaceview.h
+++ b/tdefilereplace/tdefilereplaceview.h
@@ -64,7 +64,7 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
public:
TQString currentPath();
void showSemaphore(TQString s);
- void displayScannedFiles(int filesNumber) { m_lcdFilesNumber->display(TQString::number(filesNumber,10)); }
+ void displayScannedFiles(int foldersNumber, int filesNumber);
void stringsInvert(bool invertAll);
void changeView(bool searchingOnlyMode);
TDEListView* getResultsView();
diff --git a/tdefilereplace/tdefilereplaceviewwdg.ui b/tdefilereplace/tdefilereplaceviewwdg.ui
index f7aaf87..297d06e 100644
--- a/tdefilereplace/tdefilereplaceviewwdg.ui
+++ b/tdefilereplace/tdefilereplaceviewwdg.ui
@@ -506,11 +506,42 @@
<cstring>unnamed</cstring>
</property>
<widget class="TQLabel">
+ <property name="name">
+ <cstring>m_tlFoldersNumber</cstring>
+ </property>
+ <property name="text">
+ <string>Scanned folders:</string>
+ </property>
+ </widget>
+ <widget class="TQLCDNumber">
+ <property name="name">
+ <cstring>m_lcdFoldersNumber</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>LineEditPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <property name="numDigits">
+ <number>7</number>
+ </property>
+ <property name="mode">
+ <enum>Dec</enum>
+ </property>
+ <property name="segmentStyle">
+ <enum>Flat</enum>
+ </property>
+ <property name="intValue" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="TQLabel">
<property name="name">
<cstring>m_tlFilesNumber</cstring>
</property>
<property name="text">
- <string>Scanned files:</string>
+ <string>Files:</string>
</property>
</widget>
<widget class="TQLCDNumber">