From: Hamatoma Date: Thu, 24 Dec 2015 16:00:13 +0000 (+0100) Subject: ReFind: start/stop works X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=9274ccdffc4f149d7d7a2188799c566ca44e22b9;p=reqt ReFind: start/stop works * menu, toolbar and buttons for start/stop works now * exact value of "stop after" works now --- diff --git a/appl/refind/filefinder.cpp b/appl/refind/filefinder.cpp index a061a60..469221e 100644 --- a/appl/refind/filefinder.cpp +++ b/appl/refind/filefinder.cpp @@ -142,7 +142,7 @@ void FileFinder::fillTable(const QString& path, int depth){ } if (ignore) continue; - if (isInterruptionRequested()) + if (m_stop) break; if (depth >= m_minDepth && isValid(*it)){ bool isDir = it->isDir(); @@ -180,8 +180,7 @@ void FileFinder::fillTable(const QString& path, int depth){ for (it2 = antiPatterns.begin(); it2 != antiPatterns.end(); ++it2){ delete *it2; } - if (! isInterruptionRequested() - && (depth < m_maxDepth || m_maxDepth < 0) && m_maxHits > 0){ + if (! m_stop && (depth < m_maxDepth || m_maxDepth < 0) && m_maxHits > 0){ entries = dir.entryInfoList( QDir::NoSymLinks | QDir::NoDotAndDotDot | QDir::AllDirs, QDir::NoSort); bool filtered = m_excludedDirs.length() > 0; @@ -205,6 +204,7 @@ void FileFinder::run() */ void FileFinder::search(){ clock_t start = clock(); + setStop(false); m_statistics.clear(); QString path = ReFileUtils::nativePath(m_baseDir); path = ReQStringUtils::chomp(path, OS_SEPARATOR); @@ -264,6 +264,16 @@ bool FileFinder::isValid(const QFileInfo& file){ } return rc; } +/** + * Sets the stop flag. + * + * @param stop true: the file search must be stopped + */ +void FileFinder::setStop(bool stop) +{ + m_stop = stop; +} + /** * Sets the maximal hit count. diff --git a/appl/refind/filefinder.hpp b/appl/refind/filefinder.hpp index 0916cfe..188ebc3 100644 --- a/appl/refind/filefinder.hpp +++ b/appl/refind/filefinder.hpp @@ -40,10 +40,12 @@ public: void setObserver(ReObserver* observer); void setOlderThan(const QDateTime& olderThan); void setPatterns(const QStringList& patterns); + void setStop(bool stop); void setTable(QTableWidget* table); void setTextFinder(TextFinder* textFinder); void setYoungerThan(const QDateTime& youngerThan); const Statistics& statistics() const; + private: bool isExcludedDir(const QString& node); bool isValid(const QFileInfo& file); @@ -67,6 +69,7 @@ private: ReObserver* m_observer; ReGuiQueue* m_guiQueue; int m_maxHits; + bool m_stop; }; #endif // FILEFINDER_HPP diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index a8cfd2e..884e7ce 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -74,11 +74,13 @@ MainWindow::MainWindow(const QString& startDir, const QString& homeDir, ui->comboBoxDirectory->setCurrentText(QDir::currentPath()); ui->tableWidget->setMainWindow(this); statusBar()->addWidget(m_statusMessage); - connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search())); + connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(search())); connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(clear())); connect(ui->actionStop, SIGNAL(triggered()), this, SLOT(stop())); connect(ui->pushButtonSearch, SIGNAL(clicked()), this, SLOT(search())); connect(ui->pushButtonSearch2, SIGNAL(clicked()), this, SLOT(search())); + connect(ui->pushButtonStop, SIGNAL(clicked()), this, SLOT(stop())); + connect(ui->pushButtonStop2, SIGNAL(clicked()), this, SLOT(stop())); connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(clear())); connect(ui->actionUp, SIGNAL(triggered()), this, SLOT(up())); connect(ui->pushButtonUp, SIGNAL(clicked()), this, SLOT(up())); @@ -97,7 +99,6 @@ MainWindow::MainWindow(const QString& startDir, const QString& homeDir, connect(ui->actionGetFullName, SIGNAL(triggered()), this, SLOT(fullNameToClipboard())); connect(ui->actionReset, SIGNAL(triggered()), this, SLOT(resetParameters())); - connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(cellEntered(int, int))); connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportFiles())); connect(ui->pushButtonExport, SIGNAL(clicked()), this, SLOT(exportFiles())); connect(ui->pushButtonExportFile, SIGNAL(clicked()), this, @@ -942,7 +943,7 @@ bool MainWindow::say(ReLoggerLevel level, const QString& message){ * @param start true: the search should start */ void MainWindow::startStop(bool start){ - ui->actionSearch->setEnabled(!start); + ui->actionStart->setEnabled(!start); ui->actionStop->setEnabled(start); ui->pushButtonSearch->setEnabled(! start); ui->pushButtonSearch2->setEnabled(! start); @@ -954,7 +955,7 @@ void MainWindow::startStop(bool start){ * Handles the "search" button. */ void MainWindow::stop(){ - m_finder->requestInterruption(); + m_finder->setStop(true); startStop(false); } diff --git a/appl/refind/mainwindow.ui b/appl/refind/mainwindow.ui index 153a6ce..de51ca8 100644 --- a/appl/refind/mainwindow.ui +++ b/appl/refind/mainwindow.ui @@ -853,7 +853,7 @@ Size (MByte) - AlignTrailing|AlignBottom + AlignRight|AlignBottom @@ -893,8 +893,6 @@ &File - - @@ -940,8 +938,8 @@ - + @@ -952,7 +950,8 @@ false - + +