#include "Worker.h" #include #include #include Worker::Worker(QObject *parent) : QObject(parent){ //Get the list of all applications and save them in an easily-searchable form XDGDesktopList APPS; APPS.updateList(); QList apps = APPS.apps(false,false); for(int i=0; iname+":::2:::"+apps[i]->genericName+":::3:::"+apps[i]->comment+":::4:::"+apps[i]->filePath; } stopsearch = false; } Worker::~Worker(){ stopsearch = true; } void Worker::StartSearch(QString term, bool isApp){ sterm=term; sapp=isApp; if(stopsearch){ //Need to stop the current search first - give it a moment first QTimer::singleShot(100,this, SLOT(beginsearch()) ); }else{ //Start immediately QTimer::singleShot(0,this, SLOT(beginsearch()) ); } } void Worker::StopSearch(){ stopsearch = true; } bool Worker::searchDir(QString dirpath){ //This is a recursive search algorithm for scanning a directory QDir dir(dirpath); //First look for files that match the search term if(stopsearch){ return true; } emit SearchUpdate( QString(tr("Searching: %1")).arg(dirpath.replace(QDir::homePath(),"~")) ); QStringList tmp; if(sterm.startsWith(".")){ tmp = dir.entryList(QStringList(sterm), QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden, QDir::Name); } else{ tmp = dir.entryList(QStringList(sterm), QDir::AllEntries | QDir::NoDotAndDotDot , QDir::Name); } for(int i=0; i