From: Hamatoma Date: Tue, 29 Nov 2016 01:19:42 +0000 (+0100) Subject: ReSearch: single files work, timer task X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=0996e5cc539e040d2da18db0ca18a24d17a145ec;p=reqt ReSearch: single files work, timer task --- diff --git a/appl/research/filefilter.cpp b/appl/research/filefilter.cpp index 68a8ecc..adccf56 100644 --- a/appl/research/filefilter.cpp +++ b/appl/research/filefilter.cpp @@ -39,13 +39,13 @@ FileFilter::~FileFilter() * @param includePattern regular expression to find lines to filter * @param excludePattern regular expression to prevent lines from filtering * @param fromHit first hit which is visible in the list - * @param toHit the filtering stops behind this hit + * @param pageSize the filtering stops behind this hit * @param linesAbove number of lines above the hit which will put into the list * @param linesBelow number of lines below the hit which will put into the list */ void FileFilter::filter(const QString &includePattern, const QString &excludePattern, - int fromHit, int toHit, + int fromHit, int pageSize, int linesAbove, int linesBelow, bool caseSensitive) { @@ -54,7 +54,7 @@ void FileFilter::filter(const QString &includePattern, int fileCount = m_table.rowCount(); m_list.clear(); m_fromHit = fromHit; - m_toHit = toHit; + m_toHit = fromHit + pageSize - 1; m_linesAbove = linesAbove; m_linesBelow = linesBelow; delete m_includeExpr; @@ -66,7 +66,7 @@ void FileFilter::filter(const QString &includePattern, m_includeExpr = includePattern.isEmpty() ? NULL : new QRegularExpression(includePattern, option); m_excludeExpr = excludePattern.isEmpty() ? NULL : new QRegularExpression(excludePattern, option); - while (ixFile < fileCount - 1 && hitNo <= toHit){ + while (ixFile < fileCount - 1 && hitNo < m_toHit){ ++ixFile; QString full = m_table.item(ixFile, colPath)->text(); full += OS_SEPARATOR_STR; @@ -74,7 +74,9 @@ void FileFilter::filter(const QString &includePattern, hitNo = filterOneFile(full, hitNo); } - if (hitNo <= toHit){ + if (hitNo <= fromHit) + m_lastHitPosition.m_hitCount = 0; + else if (hitNo < m_toHit){ m_lastHitPosition.m_hitCount = m_lastHitPosition.m_hitNo; } } @@ -108,7 +110,7 @@ int FileFilter::filterOneFile(const QString& filename, int lastHit) lastHit = m_lastHitPosition.m_hitNo; lineNo = m_lastHitPosition.m_line; } - while(lastHit <= m_toHit && lineNo < lastIx){ + while(lastHit < m_toHit && lineNo < lastIx){ QString line = lines[++lineNo]; if (m_includeExpr != NULL && ! m_includeExpr->match(line).hasMatch()) continue; diff --git a/appl/research/filefinder.hpp b/appl/research/filefinder.hpp index 2b45ee2..f30e40a 100644 --- a/appl/research/filefinder.hpp +++ b/appl/research/filefinder.hpp @@ -11,6 +11,7 @@ public: void addToTable(const QString& full, const QString &path, const QString &node, const QFileInfo &info); void clear(); + void detachFromTable(const QString &full, const QString &path, const QString &node); int foundFiles() const; bool handleFile(const QString &full, const QString &path, const QString &node, const QFileInfo &info); @@ -21,7 +22,6 @@ public: void setTextToSearch(const QString &text, bool caseSensitive, bool isRegularExpression, bool inverseSearch); private: - void detachFromTable(const QString &full, const QString &path, const QString &node); bool searchWithRegExpr(const QString &filename); bool searchText(const QString &filename); private: diff --git a/appl/research/mainwindow.cpp b/appl/research/mainwindow.cpp index 581441e..252dec7 100644 --- a/appl/research/mainwindow.cpp +++ b/appl/research/mainwindow.cpp @@ -6,18 +6,22 @@ #include "QFileDialog" static const char* VERSION = "2016.11.26"; +static const int s_defaultPageSize = 10; MainWindow::MainWindow(QApplication& application, const QString& homeDir, QWidget *parent) : ReGuiApplication(application, "rsearch", homeDir, 2, 10100100, "de", parent), ReGuiValidator(), - ui(new Ui::MainWindow), - m_fileFinder(NULL), - m_fileCache(new FileCache()), - m_test(true), - m_lastHitPosition(new HitPosition()) + ui(new Ui::MainWindow), + m_fileFinder(NULL), + m_fileCache(new FileCache()), + m_test(true), + m_lastHitPosition(new HitPosition()), + m_currentTask(ttUndef), + m_timer(new QTimer(this)) { ReComboBox::setDefaultHistorySize(20); + m_timer->setSingleShot(true); initializeGui(); } @@ -27,9 +31,39 @@ MainWindow::MainWindow(QApplication& application, const QString& homeDir, MainWindow::~MainWindow() { delete ui; - delete m_fileCache; - delete m_fileFinder; - delete m_lastHitPosition; + delete m_fileCache; + delete m_fileFinder; + delete m_lastHitPosition; +} + +/** + * Adds a single file to the table. + * + * @param filename the filename with path + * @param yetFound IN/OUT: number of already found files.
+ * Will be incremented if the file exists and was already + * in the table + * @return 1: the file exists
+ * 0: fhe file does not exist + */ +int MainWindow::addSingleFile(bool addNotDetach, const QString& filename, int& alreadyFound) +{ + QFileInfo info(filename); + int rc = info.exists() ? 1 : 0; + if (rc) + { + QString path = info.absolutePath(); + QString node = info.baseName(); + QString full = info.absoluteFilePath(); + int ignoredFiles = m_fileFinder->ignoredFiles(); + if (addNotDetach) + m_fileFinder->addToTable(full, path, node, info); + else + m_fileFinder->detachFromTable(full, path, node); + if (m_fileFinder->ignoredFiles() - ignoredFiles > 0) + ++alreadyFound; + } + return rc; } /** @@ -41,14 +75,14 @@ MainWindow::~MainWindow() * @param defaultValue the value if the source value is invalid */ int MainWindow::comboboxToInt(QComboBox& combobox, int defaultValue){ - QString text = combobox.currentText(); - uint rc = 0; - if (ReQStringUtils::lengthOfUInt(text, 0, 10, &rc) != text.length()){ - say(LOG_ERROR, tr("not an integer: %1 using instead: %2").arg(text).arg(defaultValue)); - combobox.setCurrentText(QString::number(defaultValue)); - rc = (uint) defaultValue; - } - return (int) rc; + QString text = combobox.currentText(); + uint rc = 0; + if (ReQStringUtils::lengthOfUInt(text, 0, 10, &rc) != text.length()){ + say(LOG_ERROR, tr("not an integer: %1 using instead: %2").arg(text).arg(defaultValue)); + combobox.setCurrentText(QString::number(defaultValue)); + rc = (uint) defaultValue; + } + return (int) rc; } /** @@ -62,45 +96,47 @@ void MainWindow::initializeGui(){ connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(onAbout())); connect(ui->comboBoxBaseDirectory, SIGNAL(textEdited(const QString&, const QString&)), this, SLOT(textEdited(const QString&, const QString&))); - connect(ui->pushButtonSelectBase, SIGNAL(clicked()), this, SLOT(onSelectBaseDirectory())); - connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(onAdd())); - connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(onClear())); - connect(ui->pushButtonFilter, SIGNAL(clicked()), this, SLOT(onFilter())); - connect(ui->pushButtonDetach, SIGNAL(clicked()), this, SLOT(onDetach())); - connect(ui->pushButtonPrevious, SIGNAL(clicked()), this, SLOT(onPrevious())); - connect(ui->pushButtonNext, SIGNAL(clicked()), this, SLOT(onNext())); - - connect(ui->comboBoxExcludingPattern, SIGNAL(textEdited(QString,QString)), - this, SLOT(clearLastHitPosition(const QString&, const QString&))); - connect(ui->comboBoxIncludingPattern, SIGNAL(textEdited(QString,QString)), - this, SLOT(clearLastHitPosition(const QString&, const QString&))); - connect(ui->comboBoxLinesAbove, SIGNAL(textEdited(QString,QString)), - this, SLOT(clearLastHitPosition(const QString&, const QString&))); + connect(ui->pushButtonSelectBase, SIGNAL(clicked()), this, SLOT(onSelectBaseDirectory())); + connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(onAdd())); + connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(onClear())); + connect(ui->pushButtonFilter, SIGNAL(clicked()), this, SLOT(onFilter())); + connect(ui->pushButtonDetach, SIGNAL(clicked()), this, SLOT(onDetach())); + connect(ui->pushButtonPrevious, SIGNAL(clicked()), this, SLOT(onPrevious())); + connect(ui->pushButtonNext, SIGNAL(clicked()), this, SLOT(onNext())); + + connect(ui->comboBoxExcludingPattern, SIGNAL(textEdited(QString,QString)), + this, SLOT(clearLastHitPosition(const QString&, const QString&))); + connect(ui->comboBoxIncludingPattern, SIGNAL(textEdited(QString,QString)), + this, SLOT(clearLastHitPosition(const QString&, const QString&))); + connect(ui->comboBoxLinesAbove, SIGNAL(textEdited(QString,QString)), + this, SLOT(clearLastHitPosition(const QString&, const QString&))); connect(ui->comboBoxLinesBelow, SIGNAL(textEdited(QString,QString)), this, SLOT(clearLastHitPosition(const QString&, const QString&))); - delete m_fileFinder; - m_fileFinder = new FileFinder(*ui->tableWidget, *m_fileCache); + connect(ui->comboBoxFromHit, SIGNAL(textEdited(QString,QString)), + this, SLOT(onFromHitChanged(const QString&, const QString&))); - ui->tableWidget->setColumnWidth(colNode, 200); - ui->tableWidget->setColumnWidth(colSize, 125); - ui->tableWidget->setColumnWidth(colDate, 175); - switchFilter(true); - if (m_test){ - ui->comboBoxBaseDirectory->setCurrentText("/home/mhm/labor"); - ui->comboBoxFilePatterns->setCurrentText("big*.txt"); - ui->comboBoxIncludingPattern->setCurrentText("47"); - onAdd(); - } + connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTask())); + + delete m_fileFinder; + m_fileFinder = new FileFinder(*ui->tableWidget, *m_fileCache); + + ui->tableWidget->setColumnWidth(colNode, 200); + ui->tableWidget->setColumnWidth(colSize, 125); + ui->tableWidget->setColumnWidth(colDate, 175); + switchFilter(true); + if (m_test){ + ui->comboBoxBaseDirectory->setCurrentText("/home/mhm"); + } } /** * Writes the known number of hits into the label. */ void MainWindow::logHits(){ - if (m_lastHitPosition->m_hitCount >= 0) - ui->labelHits->setText(tr("%1 hit(s)").arg(m_lastHitPosition->m_hitCount)); - else - ui->labelHits->setText(tr(">= %1 hit(s)").arg(m_lastHitPosition->m_maxHitNo)); + if (m_lastHitPosition->m_hitCount >= 0) + ui->labelHits->setText(tr("%1 hit(s)").arg(m_lastHitPosition->m_hitCount)); + else + ui->labelHits->setText(tr(">= %1 hit(s)").arg(m_lastHitPosition->m_maxHitNo)); } /** @@ -108,10 +144,11 @@ void MainWindow::logHits(){ */ void MainWindow::clearLastHitPosition(const QString&, const QString&) { - m_lastHitPosition->m_filename.clear(); - m_lastHitPosition->m_hitCount = -1; - m_lastHitPosition->m_hitNo = -1; - m_lastHitPosition->m_maxHitNo = 0; + m_lastHitPosition->m_filename.clear(); + m_lastHitPosition->m_hitCount = -1; + m_lastHitPosition->m_hitNo = -1; + m_lastHitPosition->m_maxHitNo = 0; + switchFilter(true); } /** @@ -136,7 +173,23 @@ void MainWindow::onAboutToQuit() */ void MainWindow::onAdd() { - searchFiles(true); + switchFilter(true); + switchAdd(true); + m_currentTask = ttAdd; + m_timer->start(5); +} + +/** + * Handles the click of the "Add" button. + */ +void MainWindow::onAddTimer() +{ + if (ui->tabWidgetFileSearch->currentIndex() < 2){ + searchFiles(true); + } else { + searchSingleFile(true); + } + switchAdd(false); } /** @@ -144,7 +197,23 @@ void MainWindow::onAdd() */ void MainWindow::onDetach() { - searchFiles(false); + switchAdd(true); + switchFilter(true); + m_currentTask = ttDetach; + m_timer->start(5); +} + +/** + * Handles the click of the "Detach" button. + */ +void MainWindow::onDetachTimer() +{ + if (ui->tabWidgetFileSearch->currentIndex() < 2){ + searchFiles(false); + } else { + searchSingleFile(false); + } + switchAdd(false); } /** @@ -152,8 +221,9 @@ void MainWindow::onDetach() */ void MainWindow::onClear() { + switchFilter(true); m_fileFinder->clear(); - ui->labelFileCount->setText(""); + ui->labelFileCount->setText(""); } /** @@ -161,17 +231,25 @@ void MainWindow::onClear() */ void MainWindow::onFilter() { - FileFilter filter(*ui->tableWidget, *ui->listWidgetHits, *m_fileCache, - *m_lastHitPosition); - int from = comboboxToInt(*ui->comboBoxFromHit, 0); - int to = comboboxToInt(*ui->comboBoxToHit, from + 100); - int above = comboboxToInt(*ui->comboBoxLinesAbove, 0); - int below = comboboxToInt(*ui->comboBoxLinesBelow, 0); - - filter.filter(ui->comboBoxIncludingPattern->currentText(), - ui->comboBoxExcludingPattern->currentText(), - from, to, above, below, false); + qint64 start = QDateTime::currentMSecsSinceEpoch(); + FileFilter filter(*ui->tableWidget, *ui->listWidgetHits, *m_fileCache, + *m_lastHitPosition); + int from = comboboxToInt(*ui->comboBoxFromHit, 0); + int pageSize = comboboxToInt(*ui->comboBoxPageSize, s_defaultPageSize); + int above = comboboxToInt(*ui->comboBoxLinesAbove, 0); + int below = comboboxToInt(*ui->comboBoxLinesBelow, 0); + ui->pushButtonFilter->setEnabled(false); + filter.filter(ui->comboBoxIncludingPattern->currentText(), + ui->comboBoxExcludingPattern->currentText(), + from, pageSize, above, below, false); switchFilter(false); + int found = pageSize; + if (m_lastHitPosition->m_hitCount >= 0 + && m_lastHitPosition->m_hitCount - from < pageSize) + found = m_lastHitPosition->m_hitCount - from + 1; + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start; + say(LOG_INFO, tr("Found: %1 hit(s) in %2").arg(found) + .arg(ReQStringUtils::readableDuration(duration))); } /** @@ -181,6 +259,18 @@ void MainWindow::onGuiTimerUpdate() { } +/** + * Handles the event "changed text" of the field comboBoxFromHit. + * + * @param oldValue value before editing + * @param newValue value after editing + */ +void MainWindow::onFromHitChanged(const QString& oldValue, const QString& newValue) +{ + ReUseParameter(oldValue); + ReUseParameter(newValue); + ui->pushButtonFilter->setEnabled(true); +} /** * The language has been changed. @@ -195,26 +285,33 @@ void MainWindow::onLanguageChange() */ void MainWindow::onNext() { - int first = comboInt(ui->comboBoxFromHit, 1); - int last = comboInt(ui->comboBoxToHit, first + 100); - int pageSize = last - first + 1; - first = first + pageSize; - ui->comboBoxFromHit->setCurrentText(QString::number(first)); - ui->comboBoxToHit->setCurrentText(QString::number(first + pageSize - 1)); - onFilter(); + int first = comboInt(ui->comboBoxFromHit, 1); + int pageSize = comboInt(ui->comboBoxPageSize, s_defaultPageSize); + if (m_lastHitPosition->m_hitCount >= 0 + && first + pageSize > m_lastHitPosition->m_hitCount) + first = max(1, m_lastHitPosition->m_hitCount - 1); + else + first += pageSize; + ui->comboBoxFromHit->setCurrentText(QString::number(first)); + if (first != m_lastHitPosition->m_hitNo) + onFilter(); + if (m_lastHitPosition->m_hitCount >= 0 + && first + pageSize > m_lastHitPosition->m_hitCount) + ui->pushButtonNext->setEnabled(false); } /** * Shows the previous page of filtered lines. */ void MainWindow::onPrevious() { - int first = comboInt(ui->comboBoxFromHit, 1); - int last = comboInt(ui->comboBoxToHit, first + 100); - int pageSize = last - first + 1; - first = max(1, first - pageSize); - ui->comboBoxFromHit->setCurrentText(QString::number(first)); - ui->comboBoxToHit->setCurrentText(QString::number(first + pageSize - 1)); - onFilter(); + int first = comboInt(ui->comboBoxFromHit, 1); + int pageSize = comboInt(ui->comboBoxPageSize, s_defaultPageSize); + first = max(1, first - pageSize); + ui->comboBoxFromHit->setCurrentText(QString::number(first)); + onFilter(); + bool enabled = m_lastHitPosition->m_hitCount < 0 + || first < m_lastHitPosition->m_hitCount; + ui->pushButtonNext->setEnabled(enabled); } /** @@ -222,11 +319,31 @@ void MainWindow::onPrevious() */ void MainWindow::onSelectBaseDirectory(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"), - ui->comboBoxBaseDirectory->currentText(), QFileDialog::ShowDirsOnly); + ui->comboBoxBaseDirectory->currentText(), QFileDialog::ShowDirsOnly); if (!dir.isEmpty()) ui->comboBoxBaseDirectory->setCurrentText(ReFileUtils::nativePath(dir)); } +/** + * Does the timer task. + */ +void MainWindow::onTimerTask() +{ + switch(m_currentTask) + { + case ttAdd: + onAddTimer(); + break; + case ttDetach: + onDetachTimer(); + break; + case ttClear: + break; + default: + break; + } +} + /** * Writes a message. * @@ -247,32 +364,84 @@ bool MainWindow::say(ReLoggerLevel level, const QString& message){ */ void MainWindow::searchFiles(bool addNotDetach) { - QString base = ui->comboBoxBaseDirectory->currentText(); - if (base.isEmpty()){ - say(LOG_ERROR, tr("missing a base directory")); - } else { - QDateTime olderThan = comboDate(ui->comboBoxOlder); - QDateTime youngerThan = comboDate(ui->comboBoxYounger); - m_fileFinder->setOlderThan(olderThan.toMSecsSinceEpoch() <= 0 - ? NULL : new QDateTime(olderThan)); - m_fileFinder->setYoungerThan(olderThan.toMSecsSinceEpoch() <= 0 - ? NULL : new QDateTime(youngerThan)); - m_fileFinder->setTextToSearch(ui->comboBoxTextPattern->currentText(), - ui->checkBoxCaseSensitiv->isChecked(), - ui->checkBoxRegularExpr->isChecked(), - ui->checkBoxInverse->isChecked()); - m_fileFinder->setAddNotDetach(addNotDetach); - m_fileFinder->search(base, ui->comboBoxFilePatterns->currentText(), - atoi(ui->lineEditMinDepth->text().toLocal8Bit().data()), - atoi(ui->lineEditMaxDepth->text().toLocal8Bit().data())); - int files = ui->tableWidget->rowCount(); - ui->labelFileCount->setText(QString::number(files) - + " " + tr("file(s)")); - say(LOG_INFO, tr("files: %1 already found: %2 processed directories: %3") - .arg(m_fileFinder->foundFiles()) - .arg(m_fileFinder->ignoredFiles()) - .arg(m_fileFinder->processedDirs())); + QString base = ui->comboBoxBaseDirectory->currentText(); + if (base.isEmpty()){ + say(LOG_ERROR, tr("missing a base directory")); + } else { + QDateTime olderThan = comboDate(ui->comboBoxOlder); + QDateTime youngerThan = comboDate(ui->comboBoxYounger); + m_fileFinder->setOlderThan(olderThan.toMSecsSinceEpoch() <= 0 + ? NULL : new QDateTime(olderThan)); + m_fileFinder->setYoungerThan(olderThan.toMSecsSinceEpoch() <= 0 + ? NULL : new QDateTime(youngerThan)); + m_fileFinder->setTextToSearch(ui->comboBoxTextPattern->currentText(), + ui->checkBoxCaseSensitiv->isChecked(), + ui->checkBoxRegularExpr->isChecked(), + ui->checkBoxInverse->isChecked()); + m_fileFinder->setAddNotDetach(addNotDetach); + m_fileFinder->search(base, ui->comboBoxFilePatterns->currentText(), + atoi(ui->lineEditMinDepth->text().toLocal8Bit().data()), + atoi(ui->lineEditMaxDepth->text().toLocal8Bit().data())); + int files = ui->tableWidget->rowCount(); + ui->labelFileCount->setText(QString::number(files) + + " " + tr("file(s)")); + say(LOG_INFO, tr("files: %1 already found: %2 processed directories: %3") + .arg(m_fileFinder->foundFiles()) + .arg(m_fileFinder->ignoredFiles()) + .arg(m_fileFinder->processedDirs())); + } +} + +/** + * Common operation of onAdd() and onDetach(). + * + * @param addNotDetach true: add the found files
+ * false: detach the found files + */ +void MainWindow::searchSingleFile(bool addNotDetach) +{ + int ix = ui->comboBoxSeparator->currentIndex(); + QString separator; + if (ix >= 0) + separator = ui->comboBoxSeparator->currentText(); + QStringList lines = ui->plainTextFilenames->toPlainText() + .split('\n', QString::SkipEmptyParts); + QRegExp separatorExpr(separator); + + int found = 0; + int allFiles = 0; + int ignored = 0; + for (int no = 0; no < lines.size(); no++){ + QString line = lines[no].trimmed(); + if (separator.isEmpty()){ + found += addSingleFile(addNotDetach, line, ignored); + ++ allFiles; + } else { + QStringList files = line.split(separatorExpr, QString::SkipEmptyParts); + allFiles += files.size(); + for (int ix2 = 0; ix2 < files.size(); ix2++) + found += addSingleFile(addNotDetach, files[ix2], ignored); + } } + say(LOG_INFO, tr("Listed: %1 exists: %2 already found: %3").arg(allFiles) + .arg(found).arg(ignored)); +} + +/** + * Switches the add button and related. + * + * @param hide true: hide the buttons + * false: show the buttons + */ +void MainWindow::switchAdd(bool hide) +{ + ui->pushButtonAdd->setEnabled(! hide); + ui->pushButtonDetach->setEnabled(! hide); + ui->pushButtonClear->setEnabled(! hide); + if (hide) + say(LOG_INFO, tr("I am working...")); + ui->pushButtonAdd->update(); + ui->groupBox->update(); } /** @@ -281,18 +450,15 @@ void MainWindow::searchFiles(bool addNotDetach) * @param first true: a new resultset is expected. */ void MainWindow::switchFilter(bool first){ - ui->pushButtonFilter->setEnabled(first); - ui->pushButtonPrevious->setEnabled(! first); - ui->pushButtonNext->setEnabled(! first); - if (first){ - int start = comboInt(ui->comboBoxFromHit, 1); - int pageSize = comboInt(ui->comboBoxToHit, start + 50) - start + 1; - ui->comboBoxFromHit->setCurrentText("1"); - ui->comboBoxToHit->setCurrentText(QString::number(pageSize)); - ui->labelHits->setText(""); - } else { - logHits(); - } + ui->pushButtonFilter->setEnabled(first); + ui->pushButtonPrevious->setEnabled(! first); + ui->pushButtonNext->setEnabled(! first); + if (first){ + ui->comboBoxFromHit->setCurrentText("1"); + ui->labelHits->setText(""); + } else { + logHits(); + } } /** @@ -303,6 +469,6 @@ void MainWindow::switchFilter(bool first){ void MainWindow::textEdited(const QString& oldString, const QString& newString) { ReUseParameter(oldString); - ReUseParameter(newString); + ReUseParameter(newString); } diff --git a/appl/research/mainwindow.hpp b/appl/research/mainwindow.hpp index 623d46f..ec9c81f 100644 --- a/appl/research/mainwindow.hpp +++ b/appl/research/mainwindow.hpp @@ -19,6 +19,10 @@ class MainWindow; class MainWindow : public ReGuiApplication, public ReGuiValidator { Q_OBJECT +public: + enum TimerTask { + ttUndef, ttAdd, ttDetach, ttClear + }; public: explicit MainWindow(QApplication& application, const QString& homeDir, @@ -28,13 +32,18 @@ public: virtual bool say(ReLoggerLevel level, const QString& message); private: + int addSingleFile(bool addNotDetach, const QString &filename, int &alreadyFound); int comboboxToInt(QComboBox &combobox, int defaultValue); void initializeGui(); void logHits(); + void onAddTimer(); virtual void onAboutToQuit(); + void onDetachTimer(); virtual void onGuiTimerUpdate(); virtual void onLanguageChange(); void searchFiles(bool addNotDetach); + void searchSingleFile(bool addNotDetach); + void switchAdd(bool hide); void switchFilter(bool first); private slots: void clearLastHitPosition(const QString &, const QString &); @@ -43,9 +52,11 @@ private slots: void onClear(); void onDetach(); void onFilter(); + void onFromHitChanged(const QString &oldValue, const QString &newValue); void onNext(); void onPrevious(); void onSelectBaseDirectory(); + void onTimerTask(); void textEdited(const QString& oldString, const QString& newString); private: Ui::MainWindow *ui; @@ -53,5 +64,7 @@ private: FileCache* m_fileCache; bool m_test; HitPosition* m_lastHitPosition; + TimerTask m_currentTask; + QTimer* m_timer; }; #endif // MAINWINDOW_H diff --git a/appl/research/mainwindow.ui b/appl/research/mainwindow.ui index e6aa781..f13990e 100644 --- a/appl/research/mainwindow.ui +++ b/appl/research/mainwindow.ui @@ -11,14 +11,14 @@ - MainWindow + ReSearch - 1 + 0 @@ -321,90 +321,119 @@ If the checkbox "inverse search" is checked a file is found only if th Single files - - - - - - - - 16777215 - 175 - - - - Activity - - - - - 0 - 150 - 131 - 20 - - - - - - - - - - 19 - 27 - 87 - 113 - - - - - - - Adds the described files into the table below - + + + - &Add + List of files: - - + + - Removes the found files from the table below - - - &Detach + One ore more filenames (with path) separated by the separator described below - - - - Qt::Vertical - - - - 20 - 40 - + + + + Separator: - + - - + + - Clears the table below + <html><head/><body><p>Regular expression for the separator between filenames.</p><p><span style=" font-weight:600;">Note</span>: The newline is always a separator.</p><p><span style=" font-weight:600;">Examples</span>: (type without &quot;)</p><p>&quot;\s+&quot; : whitespaces (blanks, tabulators)</p><p>&quot;,\s*&quot;: a comma with or without whitespaces</p><p><br/></p></body></html> - - &Clear + + true + + + '\n' (newline) + + + '\n' (newline) + + + + + + + 16777215 + 175 + + + + Activity + + + + + + + + Adds the described files into the table below + + + &Add + + + + + + + Removes the found files from the table below + + + &Detach + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Clears the table below + + + &Clear + + + + + + + + + + + + + + + @@ -482,6 +511,13 @@ If the checkbox "inverse search" is checked a file is found only if th + + Regular expression defining a hit. +<b>Examples</b> +<b>or expression</b>: "cat|dog" find the lines "<bcat</b>s are wanted" and "Missing a <b>dog</b>" +<b>Begin of the line</b>: "^1234" finds the line "<b>1234</b> houses" but not the line "count: <b>1234</b>" +<b>Word boundaries</b>: "\bcat\b" finds the line "a <b>cat</b> and a dog" but not the line "Look at the <b>cat</b>s" + true @@ -496,6 +532,9 @@ If the checkbox "inverse search" is checked a file is found only if th + + Regulare expression to prevend from being a hit + true @@ -512,7 +551,7 @@ If the checkbox "inverse search" is checked a file is found only if th 11 11 - 298 + 321 38 @@ -570,6 +609,12 @@ If the checkbox "inverse search" is checked a file is found only if th + + 10 + + + 10 + @@ -670,18 +715,21 @@ If the checkbox "inverse search" is checked a file is found only if th - To hit: + Pagesize: - + 100 16777215 + + Maximal number of hits in the list below + true