Moved pruneSelectedDirs() from Klamscan to the widget class itself.

This makes more sense and will permit to use this method in other
scenarios.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/24/head
Mavridis Philippe 4 years ago
parent 6e18c223b2
commit 3747174d78
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -472,6 +472,60 @@ DeviceItem::mountDevice( const TQString & device)
}
}
TQStringList CollectionSetup::pruneSelectedDirs(){
// This gets rid of redundant sub-directories
// from the list of dirs to be scanned.
TQStringList filepattern;
TQStringList listOfUrls = dirs();
listOfUrls.sort();
TQString prev;
TQStringList prevdirs;
struct stat sb;
for (TQStringList::Iterator it = listOfUrls.begin(); it != listOfUrls.end(); it++ ){
//kdDebug() << "dir: " << (*it) << endl;
(*it) = (*it).stripWhiteSpace();
// replace block devices with mountpoints
lstat( (*it).ascii(), &sb );
if ( (sb.st_mode & S_IFMT) == S_IFBLK ) {
// This is actually from directorylist.cpp
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "properties", (*it) );
TQStringList properties;
reply.get( properties, "TQStringList" );
(*it) = * (properties.at(7) );
} else {
(*it) = (*it) + "/";
}
if (prevdirs.isEmpty()){
//kdDebug() << (*it) << endl;
filepattern.append(*it);
prevdirs.append((*it));
}else{
filepattern.append(*it);
bool shouldappend = true;
for (TQStringList::Iterator it2 = prevdirs.begin(); it2 != prevdirs.end(); it2++ ){
if ((*it).contains(*it2)){
//kdDebug() << (*it) << endl;
filepattern.remove((*it));
shouldappend = false;
break;
}
}
if (shouldappend)
prevdirs.append((*it));
}
}
return filepattern;
}
#include "directorylist.moc"

@ -22,6 +22,7 @@
#include <tqcheckbox.h> //inlined functions
#include <tqlistview.h> //baseclass
#include <tqvbox.h> //baseclass
#include <tqstringlist.h>
#include <kdirlister.h> //stack allocated
#include <kurl.h> //stack allocated
@ -47,6 +48,8 @@ public:
TQStringList m_dirs;
TQMap<TQString,int> m_refcount;
TQStringList pruneSelectedDirs();
signals:
void dirsSelected(TQStringList& dirs);

@ -253,7 +253,7 @@ void Klamscan::slotScan()
prevdir = listOfUrlsToScan.first();
}else{
filepattern = pruneSelectedDirs();
filepattern = setup->pruneSelectedDirs();
}
scan( filepattern );
@ -302,7 +302,7 @@ void Klamscan::slotAdvOptions(){
void Klamscan::slotSchedule(){
TQStringList filepattern = pruneSelectedDirs();
TQStringList filepattern = setup->pruneSelectedDirs();
if (filepattern.isEmpty()){
@ -470,61 +470,4 @@ void Klamscan::slotManageButtons(TQWidget * current){
}
TQStringList Klamscan::pruneSelectedDirs(){
//This gets rid of redundant sub-directories from the list of dirs to be scanned.
TQStringList filepattern;
TQStringList listOfUrlsToScan = setup->dirs();
listOfUrlsToScan.sort();
TQString prev;
TQStringList prevdirs;
struct stat sb;
for (TQStringList::Iterator it = listOfUrlsToScan.begin(); it != listOfUrlsToScan.end(); it++ ){
//kdDebug() << "dir: " << (*it) << endl;
(*it) = (*it).stripWhiteSpace();
// replace block devices with mountpoints
lstat( (*it).ascii(), &sb );
if ( (sb.st_mode & S_IFMT) == S_IFBLK ) {
// This is actually from directorylist.cpp
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "properties", (*it) );
TQStringList properties;
reply.get( properties, "TQStringList" );
(*it) = * (properties.at(7) );
} else {
(*it) = (*it) + "/";
}
if (prevdirs.isEmpty()){
//kdDebug() << (*it) << endl;
filepattern.append(*it);
prevdirs.append((*it));
}else{
filepattern.append(*it);
bool shouldappend = true;
for (TQStringList::Iterator it2 = prevdirs.begin(); it2 != prevdirs.end(); it2++ ){
if ((*it).contains(*it2)){
//kdDebug() << (*it) << endl;
filepattern.remove((*it));
shouldappend = false;
break;
}
}
if (shouldappend)
prevdirs.append((*it));
}
}
return filepattern;
}
#include "klamscan.moc"

@ -112,7 +112,6 @@ private slots:
void slotManageButtons(TQWidget *current);
private:
void setDefaults();
TQStringList pruneSelectedDirs();
TQLineEdit *template_edit;
TQComboBox *files_combo, *pattern_combo, *check_combo;
TQCheckBox *recursive_box;

Loading…
Cancel
Save