2018-08-12 16:45:39 +02:00
|
|
|
#include <poppler-qt5.h>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QtDebug>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QClipboard>
|
2018-09-02 20:30:52 +02:00
|
|
|
#include <QtGlobal>
|
2018-08-12 16:45:39 +02:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QDateTime>
|
2018-08-31 20:08:23 +02:00
|
|
|
#include <QProcess>
|
2018-09-02 20:30:52 +02:00
|
|
|
#include <QComboBox>
|
2019-04-27 21:24:53 +02:00
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2022-04-15 21:00:39 +02:00
|
|
|
#include <QMessageBox>
|
2022-05-03 16:20:06 +02:00
|
|
|
#include <QFileDialog>
|
2022-05-27 09:31:21 +02:00
|
|
|
#include <QScreen>
|
2022-06-04 15:49:29 +02:00
|
|
|
#include <QProgressDialog>
|
2022-08-28 13:05:28 +02:00
|
|
|
#include <QDesktopWidget>
|
2023-04-10 18:29:27 +02:00
|
|
|
#include <QWidgetAction>
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "clicklabel.h"
|
2019-04-25 10:27:54 +02:00
|
|
|
#include "../shared/sqlitesearch.h"
|
2021-06-12 14:59:58 +02:00
|
|
|
#include "../shared/looqsgeneralexception.h"
|
2020-05-24 15:36:27 +02:00
|
|
|
#include "../shared/common.h"
|
2022-06-29 17:22:50 +02:00
|
|
|
#include "aboutdialog.h"
|
2020-05-24 15:36:27 +02:00
|
|
|
|
2022-06-04 15:49:29 +02:00
|
|
|
MainWindow::MainWindow(QWidget *parent, QString socketPath)
|
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow), progressDialog(this)
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2022-06-04 15:49:29 +02:00
|
|
|
this->progressDialog.cancel(); // because constructing it shows it, quite weird
|
2018-08-12 16:45:39 +02:00
|
|
|
ui->setupUi(this);
|
2021-03-07 21:09:38 +01:00
|
|
|
setWindowTitle(QCoreApplication::applicationName());
|
2023-01-08 17:37:28 +01:00
|
|
|
|
2019-08-26 09:20:21 +02:00
|
|
|
QSettings settings;
|
2018-08-12 16:45:39 +02:00
|
|
|
|
2022-04-14 15:04:16 +02:00
|
|
|
this->dbFactory = new DatabaseFactory(Common::databasePath());
|
|
|
|
|
|
|
|
db = this->dbFactory->forCurrentThread();
|
|
|
|
this->dbService = new SqliteDbService(*this->dbFactory);
|
2022-06-04 15:49:29 +02:00
|
|
|
this->indexSyncer = new IndexSyncer(*this->dbService);
|
|
|
|
this->indexSyncer->moveToThread(&this->syncerThread);
|
2022-04-14 15:04:16 +02:00
|
|
|
|
|
|
|
indexer = new Indexer(*(this->dbService));
|
|
|
|
indexer->setParent(this);
|
2023-04-10 18:29:27 +02:00
|
|
|
|
|
|
|
tagManager = new TagManager(*(this->dbService));
|
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
connectSignals();
|
|
|
|
ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
2018-08-31 20:40:07 +02:00
|
|
|
ui->statusBar->addWidget(ui->lblSearchResults);
|
2022-01-03 23:02:21 +01:00
|
|
|
ui->statusBar->addWidget(ui->previewProcessBar);
|
|
|
|
ui->previewProcessBar->hide();
|
2019-04-25 10:27:54 +02:00
|
|
|
ui->comboScale->setCurrentText(settings.value("currentScale").toString());
|
2022-01-03 23:02:21 +01:00
|
|
|
previewsPerPage = settings.value("previewsPerPage", 20).toInt();
|
|
|
|
ui->spinPreviewPage->setMinimum(1);
|
2022-04-15 22:57:15 +02:00
|
|
|
|
|
|
|
QStringList indexPaths = settings.value("indexPaths").toStringList();
|
|
|
|
ui->lstPaths->addItems(indexPaths);
|
2022-05-29 10:09:24 +02:00
|
|
|
|
2022-05-31 10:16:53 +02:00
|
|
|
QString ignorePatterns = settings.value("ignorePatterns").toString();
|
|
|
|
ui->txtIgnorePatterns->setText(ignorePatterns);
|
|
|
|
|
2022-08-21 17:47:34 +02:00
|
|
|
QStringList searchHistoryList = settings.value(SETTINGS_KEY_SEARCHHISTORY).toStringList();
|
|
|
|
this->searchHistory = searchHistoryList.toVector();
|
|
|
|
this->currentSearchHistoryIndex = this->searchHistory.size();
|
|
|
|
|
2022-05-29 10:09:24 +02:00
|
|
|
ui->spinPreviewPage->setValue(1);
|
|
|
|
ui->spinPreviewPage->setMinimum(1);
|
2022-06-23 15:27:13 +02:00
|
|
|
|
|
|
|
ui->btnOpenFailed->setVisible(false);
|
2022-06-29 12:40:04 +02:00
|
|
|
ui->comboPreviewFiles->setVisible(false);
|
2022-06-23 15:27:13 +02:00
|
|
|
|
|
|
|
auto policy = ui->btnOpenFailed->sizePolicy();
|
|
|
|
policy.setRetainSizeWhenHidden(true);
|
|
|
|
ui->btnOpenFailed->setSizePolicy(policy);
|
2022-07-16 23:35:40 +02:00
|
|
|
|
2022-08-21 17:28:04 +02:00
|
|
|
ui->txtSearch->installEventFilter(this);
|
2022-08-21 18:42:32 +02:00
|
|
|
ui->scrollArea->viewport()->installEventFilter(this);
|
2022-08-21 17:28:04 +02:00
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
this->previewCoordinator.setSocketPath(socketPath);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2022-04-15 21:00:39 +02:00
|
|
|
void MainWindow::addPathToIndex()
|
|
|
|
{
|
|
|
|
QString path = this->ui->txtPathScanAdd->text();
|
|
|
|
QFileInfo fileInfo{path};
|
|
|
|
if(!fileInfo.exists(path))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Invalid path", "Path does not seem to exist");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!fileInfo.isReadable())
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Invalid path", "Path cannot be read");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->ui->lstPaths->addItem(path);
|
|
|
|
this->ui->txtPathScanAdd->clear();
|
|
|
|
}
|
2022-06-04 15:49:29 +02:00
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
void MainWindow::connectSignals()
|
|
|
|
{
|
|
|
|
connect(ui->txtSearch, &QLineEdit::returnPressed, this, &MainWindow::lineEditReturnPressed);
|
2019-04-27 21:24:53 +02:00
|
|
|
connect(&searchWatcher, &QFutureWatcher<SearchResult>::finished, this,
|
|
|
|
[&]
|
|
|
|
{
|
2019-04-29 23:05:51 +02:00
|
|
|
try
|
|
|
|
{
|
2020-06-06 23:18:33 +02:00
|
|
|
this->ui->txtSearch->setEnabled(true);
|
2019-04-29 23:05:51 +02:00
|
|
|
auto results = searchWatcher.future().result();
|
|
|
|
handleSearchResults(results);
|
|
|
|
}
|
2021-06-12 14:59:58 +02:00
|
|
|
catch(LooqsGeneralException &e)
|
2019-04-29 23:05:51 +02:00
|
|
|
{
|
|
|
|
handleSearchError(e.message);
|
|
|
|
}
|
2019-04-27 21:24:53 +02:00
|
|
|
});
|
2018-08-12 16:45:39 +02:00
|
|
|
connect(ui->treeResultsList, &QTreeWidget::itemActivated, this, &MainWindow::treeSearchItemActivated);
|
|
|
|
connect(ui->treeResultsList, &QTreeWidget::customContextMenuRequested, this,
|
|
|
|
&MainWindow::showSearchResultsContextMenu);
|
|
|
|
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &MainWindow::tabChanged);
|
2021-06-12 23:01:14 +02:00
|
|
|
connect(ui->comboScale, qOverload<int>(&QComboBox::currentIndexChanged), this, &MainWindow::comboScaleChanged);
|
2022-01-03 23:02:21 +01:00
|
|
|
connect(ui->spinPreviewPage, qOverload<int>(&QSpinBox::valueChanged), this,
|
|
|
|
&MainWindow::spinPreviewPageValueChanged);
|
2022-04-14 15:04:16 +02:00
|
|
|
|
2022-04-15 21:00:39 +02:00
|
|
|
connect(ui->btnAddPath, &QPushButton::clicked, this, &MainWindow::addPathToIndex);
|
|
|
|
connect(ui->txtPathScanAdd, &QLineEdit::returnPressed, this, &MainWindow::addPathToIndex);
|
2022-04-14 15:04:16 +02:00
|
|
|
connect(ui->btnStartIndexing, &QPushButton::clicked, this, &MainWindow::startIndexing);
|
|
|
|
|
|
|
|
connect(this->indexer, &Indexer::pathsCountChanged, this,
|
|
|
|
[&](int number)
|
|
|
|
{
|
|
|
|
ui->lblSearchResults->setText("Found paths: " + QString::number(number));
|
|
|
|
ui->lblPathsFoundValue->setText(QString::number(number));
|
|
|
|
ui->previewProcessBar->setMaximum(number);
|
|
|
|
});
|
|
|
|
connect(this->indexer, &Indexer::indexProgress, this,
|
|
|
|
|
|
|
|
[&](int number, unsigned int added, unsigned int skipped, unsigned int failed, unsigned int totalCount)
|
|
|
|
{
|
|
|
|
ui->lblSearchResults->setText("Processed " + QString::number(number) + " files");
|
|
|
|
ui->previewProcessBar->setValue(number);
|
|
|
|
ui->previewProcessBar->setMaximum(totalCount);
|
|
|
|
ui->lblAddedValue->setText(QString::number(added));
|
|
|
|
ui->lblSkippedValue->setText(QString::number(skipped));
|
|
|
|
ui->lblFailedValue->setText(QString::number(failed));
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(this->indexer, &Indexer::finished, this, &MainWindow::finishIndexing);
|
2022-04-15 21:05:00 +02:00
|
|
|
|
|
|
|
connect(ui->lstPaths->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
2023-03-12 16:41:31 +01:00
|
|
|
[&](const QItemSelection & /*selected*/, const QItemSelection & /*deselected*/)
|
2022-04-15 21:05:00 +02:00
|
|
|
{ ui->btnDeletePath->setEnabled(this->ui->lstPaths->selectedItems().count() > 0); });
|
|
|
|
|
|
|
|
connect(ui->btnDeletePath, &QPushButton::clicked, this, [&] { qDeleteAll(ui->lstPaths->selectedItems()); });
|
2022-05-03 16:20:06 +02:00
|
|
|
connect(ui->btnChoosePath, &QPushButton::clicked, this,
|
|
|
|
[&]
|
|
|
|
{
|
|
|
|
QFileDialog dialog(nullptr);
|
|
|
|
dialog.setFileMode(QFileDialog::Directory);
|
|
|
|
dialog.setOptions(QFileDialog::ShowDirsOnly);
|
|
|
|
if(dialog.exec())
|
|
|
|
{
|
|
|
|
auto paths = dialog.selectedFiles();
|
|
|
|
if(paths.size() == 1)
|
|
|
|
{
|
|
|
|
ui->lstPaths->addItem(paths[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-06-29 17:22:50 +02:00
|
|
|
connect(ui->menuAboutAction, &QAction::triggered, this,
|
2023-03-12 16:41:31 +01:00
|
|
|
[this](bool /*checked*/)
|
2022-06-29 17:22:50 +02:00
|
|
|
{
|
|
|
|
AboutDialog aboutDialog(this);
|
|
|
|
|
|
|
|
aboutDialog.exec();
|
|
|
|
});
|
2022-05-31 18:41:13 +02:00
|
|
|
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
2023-03-12 16:41:31 +01:00
|
|
|
[this](bool /*checked*/) { QMessageBox::aboutQt(this, "About Qt"); });
|
2022-06-04 15:49:29 +02:00
|
|
|
connect(ui->menuSyncIndexAction, &QAction::triggered, this, &MainWindow::startIndexSync);
|
2022-07-23 20:16:14 +02:00
|
|
|
connect(ui->menuOpenUserManualAction, &QAction::triggered, this,
|
2023-03-12 16:41:31 +01:00
|
|
|
[]() { QDesktopServices::openUrl(Common::userManualUrl()); });
|
2022-07-23 20:16:14 +02:00
|
|
|
|
2023-03-12 16:41:31 +01:00
|
|
|
connect(
|
|
|
|
indexSyncer, &IndexSyncer::finished, this,
|
|
|
|
[&](unsigned int totalUpdated, unsigned int totalDeleted, unsigned int totalErrored)
|
|
|
|
{
|
|
|
|
this->progressDialog.cancel();
|
|
|
|
|
|
|
|
QMessageBox::information(
|
|
|
|
this, "Syncing finished",
|
|
|
|
QString("Syncing finished\n\nTotal updated: %1\nTotal deleted: %2\nTotal errors: %3\n")
|
|
|
|
.arg(QString::number(totalUpdated), QString::number(totalDeleted), QString::number(totalErrored)));
|
|
|
|
});
|
2022-06-04 15:49:29 +02:00
|
|
|
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
|
|
|
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
2022-06-13 19:36:12 +02:00
|
|
|
connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings);
|
2022-06-23 15:27:13 +02:00
|
|
|
connect(ui->btnOpenFailed, &QPushButton::clicked, this, &MainWindow::exportFailedPaths);
|
2022-06-29 12:40:04 +02:00
|
|
|
connect(
|
2022-08-23 17:35:50 +02:00
|
|
|
ui->comboPreviewFiles, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
if(this->previewTabActive())
|
|
|
|
{
|
|
|
|
makePreviews(1);
|
|
|
|
}
|
|
|
|
},
|
2022-06-29 12:40:04 +02:00
|
|
|
Qt::QueuedConnection);
|
2023-01-08 17:37:28 +01:00
|
|
|
connect(&previewCoordinator, &PreviewCoordinator::previewReady, this, &MainWindow::previewReceived,
|
2022-07-16 23:35:40 +02:00
|
|
|
Qt::QueuedConnection);
|
2023-01-08 17:37:28 +01:00
|
|
|
connect(&previewCoordinator, &PreviewCoordinator::completedGeneration, this,
|
2022-07-16 23:35:40 +02:00
|
|
|
[&]
|
|
|
|
{
|
|
|
|
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->maximum());
|
|
|
|
this->ui->spinPreviewPage->setEnabled(true);
|
|
|
|
this->ui->comboPreviewFiles->setEnabled(true);
|
2022-08-23 17:37:01 +02:00
|
|
|
ui->txtSearch->setEnabled(true);
|
2022-07-16 23:35:40 +02:00
|
|
|
});
|
2023-01-08 17:37:28 +01:00
|
|
|
connect(&previewCoordinator, &PreviewCoordinator::error, this,
|
2022-07-16 23:35:40 +02:00
|
|
|
[this](QString msg)
|
|
|
|
{
|
|
|
|
qCritical() << msg << Qt::endl;
|
|
|
|
QMessageBox::critical(this, "IPC error", msg);
|
|
|
|
});
|
2023-01-08 17:37:28 +01:00
|
|
|
connect(ui->radioMetadataOnly, &QRadioButton::toggled, this,
|
|
|
|
[this](bool toggled)
|
|
|
|
{
|
|
|
|
if(toggled)
|
|
|
|
{
|
|
|
|
this->ui->chkFillContentForContentless->setChecked(false);
|
|
|
|
};
|
|
|
|
});
|
2022-06-23 15:27:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::exportFailedPaths()
|
|
|
|
{
|
|
|
|
QString filename =
|
|
|
|
QString("/tmp/looqs_indexresult_failed_%1").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss"));
|
|
|
|
QFile outFile(filename);
|
|
|
|
if(!outFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Failed to write log file", "An error occured while trying to create log file");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTextStream stream(&outFile);
|
|
|
|
|
|
|
|
IndexResult result = this->indexer->getResult();
|
|
|
|
|
|
|
|
stream << "Failed to index the following paths:\n";
|
|
|
|
for(FileScanResult &fsr : result.failedResults())
|
|
|
|
{
|
|
|
|
stream << fsr.first << " " << SaveFileResultToString(fsr.second) << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
QDesktopServices::openUrl(filename);
|
2019-08-26 09:20:21 +02:00
|
|
|
}
|
|
|
|
|
2022-06-04 15:49:29 +02:00
|
|
|
void MainWindow::startIndexSync()
|
|
|
|
{
|
|
|
|
progressDialog.setWindowTitle("Syncing");
|
|
|
|
progressDialog.setLabelText("Syncing - this might take a moment, please wait");
|
|
|
|
progressDialog.setWindowModality(Qt::ApplicationModal);
|
|
|
|
progressDialog.setMinimum(0);
|
|
|
|
progressDialog.setMaximum(0);
|
|
|
|
progressDialog.setValue(0);
|
|
|
|
progressDialog.open();
|
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
FileSaverOptions options;
|
|
|
|
options.keepGoing = true;
|
|
|
|
options.verbose = false;
|
|
|
|
|
|
|
|
indexSyncer->setFileSaverOptions(options);
|
2022-06-04 15:49:29 +02:00
|
|
|
indexSyncer->setDryRun(false);
|
|
|
|
indexSyncer->setRemoveDeletedFromIndex(true);
|
|
|
|
|
|
|
|
this->syncerThread.start();
|
|
|
|
|
|
|
|
emit beginIndexSync();
|
|
|
|
}
|
2022-06-13 19:36:12 +02:00
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
void MainWindow::spinPreviewPageValueChanged(int val)
|
2019-08-26 09:20:21 +02:00
|
|
|
{
|
2022-01-03 23:02:21 +01:00
|
|
|
makePreviews(val);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2022-04-14 15:04:16 +02:00
|
|
|
void MainWindow::startIndexing()
|
|
|
|
{
|
2022-04-15 21:06:19 +02:00
|
|
|
if(this->indexer->isRunning())
|
|
|
|
{
|
|
|
|
ui->btnStartIndexing->setEnabled(false);
|
2023-04-10 18:44:45 +02:00
|
|
|
|
2022-04-15 21:06:19 +02:00
|
|
|
ui->btnStartIndexing->setText("Start indexing");
|
|
|
|
this->indexer->requestCancellation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->previewsTab->setEnabled(false);
|
|
|
|
ui->resultsTab->setEnabled(false);
|
2022-06-13 22:53:41 +02:00
|
|
|
ui->settingsTab->setEnabled(false);
|
2022-04-14 15:04:16 +02:00
|
|
|
ui->txtPathScanAdd->setEnabled(false);
|
2023-04-10 18:44:45 +02:00
|
|
|
ui->btnAddPath->setEnabled(false);
|
|
|
|
ui->btnChoosePath->setEnabled(false);
|
2022-04-14 15:04:16 +02:00
|
|
|
ui->txtSearch->setEnabled(false);
|
|
|
|
ui->previewProcessBar->setValue(0);
|
2022-04-17 20:52:07 +02:00
|
|
|
ui->previewProcessBar->setVisible(true);
|
2022-06-23 15:27:13 +02:00
|
|
|
ui->btnOpenFailed->setVisible(false);
|
2022-04-14 15:04:16 +02:00
|
|
|
|
|
|
|
QVector<QString> paths;
|
2022-04-15 22:57:15 +02:00
|
|
|
QStringList pathSettingsValue;
|
2022-04-14 15:04:16 +02:00
|
|
|
for(int i = 0; i < ui->lstPaths->count(); i++)
|
|
|
|
{
|
2022-04-15 22:57:15 +02:00
|
|
|
QString path = ui->lstPaths->item(i)->text();
|
|
|
|
paths.append(path);
|
|
|
|
pathSettingsValue.append(path);
|
2022-04-14 15:04:16 +02:00
|
|
|
}
|
|
|
|
this->indexer->setTargetPaths(paths);
|
2022-05-31 10:16:53 +02:00
|
|
|
QString ignorePatterns = ui->txtIgnorePatterns->text();
|
|
|
|
this->indexer->setIgnorePattern(ignorePatterns.split(";"));
|
2023-01-08 17:37:28 +01:00
|
|
|
|
|
|
|
FileSaverOptions options;
|
|
|
|
options.fillExistingContentless =
|
|
|
|
ui->chkFillContentForContentless->isEnabled() && ui->chkFillContentForContentless->isChecked();
|
|
|
|
options.metadataOnly = ui->radioMetadataOnly->isChecked();
|
|
|
|
options.verbose = false;
|
|
|
|
options.keepGoing = true;
|
|
|
|
|
|
|
|
this->indexer->setFileSaverOptions(options);
|
2022-04-14 15:04:16 +02:00
|
|
|
this->indexer->beginIndexing();
|
2022-04-15 22:57:15 +02:00
|
|
|
QSettings settings;
|
|
|
|
settings.setValue("indexPaths", pathSettingsValue);
|
2022-05-31 10:16:53 +02:00
|
|
|
settings.setValue("ignorePatterns", ignorePatterns);
|
2022-04-15 21:06:19 +02:00
|
|
|
ui->btnStartIndexing->setText("Stop indexing");
|
2022-04-14 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::finishIndexing()
|
|
|
|
{
|
|
|
|
IndexResult result = this->indexer->getResult();
|
|
|
|
|
|
|
|
ui->lblSearchResults->setText("Indexing finished");
|
|
|
|
ui->previewProcessBar->setValue(ui->previewProcessBar->maximum());
|
|
|
|
ui->lblFailedValue->setText(QString::number(result.erroredPaths));
|
|
|
|
ui->lblSkippedValue->setText(QString::number(result.skippedPaths));
|
|
|
|
ui->lblAddedValue->setText(QString::number(result.addedPaths));
|
2022-04-15 21:06:19 +02:00
|
|
|
ui->btnStartIndexing->setEnabled(true);
|
|
|
|
ui->btnStartIndexing->setText("Start indexing");
|
2022-04-15 22:56:11 +02:00
|
|
|
ui->previewsTab->setEnabled(true);
|
|
|
|
ui->resultsTab->setEnabled(true);
|
2022-06-13 22:53:41 +02:00
|
|
|
ui->settingsTab->setEnabled(true);
|
2022-04-15 22:56:11 +02:00
|
|
|
ui->txtPathScanAdd->setEnabled(true);
|
2023-04-10 18:44:45 +02:00
|
|
|
ui->btnAddPath->setEnabled(true);
|
|
|
|
ui->btnChoosePath->setEnabled(true);
|
2022-04-15 22:56:11 +02:00
|
|
|
ui->txtSearch->setEnabled(true);
|
2022-06-23 15:27:13 +02:00
|
|
|
if(result.erroredPaths > 0)
|
|
|
|
{
|
|
|
|
ui->btnOpenFailed->setVisible(true);
|
|
|
|
}
|
2022-04-14 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 16:41:31 +01:00
|
|
|
void MainWindow::comboScaleChanged(int /*i*/)
|
2018-09-02 20:30:52 +02:00
|
|
|
{
|
2019-04-25 10:27:54 +02:00
|
|
|
QSettings scaleSetting;
|
|
|
|
scaleSetting.setValue("currentScale", ui->comboScale->currentText());
|
2022-01-03 23:02:21 +01:00
|
|
|
makePreviews(ui->spinPreviewPage->value());
|
2018-09-02 20:30:52 +02:00
|
|
|
}
|
2022-04-14 15:04:16 +02:00
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
bool MainWindow::previewTabActive()
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
|
|
|
return ui->tabWidget->currentIndex() == 1;
|
|
|
|
}
|
|
|
|
|
2022-04-14 15:04:16 +02:00
|
|
|
bool MainWindow::indexerTabActive()
|
|
|
|
{
|
|
|
|
return ui->tabWidget->currentIndex() == 2;
|
|
|
|
}
|
|
|
|
|
2022-08-14 13:04:10 +02:00
|
|
|
void MainWindow::processShortcut(int key)
|
|
|
|
{
|
2022-08-14 16:18:15 +02:00
|
|
|
if(key == Qt::Key_Tab || key == Qt::Key_Backtab)
|
|
|
|
{
|
|
|
|
int tabIndex = ui->tabWidget->currentIndex();
|
|
|
|
if(key == Qt::Key_Tab)
|
|
|
|
{
|
|
|
|
++tabIndex;
|
|
|
|
}
|
|
|
|
if(key == Qt::Key_Backtab)
|
|
|
|
{
|
|
|
|
--tabIndex;
|
|
|
|
}
|
|
|
|
tabIndex = tabIndex % ui->tabWidget->count();
|
|
|
|
if(tabIndex < 0)
|
|
|
|
{
|
|
|
|
tabIndex = ui->tabWidget->count() - 1;
|
|
|
|
}
|
|
|
|
ui->tabWidget->setCurrentIndex(tabIndex);
|
|
|
|
}
|
2022-08-14 13:04:10 +02:00
|
|
|
if(key == Qt::Key_L)
|
|
|
|
{
|
|
|
|
ui->txtSearch->setFocus();
|
|
|
|
ui->txtSearch->selectAll();
|
|
|
|
}
|
|
|
|
if(key == Qt::Key_W)
|
|
|
|
{
|
|
|
|
ui->txtSearch->setFocus();
|
|
|
|
QString currentText = ui->txtSearch->text().trimmed();
|
2023-03-12 16:41:31 +01:00
|
|
|
static QRegularExpression separatorRegex("[\\s\\)]");
|
|
|
|
int index = currentText.lastIndexOf(separatorRegex);
|
2022-08-14 13:04:10 +02:00
|
|
|
if(index != -1)
|
|
|
|
{
|
|
|
|
bool isFilter = (index == currentText.length() - 1);
|
|
|
|
currentText.remove(index + 1, currentText.length() - index - 1);
|
|
|
|
if(isFilter)
|
|
|
|
{
|
|
|
|
index = currentText.lastIndexOf(' ', index);
|
|
|
|
if(index == -1)
|
|
|
|
{
|
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
currentText.remove(index, currentText.length());
|
|
|
|
}
|
|
|
|
if(currentText.length() > 0)
|
|
|
|
{
|
|
|
|
currentText += ' ';
|
|
|
|
}
|
|
|
|
ui->txtSearch->setText(currentText);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->txtSearch->clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(key == Qt::Key_F)
|
|
|
|
{
|
|
|
|
ui->txtSearch->setFocus();
|
|
|
|
QString currentText = ui->txtSearch->text().trimmed();
|
|
|
|
int index = currentText.lastIndexOf(')');
|
|
|
|
if(index != -1)
|
|
|
|
{
|
|
|
|
bool isFilter = (index == currentText.length() - 1);
|
|
|
|
if(!isFilter)
|
|
|
|
{
|
|
|
|
ui->txtSearch->setSelection(index + 2, ui->txtSearch->text().length() - index - 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int begin = currentText.lastIndexOf('(', index - 1);
|
|
|
|
if(begin != -1)
|
|
|
|
{
|
|
|
|
ui->txtSearch->setSelection(begin + 1, index - begin - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int spaceIndex = currentText.lastIndexOf(' ');
|
|
|
|
int colonIndex = currentText.lastIndexOf(':');
|
|
|
|
if(colonIndex > spaceIndex)
|
|
|
|
{
|
|
|
|
int target = currentText.indexOf(' ', colonIndex);
|
|
|
|
if(target == -1)
|
|
|
|
{
|
|
|
|
target = ui->txtSearch->text().size() - colonIndex;
|
|
|
|
}
|
|
|
|
ui->txtSearch->setSelection(colonIndex + 1, target - 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->txtSearch->setSelection(spaceIndex + 1, ui->txtSearch->text().size() - spaceIndex - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-21 17:28:04 +02:00
|
|
|
bool MainWindow::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
|
|
|
if(object == ui->txtSearch && !searchHistory.empty())
|
|
|
|
{
|
|
|
|
if(event->type() == QEvent::KeyPress)
|
|
|
|
{
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
|
|
if(keyEvent->key() == Qt::Key_Up)
|
|
|
|
{
|
|
|
|
if(this->currentSavedSearchText.isEmpty())
|
|
|
|
{
|
|
|
|
this->currentSavedSearchText = ui->txtSearch->text();
|
|
|
|
}
|
|
|
|
if(this->currentSearchHistoryIndex <= 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
--this->currentSearchHistoryIndex;
|
|
|
|
QString text = this->searchHistory.at(this->currentSearchHistoryIndex);
|
|
|
|
ui->txtSearch->setText(text);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(keyEvent->key() == Qt::Key_Down)
|
|
|
|
{
|
|
|
|
if(this->currentSearchHistoryIndex == searchHistory.size() - 1)
|
|
|
|
{
|
|
|
|
if(!this->currentSavedSearchText.isEmpty())
|
|
|
|
{
|
|
|
|
ui->txtSearch->setText(this->currentSavedSearchText);
|
|
|
|
this->currentSavedSearchText.clear();
|
|
|
|
++this->currentSearchHistoryIndex;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(this->currentSearchHistoryIndex < searchHistory.size() - 1)
|
|
|
|
{
|
|
|
|
++this->currentSearchHistoryIndex;
|
|
|
|
QString text = this->searchHistory.at(this->currentSearchHistoryIndex);
|
|
|
|
ui->txtSearch->setText(text);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->currentSavedSearchText.clear();
|
|
|
|
/* Off by one on purpose so Key_Up decrements it again and lands at
|
|
|
|
* the last entry */
|
|
|
|
this->currentSearchHistoryIndex = this->searchHistory.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-21 18:42:32 +02:00
|
|
|
if(object == ui->scrollArea->viewport())
|
|
|
|
{
|
|
|
|
if(event->type() == QEvent::Wheel)
|
|
|
|
{
|
|
|
|
QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event);
|
|
|
|
if(wheelEvent->modifiers() & Qt::ControlModifier)
|
|
|
|
{
|
|
|
|
if(wheelEvent->angleDelta().y() > 0)
|
|
|
|
{
|
|
|
|
if(ui->comboScale->currentIndex() < ui->comboScale->count() - 1)
|
|
|
|
{
|
|
|
|
ui->comboScale->setCurrentIndex(ui->comboScale->currentIndex() + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ui->comboScale->currentIndex() > 0)
|
|
|
|
{
|
|
|
|
ui->comboScale->setCurrentIndex(ui->comboScale->currentIndex() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-21 17:28:04 +02:00
|
|
|
return QMainWindow::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
|
2018-12-29 20:21:13 +01:00
|
|
|
void MainWindow::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
bool quit =
|
|
|
|
((event->modifiers() & Qt::ControlModifier && event->key() == Qt::Key_Q) || event->key() == Qt::Key_Escape);
|
|
|
|
if(quit)
|
|
|
|
{
|
|
|
|
qApp->quit();
|
2022-08-14 16:18:15 +02:00
|
|
|
return;
|
2018-12-29 20:21:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(event->modifiers() & Qt::ControlModifier)
|
|
|
|
{
|
2022-08-14 13:04:10 +02:00
|
|
|
processShortcut(event->key());
|
2022-08-14 16:18:15 +02:00
|
|
|
return;
|
2018-12-29 20:21:13 +01:00
|
|
|
}
|
2022-08-14 16:18:15 +02:00
|
|
|
|
2018-12-29 20:21:13 +01:00
|
|
|
QWidget::keyPressEvent(event);
|
|
|
|
}
|
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
void MainWindow::tabChanged()
|
|
|
|
{
|
2022-04-17 20:52:07 +02:00
|
|
|
if(ui->tabWidget->currentIndex() == 0)
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2022-04-17 20:52:07 +02:00
|
|
|
ui->previewProcessBar->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ui->previewProcessBar->value() > 0)
|
2018-08-31 20:40:07 +02:00
|
|
|
{
|
2022-04-17 20:52:07 +02:00
|
|
|
ui->previewProcessBar->show();
|
2018-08-31 20:40:07 +02:00
|
|
|
}
|
|
|
|
}
|
2022-04-17 20:52:07 +02:00
|
|
|
if(previewTabActive())
|
2018-08-31 20:40:07 +02:00
|
|
|
{
|
2022-04-17 20:52:07 +02:00
|
|
|
if(previewDirty)
|
|
|
|
{
|
|
|
|
makePreviews(ui->spinPreviewPage->value());
|
|
|
|
}
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
2022-06-13 19:36:12 +02:00
|
|
|
/* Settings tab active */
|
|
|
|
if(ui->tabWidget->currentIndex() == 3)
|
|
|
|
{
|
|
|
|
initSettingsTabs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::initSettingsTabs()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
QString pdfViewerCmd = settings.value(SETTINGS_KEY_PDFVIEWER).toString();
|
|
|
|
QString excludedPaths = Common::excludedPaths().join(';');
|
|
|
|
QString mountPaths = Common::mountPaths().join(';');
|
2022-06-14 10:58:38 +02:00
|
|
|
QString databasePath = Common::databasePath();
|
2022-06-13 19:36:12 +02:00
|
|
|
int numPagesPerPreview = settings.value(SETTINGS_KEY_PREVIEWSPERPAGE, 20).toInt();
|
|
|
|
|
|
|
|
ui->txtSettingPdfPreviewerCmd->setText(pdfViewerCmd);
|
|
|
|
ui->txtSettingIgnoredPaths->setText(excludedPaths);
|
|
|
|
ui->txtSettingMountPaths->setText(mountPaths);
|
|
|
|
ui->spinSettingNumerPerPages->setValue(numPagesPerPreview);
|
2022-06-14 10:58:38 +02:00
|
|
|
ui->txtSettingDatabasePath->setText(databasePath);
|
2022-08-21 22:57:46 +02:00
|
|
|
bool horizontalScroll = settings.value(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY).toBool();
|
|
|
|
ui->radioScrollHorizontally->setChecked(horizontalScroll);
|
|
|
|
ui->radioScrollVertically->setChecked(!horizontalScroll);
|
2022-06-13 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::saveSettings()
|
|
|
|
{
|
2022-08-14 10:41:31 +02:00
|
|
|
if(ui->chkRemoveOldDb->isChecked())
|
|
|
|
{
|
|
|
|
bool result = QFile::remove(Common::databasePath());
|
|
|
|
if(!result)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Error removing database",
|
|
|
|
"Failed to remove old database. Settings not saved.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-13 19:36:12 +02:00
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
QString pdfViewerCmd = ui->txtSettingPdfPreviewerCmd->text();
|
|
|
|
QStringList excludedPaths = ui->txtSettingIgnoredPaths->text().split(';');
|
|
|
|
QStringList mountPaths = ui->txtSettingMountPaths->text().split(';');
|
2022-06-14 10:58:38 +02:00
|
|
|
QString databasePath = ui->txtSettingDatabasePath->text();
|
2022-06-13 19:36:12 +02:00
|
|
|
|
|
|
|
settings.setValue(SETTINGS_KEY_PDFVIEWER, pdfViewerCmd);
|
|
|
|
settings.setValue(SETTINGS_KEY_EXCLUDEDPATHS, excludedPaths);
|
|
|
|
settings.setValue(SETTINGS_KEY_MOUNTPATHS, mountPaths);
|
|
|
|
settings.setValue(SETTINGS_KEY_PREVIEWSPERPAGE, ui->spinSettingNumerPerPages->value());
|
2022-06-14 10:58:38 +02:00
|
|
|
settings.setValue(SETTINGS_KEY_DBPATH, databasePath);
|
2022-08-21 22:57:46 +02:00
|
|
|
settings.setValue(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY, ui->radioScrollHorizontally->isChecked());
|
2022-06-13 19:36:12 +02:00
|
|
|
|
|
|
|
settings.sync();
|
|
|
|
|
|
|
|
QProcess::startDetached(qApp->arguments()[0], qApp->arguments().mid(1));
|
|
|
|
qApp->quit();
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
void MainWindow::previewReceived()
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2023-01-08 17:37:28 +01:00
|
|
|
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->value() + 1);
|
|
|
|
QBoxLayout *layout = static_cast<QBoxLayout *>(ui->scrollAreaWidgetContents->layout());
|
|
|
|
int index = layout->count();
|
|
|
|
if(index > 0)
|
2022-05-27 09:31:21 +02:00
|
|
|
{
|
2023-01-08 17:37:28 +01:00
|
|
|
--index;
|
2022-05-27 09:31:21 +02:00
|
|
|
}
|
2023-01-08 17:37:28 +01:00
|
|
|
QSharedPointer<PreviewResult> preview = this->previewCoordinator.resultAt(index);
|
|
|
|
|
2022-05-27 09:31:21 +02:00
|
|
|
if(!preview.isNull() && preview->hasPreview())
|
2019-04-30 14:13:10 +02:00
|
|
|
{
|
2022-01-03 23:02:21 +01:00
|
|
|
QString docPath = preview->getDocumentPath();
|
|
|
|
auto previewPage = preview->getPage();
|
2022-07-24 11:40:38 +02:00
|
|
|
ClickLabel *headerLabel = new ClickLabel();
|
|
|
|
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
|
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
2022-08-28 13:05:28 +02:00
|
|
|
label->setMaximumWidth(QApplication::desktop()->availableGeometry().width() - 200);
|
2022-07-24 11:40:38 +02:00
|
|
|
|
|
|
|
QVBoxLayout *previewLayout = new QVBoxLayout();
|
|
|
|
|
2022-07-23 20:21:45 +02:00
|
|
|
QFont font = label->font();
|
|
|
|
font.setPointSize(QApplication::font().pointSize() * currentSelectedScale() / 100);
|
|
|
|
label->setFont(font);
|
2022-07-24 11:40:38 +02:00
|
|
|
headerLabel->setFont(font);
|
|
|
|
|
|
|
|
auto leftClickHandler = [this, docPath, previewPage]() { openDocument(docPath, previewPage); };
|
|
|
|
auto rightClickhandler = [this, docPath, previewPage]()
|
|
|
|
{
|
|
|
|
QFileInfo fileInfo{docPath};
|
|
|
|
QMenu menu("labeRightClick", this);
|
2022-11-22 20:29:32 +01:00
|
|
|
createSearchResultMenu(menu, fileInfo);
|
2023-03-12 16:41:31 +01:00
|
|
|
menu.addAction("Copy page number", this,
|
2022-07-24 11:40:38 +02:00
|
|
|
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
|
|
|
menu.exec(QCursor::pos());
|
|
|
|
};
|
|
|
|
|
|
|
|
connect(label, &ClickLabel::leftClick, leftClickHandler);
|
|
|
|
connect(label, &ClickLabel::rightClick, rightClickhandler);
|
|
|
|
|
|
|
|
connect(headerLabel, &ClickLabel::rightClick, rightClickhandler);
|
|
|
|
|
|
|
|
previewLayout->addWidget(label);
|
|
|
|
|
|
|
|
previewLayout->addWidget(headerLabel);
|
|
|
|
|
|
|
|
previewLayout->setMargin(0);
|
|
|
|
previewLayout->insertStretch(0, 1);
|
|
|
|
previewLayout->insertStretch(-1, 1);
|
2022-08-28 13:04:01 +02:00
|
|
|
previewLayout->setAlignment(Qt::AlignCenter);
|
2022-07-24 11:40:38 +02:00
|
|
|
QWidget *previewWidget = new QWidget();
|
|
|
|
|
|
|
|
previewWidget->setLayout(previewLayout);
|
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
layout->insertWidget(index, previewWidget);
|
2019-04-30 14:13:10 +02:00
|
|
|
}
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::lineEditReturnPressed()
|
|
|
|
{
|
|
|
|
QString q = ui->txtSearch->text();
|
2021-06-12 14:59:58 +02:00
|
|
|
if(!LooqsQuery::checkParanthesis(q))
|
2018-09-02 13:54:27 +02:00
|
|
|
{
|
|
|
|
ui->lblSearchResults->setText("Invalid paranthesis");
|
|
|
|
return;
|
|
|
|
}
|
2022-06-13 19:36:12 +02:00
|
|
|
if(ui->tabWidget->currentIndex() > 1)
|
2022-06-04 15:55:32 +02:00
|
|
|
{
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
|
|
}
|
2018-09-02 12:27:23 +02:00
|
|
|
// TODO: validate q;
|
2022-08-21 17:28:04 +02:00
|
|
|
while(this->searchHistory.size() > 30)
|
|
|
|
{
|
|
|
|
this->searchHistory.removeFirst();
|
|
|
|
}
|
|
|
|
this->searchHistory.append(q);
|
|
|
|
this->currentSearchHistoryIndex = this->searchHistory.size();
|
|
|
|
this->currentSavedSearchText.clear();
|
|
|
|
|
2022-04-17 20:52:07 +02:00
|
|
|
ui->treeResultsList->clear();
|
2018-09-02 12:33:04 +02:00
|
|
|
ui->lblSearchResults->setText("Searching...");
|
2020-06-06 23:18:33 +02:00
|
|
|
this->ui->txtSearch->setEnabled(false);
|
2019-04-27 21:24:53 +02:00
|
|
|
QFuture<QVector<SearchResult>> searchFuture = QtConcurrent::run(
|
|
|
|
[&, q]()
|
|
|
|
{
|
|
|
|
SqliteSearch searcher(db);
|
2022-01-04 11:18:53 +01:00
|
|
|
QVector<SearchResult> results;
|
2022-07-29 00:53:09 +02:00
|
|
|
LooqsQuery tmpQuery = LooqsQuery::build(q, TokenType::WORD, true);
|
2021-12-30 12:17:12 +01:00
|
|
|
|
2022-07-29 00:53:09 +02:00
|
|
|
LooqsQuery pathsQuery = tmpQuery;
|
|
|
|
|
|
|
|
this->contentSearchQuery = tmpQuery;
|
|
|
|
|
|
|
|
bool addContentSearch = false;
|
|
|
|
bool addPathSearch = false;
|
|
|
|
|
|
|
|
auto createFinalTokens = [&tmpQuery](TokenType replacementToken)
|
2022-01-04 11:18:53 +01:00
|
|
|
{
|
2022-07-29 00:53:09 +02:00
|
|
|
QVector<Token> tokens = tmpQuery.getTokens();
|
|
|
|
for(Token &token : tokens)
|
2022-06-05 14:04:42 +02:00
|
|
|
{
|
2022-07-29 00:53:09 +02:00
|
|
|
if(token.type == TokenType::WORD)
|
|
|
|
{
|
|
|
|
token.type = replacementToken;
|
|
|
|
}
|
2022-06-05 14:04:42 +02:00
|
|
|
}
|
2022-07-29 00:53:09 +02:00
|
|
|
return tokens;
|
|
|
|
};
|
2022-06-05 14:04:42 +02:00
|
|
|
|
2022-07-30 09:35:56 +02:00
|
|
|
/* An explicit search, no lone words. We just pass it on */
|
2022-07-29 00:53:09 +02:00
|
|
|
if(!(tmpQuery.getTokensMask() & TokenType::WORD))
|
|
|
|
{
|
|
|
|
if(tmpQuery.hasContentSearch())
|
|
|
|
{
|
|
|
|
addContentSearch = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addPathSearch = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* A path search, and lone words, e. g. p:("docs") invoice */
|
|
|
|
else if(tmpQuery.hasPathSearch() && (tmpQuery.getTokensMask() & TokenType::WORD))
|
|
|
|
{
|
|
|
|
this->contentSearchQuery = tmpQuery;
|
|
|
|
this->contentSearchQuery.setTokens(createFinalTokens(TokenType::FILTER_CONTENT_CONTAINS));
|
|
|
|
addContentSearch = true;
|
|
|
|
addPathSearch = false;
|
|
|
|
}
|
|
|
|
/* A content search and lone words, e. g. c:("to be or not") ebooks */
|
|
|
|
else if(tmpQuery.hasContentSearch() && (tmpQuery.getTokensMask() & TokenType::WORD))
|
|
|
|
{
|
2022-07-30 09:35:56 +02:00
|
|
|
this->contentSearchQuery = LooqsQuery::build(q, TokenType::FILTER_PATH_CONTAINS, false);
|
2022-07-29 00:53:09 +02:00
|
|
|
addContentSearch = true;
|
|
|
|
addPathSearch = false;
|
|
|
|
}
|
|
|
|
/* "Simply lone words, so search both" */
|
|
|
|
else if(!tmpQuery.hasPathSearch() && !tmpQuery.hasContentSearch())
|
|
|
|
{
|
|
|
|
this->contentSearchQuery.setTokens(createFinalTokens(TokenType::FILTER_CONTENT_CONTAINS));
|
2022-07-30 09:35:56 +02:00
|
|
|
pathsQuery = LooqsQuery::build(q, TokenType::FILTER_PATH_CONTAINS, false);
|
2022-07-29 00:53:09 +02:00
|
|
|
addContentSearch = true;
|
|
|
|
addPathSearch = true;
|
|
|
|
}
|
|
|
|
if(addPathSearch)
|
|
|
|
{
|
|
|
|
if(pathsQuery.getLimit() == -1)
|
|
|
|
{
|
|
|
|
pathsQuery.setLimit(1000);
|
|
|
|
}
|
|
|
|
results.append(searcher.search(pathsQuery));
|
2022-01-04 11:18:53 +01:00
|
|
|
}
|
|
|
|
if(addContentSearch)
|
|
|
|
{
|
2022-06-05 14:04:42 +02:00
|
|
|
if(this->contentSearchQuery.getLimit() == -1)
|
|
|
|
{
|
|
|
|
this->contentSearchQuery.setLimit(1000);
|
|
|
|
}
|
2022-01-04 11:18:53 +01:00
|
|
|
results.append(searcher.search(this->contentSearchQuery));
|
|
|
|
}
|
2022-07-30 09:35:56 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this->contentSearchQuery.setTokens({});
|
|
|
|
}
|
2021-12-30 12:17:12 +01:00
|
|
|
return results;
|
2019-04-27 21:24:53 +02:00
|
|
|
});
|
|
|
|
searchWatcher.setFuture(searchFuture);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
|
|
|
|
{
|
2022-08-06 10:10:42 +02:00
|
|
|
qDeleteAll(ui->scrollAreaWidgetContents->children());
|
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
ui->treeResultsList->clear();
|
2022-06-29 12:40:04 +02:00
|
|
|
ui->comboPreviewFiles->clear();
|
|
|
|
ui->comboPreviewFiles->addItem("All previews");
|
|
|
|
ui->comboPreviewFiles->setVisible(true);
|
2022-08-27 12:02:12 +02:00
|
|
|
ui->lblTotalPreviewPagesCount->setText("");
|
2021-03-27 18:18:19 +01:00
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
this->previewCoordinator.init(results);
|
|
|
|
|
2021-03-27 18:18:19 +01:00
|
|
|
bool hasDeleted = false;
|
2022-08-23 23:30:10 +02:00
|
|
|
QHash<QString, bool> seenMap;
|
2018-08-12 16:45:39 +02:00
|
|
|
for(const SearchResult &result : results)
|
|
|
|
{
|
2022-08-23 23:30:10 +02:00
|
|
|
const QString &absPath = result.fileData.absPath;
|
|
|
|
QFileInfo pathInfo(absPath);
|
2021-03-27 18:18:19 +01:00
|
|
|
|
2022-08-23 23:30:10 +02:00
|
|
|
if(!seenMap.contains(absPath))
|
|
|
|
{
|
|
|
|
QString fileName = pathInfo.fileName();
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeResultsList);
|
|
|
|
|
|
|
|
QDateTime dt = QDateTime::fromSecsSinceEpoch(result.fileData.mtime);
|
|
|
|
item->setIcon(0, iconProvider.icon(pathInfo));
|
|
|
|
item->setText(0, fileName);
|
|
|
|
item->setText(1, absPath);
|
|
|
|
item->setText(2, dt.toString(Qt::ISODate));
|
|
|
|
item->setText(3, this->locale().formattedDataSize(result.fileData.size));
|
|
|
|
}
|
2021-03-27 18:18:19 +01:00
|
|
|
bool exists = pathInfo.exists();
|
2023-01-08 17:37:28 +01:00
|
|
|
if(!exists)
|
2021-03-27 18:18:19 +01:00
|
|
|
{
|
2023-01-08 17:37:28 +01:00
|
|
|
hasDeleted = true;
|
2021-03-27 18:18:19 +01:00
|
|
|
}
|
2023-01-08 17:37:28 +01:00
|
|
|
seenMap[absPath] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
seenMap.clear();
|
|
|
|
for(const SearchResult &result : this->previewCoordinator.getPreviewableSearchResults())
|
|
|
|
{
|
|
|
|
const QString &absPath = result.fileData.absPath;
|
|
|
|
if(!seenMap.contains(absPath))
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2023-01-08 17:37:28 +01:00
|
|
|
ui->comboPreviewFiles->addItem(absPath);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
2022-08-27 12:02:12 +02:00
|
|
|
seenMap[absPath] = true;
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
2022-08-23 23:30:10 +02:00
|
|
|
|
2018-08-12 16:45:39 +02:00
|
|
|
ui->treeResultsList->resizeColumnToContents(0);
|
|
|
|
ui->treeResultsList->resizeColumnToContents(1);
|
2022-05-29 17:04:08 +02:00
|
|
|
ui->treeResultsList->resizeColumnToContents(2);
|
2023-01-08 17:37:28 +01:00
|
|
|
|
|
|
|
previewDirty = this->previewCoordinator.previewableCount() > 0;
|
2019-08-26 09:20:21 +02:00
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
ui->spinPreviewPage->setValue(1);
|
2022-05-29 10:09:24 +02:00
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
if(previewTabActive() && previewDirty)
|
2018-09-02 12:27:23 +02:00
|
|
|
{
|
2022-01-03 23:02:21 +01:00
|
|
|
makePreviews(1);
|
2018-09-02 12:27:23 +02:00
|
|
|
}
|
2021-03-27 18:18:19 +01:00
|
|
|
|
2023-03-26 15:53:40 +02:00
|
|
|
ui->tabWidget->setTabEnabled(1, previewDirty);
|
|
|
|
|
2021-03-27 18:18:19 +01:00
|
|
|
QString statusText = "Results: " + QString::number(results.size()) + " files";
|
2023-01-08 17:37:28 +01:00
|
|
|
statusText += ", previewable: " + QString::number(this->previewCoordinator.previewableCount());
|
2021-03-27 18:18:19 +01:00
|
|
|
if(hasDeleted)
|
|
|
|
{
|
2022-06-05 11:14:10 +02:00
|
|
|
statusText += " WARNING: Some files are inaccessible. No preview available for those. Index may be out of sync";
|
2021-03-27 18:18:19 +01:00
|
|
|
}
|
|
|
|
ui->lblSearchResults->setText(statusText);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:21:45 +02:00
|
|
|
int MainWindow::currentSelectedScale()
|
|
|
|
{
|
|
|
|
QString scaleText = ui->comboScale->currentText();
|
|
|
|
scaleText.chop(1);
|
|
|
|
return scaleText.toInt();
|
|
|
|
}
|
|
|
|
|
2022-01-03 23:02:21 +01:00
|
|
|
void MainWindow::makePreviews(int page)
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2023-01-08 17:37:28 +01:00
|
|
|
if(this->previewCoordinator.previewableCount() == 0)
|
2022-05-27 09:31:21 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-08-12 16:45:39 +02:00
|
|
|
qDeleteAll(ui->scrollAreaWidgetContents->children());
|
|
|
|
|
2022-08-21 22:57:46 +02:00
|
|
|
QSettings settings;
|
|
|
|
bool horizontalScroll = settings.value(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY, false).toBool();
|
|
|
|
if(horizontalScroll)
|
|
|
|
{
|
|
|
|
ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
|
|
|
|
ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignCenter);
|
|
|
|
}
|
2023-01-08 17:37:28 +01:00
|
|
|
ui->previewProcessBar->setMaximum(this->previewCoordinator.previewableCount());
|
2019-08-18 23:23:11 +02:00
|
|
|
|
|
|
|
QVector<QString> wordsToHighlight;
|
2023-03-12 16:41:31 +01:00
|
|
|
static QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
|
2021-12-30 12:17:12 +01:00
|
|
|
for(const Token &token : this->contentSearchQuery.getTokens())
|
2019-08-18 23:23:11 +02:00
|
|
|
{
|
|
|
|
if(token.type == FILTER_CONTENT_CONTAINS)
|
|
|
|
{
|
2019-08-19 19:43:05 +02:00
|
|
|
QRegularExpressionMatchIterator i = extractor.globalMatch(token.value);
|
|
|
|
while(i.hasNext())
|
2019-08-18 23:23:11 +02:00
|
|
|
{
|
2019-08-19 19:43:05 +02:00
|
|
|
QRegularExpressionMatch m = i.next();
|
|
|
|
QString value = m.captured(1);
|
|
|
|
if(value.isEmpty())
|
|
|
|
{
|
|
|
|
value = m.captured(2);
|
|
|
|
}
|
|
|
|
wordsToHighlight.append(value);
|
2019-08-18 23:23:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-18 22:03:11 +01:00
|
|
|
int length = previewsPerPage;
|
|
|
|
int beginOffset = page * previewsPerPage - previewsPerPage;
|
|
|
|
if(beginOffset < 0)
|
2022-05-29 10:09:24 +02:00
|
|
|
{
|
|
|
|
// Should not happen actually
|
2022-11-18 22:03:11 +01:00
|
|
|
beginOffset = 0;
|
2022-05-29 10:09:24 +02:00
|
|
|
}
|
2022-05-27 09:31:21 +02:00
|
|
|
|
2022-07-23 20:21:45 +02:00
|
|
|
int currentScale = currentSelectedScale();
|
2022-05-27 09:31:21 +02:00
|
|
|
RenderConfig renderConfig;
|
2022-07-23 20:21:45 +02:00
|
|
|
renderConfig.scaleX = QGuiApplication::primaryScreen()->physicalDotsPerInchX() * (currentScale / 100.);
|
|
|
|
renderConfig.scaleY = QGuiApplication::primaryScreen()->physicalDotsPerInchY() * (currentScale / 100.);
|
2022-05-27 09:31:21 +02:00
|
|
|
renderConfig.wordsToHighlight = wordsToHighlight;
|
|
|
|
|
|
|
|
QVector<RenderTarget> targets;
|
2023-01-08 17:37:28 +01:00
|
|
|
for(const SearchResult &sr : this->previewCoordinator.getPreviewableSearchResults())
|
2022-05-27 09:31:21 +02:00
|
|
|
{
|
2022-06-29 12:40:04 +02:00
|
|
|
if(ui->comboPreviewFiles->currentIndex() != 0)
|
|
|
|
{
|
|
|
|
if(sr.fileData.absPath != ui->comboPreviewFiles->currentText())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2022-05-27 09:31:21 +02:00
|
|
|
RenderTarget renderTarget;
|
|
|
|
renderTarget.path = sr.fileData.absPath;
|
2022-08-24 00:00:09 +02:00
|
|
|
renderTarget.page = (int)sr.page;
|
2022-11-18 22:03:11 +01:00
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
targets.append(renderTarget);
|
2022-05-27 09:31:21 +02:00
|
|
|
}
|
2022-05-29 10:09:24 +02:00
|
|
|
int numpages = ceil(static_cast<double>(targets.size()) / previewsPerPage);
|
|
|
|
ui->spinPreviewPage->setMaximum(numpages);
|
2022-11-18 22:03:11 +01:00
|
|
|
targets = targets.mid(beginOffset, length);
|
2022-05-29 10:09:24 +02:00
|
|
|
|
2022-05-29 10:13:02 +02:00
|
|
|
ui->lblTotalPreviewPagesCount->setText(QString::number(numpages));
|
2022-05-27 09:31:21 +02:00
|
|
|
ui->previewProcessBar->setMaximum(targets.count());
|
|
|
|
ui->previewProcessBar->setMinimum(0);
|
|
|
|
ui->previewProcessBar->setValue(0);
|
2023-01-08 17:37:28 +01:00
|
|
|
ui->previewProcessBar->setVisible(this->previewCoordinator.previewableCount() > 0);
|
2022-05-29 10:51:44 +02:00
|
|
|
this->ui->spinPreviewPage->setEnabled(false);
|
2022-06-29 12:40:04 +02:00
|
|
|
this->ui->comboPreviewFiles->setEnabled(false);
|
2022-08-23 17:37:01 +02:00
|
|
|
this->ui->txtSearch->setEnabled(false);
|
2023-01-08 17:37:28 +01:00
|
|
|
|
|
|
|
this->previewCoordinator.startGeneration(renderConfig, targets);
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2018-09-02 13:54:27 +02:00
|
|
|
void MainWindow::handleSearchError(QString error)
|
|
|
|
{
|
|
|
|
ui->lblSearchResults->setText("Error:" + error);
|
|
|
|
}
|
|
|
|
|
2022-11-22 20:29:32 +01:00
|
|
|
void MainWindow::createSearchResultMenu(QMenu &menu, const QFileInfo &fileInfo)
|
2021-03-27 17:58:38 +01:00
|
|
|
{
|
2023-03-12 16:41:31 +01:00
|
|
|
menu.addAction("Copy filename to clipboard", this,
|
2021-03-27 17:58:38 +01:00
|
|
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
|
2023-03-12 16:41:31 +01:00
|
|
|
menu.addAction("Copy full path to clipboard", this,
|
2021-03-27 17:58:38 +01:00
|
|
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
|
2023-03-12 16:41:31 +01:00
|
|
|
menu.addAction("Open containing folder", this, [this, &fileInfo] { this->openFile(fileInfo.absolutePath()); });
|
2022-06-29 12:40:04 +02:00
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
auto previewables = this->previewCoordinator.getPreviewableSearchResults();
|
2022-06-29 12:40:04 +02:00
|
|
|
auto result =
|
2023-01-08 17:37:28 +01:00
|
|
|
std::find_if(previewables.begin(), previewables.end(),
|
2023-03-12 16:41:31 +01:00
|
|
|
[&fileInfo](SearchResult &a) { return fileInfo.absoluteFilePath() == a.fileData.absPath; });
|
2022-06-29 12:40:04 +02:00
|
|
|
|
2023-01-08 17:37:28 +01:00
|
|
|
if(result != previewables.end())
|
2022-06-29 12:40:04 +02:00
|
|
|
{
|
2023-03-12 16:41:31 +01:00
|
|
|
menu.addAction("Show previews for this file", this,
|
2022-06-29 12:40:04 +02:00
|
|
|
[this, &fileInfo]
|
|
|
|
{
|
|
|
|
ui->tabWidget->setCurrentIndex(1);
|
|
|
|
this->ui->comboPreviewFiles->setCurrentText(fileInfo.absoluteFilePath());
|
|
|
|
});
|
|
|
|
}
|
2023-04-10 18:29:27 +02:00
|
|
|
|
|
|
|
QMenu *tagMenu = menu.addMenu("Tag file with: ");
|
|
|
|
QVector<QString> allTags = this->dbService->getTags();
|
|
|
|
QHash<QString, bool> fileTags;
|
|
|
|
|
|
|
|
QString path = fileInfo.absoluteFilePath();
|
|
|
|
|
|
|
|
for(const QString &fileTag : this->dbService->getTagsForPath(path))
|
|
|
|
{
|
|
|
|
fileTags[fileTag] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(const QString &tag : allTags)
|
|
|
|
{
|
|
|
|
QCheckBox *checkBox = new QCheckBox(tagMenu);
|
|
|
|
QWidgetAction *checkableAction = new QWidgetAction(tagMenu);
|
|
|
|
checkableAction->setDefaultWidget(checkBox);
|
|
|
|
checkBox->setText(tag);
|
|
|
|
checkBox->setChecked(fileTags.contains(tag));
|
|
|
|
tagMenu->addAction(checkableAction);
|
|
|
|
|
|
|
|
connect(checkBox, &QCheckBox::stateChanged, this,
|
|
|
|
[this, checkBox, path]
|
|
|
|
{
|
|
|
|
QVector<QString> currentTags = this->dbService->getTagsForPath(path);
|
|
|
|
QString checkBoxText = checkBox->text();
|
|
|
|
if(checkBox->isChecked())
|
|
|
|
{
|
|
|
|
if(!this->tagManager->addTagsToPath(path, {checkBoxText}))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Error while adding tag",
|
|
|
|
"An error occured while trying to add the tag");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!this->tagManager->removeTagsForPath(path, {checkBoxText}))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Error while removing tag",
|
|
|
|
"An error occured while trying to remove the tag");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
tagMenu->addAction("Add new tags", this,
|
|
|
|
[this, path]
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
QString text =
|
|
|
|
QInputDialog::getText(this, tr("Enter new tags"), tr("New tags (comma separated):"),
|
|
|
|
QLineEdit::Normal, "", &ok);
|
|
|
|
|
|
|
|
if(ok && !this->tagManager->addTagsToPath(path, text, ','))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "Error while trying to add tags",
|
|
|
|
"An error occured while trying to add tags");
|
|
|
|
}
|
|
|
|
});
|
2021-09-28 21:44:09 +02:00
|
|
|
}
|
|
|
|
|
2022-05-28 22:02:54 +02:00
|
|
|
void MainWindow::openDocument(QString path, int num)
|
2021-09-28 21:44:09 +02:00
|
|
|
{
|
2022-05-28 22:02:54 +02:00
|
|
|
QSettings settings;
|
|
|
|
QString command = settings.value("pdfviewer").toString();
|
|
|
|
if(path.endsWith(".pdf") && command != "" && command.contains("%p") && command.contains("%f"))
|
|
|
|
{
|
|
|
|
QStringList splitted = command.split(" ");
|
|
|
|
if(splitted.size() > 1)
|
|
|
|
{
|
|
|
|
QString cmd = splitted[0];
|
|
|
|
QStringList args = splitted.mid(1);
|
|
|
|
args.replaceInStrings("%f", path);
|
|
|
|
args.replaceInStrings("%p", QString::number(num));
|
|
|
|
QProcess::startDetached(cmd, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
|
|
|
}
|
2021-09-28 21:44:09 +02:00
|
|
|
}
|
|
|
|
|
2022-05-28 22:02:54 +02:00
|
|
|
void MainWindow::openFile(QString path)
|
2021-09-28 21:44:09 +02:00
|
|
|
{
|
2022-05-28 22:02:54 +02:00
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
2021-03-27 17:58:38 +01:00
|
|
|
}
|
|
|
|
|
2023-03-12 16:41:31 +01:00
|
|
|
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int /*i*/)
|
2018-08-12 16:45:39 +02:00
|
|
|
{
|
2022-05-28 22:02:54 +02:00
|
|
|
openFile(item->text(1));
|
2018-08-12 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = ui->treeResultsList->itemAt(point);
|
|
|
|
if(item == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-03-27 17:58:38 +01:00
|
|
|
QFileInfo pathinfo(item->text(1));
|
|
|
|
QMenu menu("SearchResults", this);
|
2022-11-22 20:29:32 +01:00
|
|
|
createSearchResultMenu(menu, pathinfo);
|
2018-08-12 16:45:39 +02:00
|
|
|
menu.exec(QCursor::pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2022-06-04 15:49:29 +02:00
|
|
|
syncerThread.terminate();
|
|
|
|
delete this->indexSyncer;
|
|
|
|
delete this->dbService;
|
|
|
|
delete this->dbFactory;
|
|
|
|
delete this->indexer;
|
2023-04-10 18:29:27 +02:00
|
|
|
delete this->tagManager;
|
2018-08-12 16:45:39 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
2022-08-21 17:47:34 +02:00
|
|
|
|
2023-03-12 16:41:31 +01:00
|
|
|
void MainWindow::closeEvent(QCloseEvent * /*event*/)
|
2022-08-21 17:47:34 +02:00
|
|
|
{
|
|
|
|
QStringList list = this->searchHistory.toList();
|
|
|
|
QSettings settings;
|
|
|
|
settings.setValue(SETTINGS_KEY_SEARCHHISTORY, list);
|
|
|
|
settings.sync();
|
|
|
|
}
|