TDEFileReplace: added 'scanned folders' field in the status bar. This relates to bug 2264.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 10 years ago
parent d7398464a9
commit c9fa04f084

@ -131,12 +131,12 @@ void TDEFileReplacePart::slotSearchingOperation()
m_view->showSemaphore("red"); m_view->showSemaphore("red");
uint filesNumber = 0;
if(m_option->m_recursive) if(m_option->m_recursive)
{ {
int foldersNumber = 0;
int filesNumber = 0;
m_circ_ref_warning_shown = false; m_circ_ref_warning_shown = false;
recursiveFileSearch(currentDirectory, currentFilter, filesNumber, 0); recursiveFileSearch(currentDirectory, currentFilter, foldersNumber, filesNumber, 0);
} }
else else
fileSearch(currentDirectory, currentFilter); fileSearch(currentDirectory, currentFilter);
@ -202,9 +202,10 @@ void TDEFileReplacePart::slotReplacingOperation()
if(m_option->m_recursive) if(m_option->m_recursive)
{ {
int foldersNumber = 0;
int filesNumber = 0; int filesNumber = 0;
m_circ_ref_warning_shown = false; m_circ_ref_warning_shown = false;
recursiveFileReplace(currentDirectory, filesNumber, 0); recursiveFileReplace(currentDirectory, foldersNumber, filesNumber, 0);
} }
else else
{ {
@ -951,7 +952,7 @@ void TDEFileReplacePart::fileReplace()
TQStringList::iterator filesIt; TQStringList::iterator filesIt;
int filesNumber = 0; int filesNumber = 0;
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(0, filesNumber);
for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt) for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
{ {
@ -971,11 +972,13 @@ void TDEFileReplacePart::fileReplace()
replaceAndOverwrite(d.canonicalPath(), fileName); replaceAndOverwrite(d.canonicalPath(), fileName);
filesNumber++; 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 == true or the max depth level is reached, then interrupt recursion
if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth)) if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth))
@ -993,8 +996,7 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
} }
return; return;
} }
else
{
TQDir d(directoryName); TQDir d(directoryName);
d.setMatchAllDirs(true); d.setMatchAllDirs(true);
@ -1010,7 +1012,6 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
break; break;
TQString fileName = (*filesIt); TQString fileName = (*filesIt);
// Avoids files that not match requirements // Avoids files that not match requirements
if(!TDEFileReplaceLib::isAnAccessibleFile(d.canonicalPath(), fileName, m_option)) if(!TDEFileReplaceLib::isAnAccessibleFile(d.canonicalPath(), fileName, m_option))
continue; continue;
@ -1019,15 +1020,15 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
TQFileInfo qi(filePath); TQFileInfo qi(filePath);
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(foldersNumber, filesNumber);
kapp->processEvents(); kapp->processEvents();
// Replace recursively if "filePath" is a directory and we have not reached the max depth level // Replace recursively if "filePath" is a directory and we have not reached the max depth level
if (qi.isDir()) if (qi.isDir())
{ {
if (!m_option->m_limitDepth || depth < m_option->m_maxDepth) if (!m_option->m_limitDepth || depth < m_option->m_maxDepth)
{ {
recursiveFileReplace(filePath, filesNumber, depth+1); recursiveFileReplace(filePath, foldersNumber, filesNumber, depth+1);
} }
} }
else else
@ -1038,10 +1039,12 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
replaceAndOverwrite(d.canonicalPath(), fileName); replaceAndOverwrite(d.canonicalPath(), fileName);
filesNumber++; filesNumber++;
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(foldersNumber, filesNumber);
}
} }
} }
foldersNumber++;
m_view->displayScannedFiles(foldersNumber, filesNumber);
} }
void TDEFileReplacePart::replaceAndBackup(const TQString& currentDir, const TQString& oldFileName) void TDEFileReplacePart::replaceAndBackup(const TQString& currentDir, const TQString& oldFileName)
@ -1286,7 +1289,7 @@ void TDEFileReplacePart::fileSearch(const TQString& directoryName, const TQStrin
TQStringList::iterator filesIt; TQStringList::iterator filesIt;
uint filesNumber = 0; uint filesNumber = 0;
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(0, filesNumber);
for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt) for (filesIt = filesList.begin(); filesIt != filesList.end() ; ++filesIt)
{ {
@ -1306,12 +1309,13 @@ void TDEFileReplacePart::fileSearch(const TQString& directoryName, const TQStrin
kapp->processEvents(); kapp->processEvents();
search(filePath, fileName); search(filePath, fileName);
filesNumber++; filesNumber++;
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(0, filesNumber);
} }
m_view->displayScannedFiles(1, filesNumber);
} }
void TDEFileReplacePart::recursiveFileSearch(const TQString &directoryName, const TQString &filters, void TDEFileReplacePart::recursiveFileSearch(const TQString &directoryName, const TQString &filters,
uint& filesNumber, int depth) int &foldersNumber, int &filesNumber, int depth)
{ {
// if m_stop == true or the max depth level is reached, then interrupt recursion // 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)) if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth))
@ -1329,8 +1333,7 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
} }
return; return;
} }
else
{
TQDir d(directoryName); TQDir d(directoryName);
d.setMatchAllDirs(true); d.setMatchAllDirs(true);
@ -1353,7 +1356,7 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
// Composes file path string // Composes file path string
TQFileInfo fileInfo(filePath+"/"+fileName); TQFileInfo fileInfo(filePath+"/"+fileName);
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(foldersNumber, filesNumber);
kapp->processEvents(); kapp->processEvents();
// Searchs recursively if "filePath" is a directory and we have not reached the max depth level // Searchs recursively if "filePath" is a directory and we have not reached the max depth level
@ -1361,17 +1364,19 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
{ {
if (!m_option->m_limitDepth || depth < m_option->m_maxDepth) if (!m_option->m_limitDepth || depth < m_option->m_maxDepth)
{ {
recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber, depth+1); recursiveFileSearch(filePath+"/"+fileName, filters, foldersNumber, filesNumber, depth+1);
} }
} }
else else
{ {
search(filePath, fileName); search(filePath, fileName);
filesNumber++; filesNumber++;
m_view->displayScannedFiles(filesNumber); m_view->displayScannedFiles(foldersNumber, filesNumber);
}
} }
} }
foldersNumber++;
m_view->displayScannedFiles(foldersNumber, filesNumber);
} }
void TDEFileReplacePart::search(const TQString& currentDir, const TQString& fileName) void TDEFileReplacePart::search(const TQString& currentDir, const TQString& fileName)

@ -134,16 +134,18 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart
* Replacing methods * Replacing methods
*/ */
void fileReplace(); 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 replaceAndBackup(const TQString& currentDir, const TQString& oldFileName);
void replaceAndOverwrite(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 * Searching methods
*/ */
void fileSearch(const TQString& dirName, const TQString& filters); 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); void search(const TQString& currentDir, const TQString& fileName);
/** /**

@ -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) void TDEFileReplaceView::stringsInvert(bool invertAll)
{ {
TQListViewItem* lviCurItem, TQListViewItem* lviCurItem,

@ -64,7 +64,7 @@ class TDEFileReplaceView : public TDEFileReplaceViewWdg
public: public:
TQString currentPath(); TQString currentPath();
void showSemaphore(TQString s); 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 stringsInvert(bool invertAll);
void changeView(bool searchingOnlyMode); void changeView(bool searchingOnlyMode);
TDEListView* getResultsView(); TDEListView* getResultsView();

@ -505,12 +505,43 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </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"> <widget class="TQLabel">
<property name="name"> <property name="name">
<cstring>m_tlFilesNumber</cstring> <cstring>m_tlFilesNumber</cstring>
</property> </property>
<property name="text"> <property name="text">
<string>Scanned files:</string> <string>Files:</string>
</property> </property>
</widget> </widget>
<widget class="TQLCDNumber"> <widget class="TQLCDNumber">

Loading…
Cancel
Save