GUI: Begin new 'Indexer' tab
This commit is contained in:
parent
be41fab5d5
commit
0af7d4a3dc
@ -53,13 +53,15 @@ FORMS += \
|
|||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
INCLUDEPATH += /usr/include/poppler/qt5/
|
INCLUDEPATH += /usr/include/poppler/qt5/
|
||||||
LIBS += -lpoppler-qt5
|
|
||||||
QT += widgets sql
|
QT += widgets sql
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../shared/release/ -lshared
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../shared/release/ -lshared
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../shared/debug/ -lshared
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../shared/debug/ -lshared
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../shared/ -lshared
|
else:unix: LIBS += -L$$OUT_PWD/../shared/ -lshared
|
||||||
|
|
||||||
|
LIBS += -luchardet -lpoppler-qt5 -lquazip5
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../shared
|
INCLUDEPATH += $$PWD/../shared
|
||||||
DEPENDPATH += $$PWD/../shared
|
DEPENDPATH += $$PWD/../shared
|
||||||
|
|
||||||
|
18
gui/main.cpp
18
gui/main.cpp
@ -10,6 +10,7 @@
|
|||||||
#include "searchresult.h"
|
#include "searchresult.h"
|
||||||
#include "previewresultpdf.h"
|
#include "previewresultpdf.h"
|
||||||
#include "../shared/common.h"
|
#include "../shared/common.h"
|
||||||
|
#include "../shared/sandboxedprocessor.h"
|
||||||
#include "../submodules/exile.h/exile.h"
|
#include "../submodules/exile.h/exile.h"
|
||||||
#include "ipcserver.h"
|
#include "ipcserver.h"
|
||||||
|
|
||||||
@ -82,6 +83,22 @@ int main(int argc, char *argv[])
|
|||||||
qDebug() << "Launched IPC Server";
|
qDebug() << "Launched IPC Server";
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
if(arg == "process")
|
||||||
|
{
|
||||||
|
Common::setupAppInfo();
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
QStringList args = a.arguments();
|
||||||
|
if(args.length() < 1)
|
||||||
|
{
|
||||||
|
qDebug() << "Filename is required";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString file = args.at(1);
|
||||||
|
SandboxedProcessor processor(file);
|
||||||
|
return processor.process();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QProcess process;
|
QProcess process;
|
||||||
QStringList args;
|
QStringList args;
|
||||||
@ -126,6 +143,7 @@ int main(int argc, char *argv[])
|
|||||||
qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>");
|
qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>");
|
||||||
qRegisterMetaType<QVector<PreviewResultPdf>>("QVector<PreviewResultPdf>");
|
qRegisterMetaType<QVector<PreviewResultPdf>>("QVector<PreviewResultPdf>");
|
||||||
qRegisterMetaType<PreviewResultPdf>("PreviewResultPdf");
|
qRegisterMetaType<PreviewResultPdf>("PreviewResultPdf");
|
||||||
|
qRegisterMetaType<FileScanResult>("FileScanResult");
|
||||||
|
|
||||||
IPCClient client{socketPath};
|
IPCClient client{socketPath};
|
||||||
MainWindow w{0, client};
|
MainWindow w{0, client};
|
||||||
|
@ -25,13 +25,13 @@ MainWindow::MainWindow(QWidget *parent, IPCClient &client) : QMainWindow(parent)
|
|||||||
this->ipcClient = &client;
|
this->ipcClient = &client;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
db = QSqlDatabase::addDatabase("QSQLITE");
|
this->dbFactory = new DatabaseFactory(Common::databasePath());
|
||||||
db.setDatabaseName(Common::databasePath());
|
|
||||||
if(!db.open())
|
db = this->dbFactory->forCurrentThread();
|
||||||
{
|
this->dbService = new SqliteDbService(*this->dbFactory);
|
||||||
qDebug() << "failed to open database";
|
|
||||||
throw std::runtime_error("Failed to open database");
|
indexer = new Indexer(*(this->dbService));
|
||||||
}
|
indexer->setParent(this);
|
||||||
connectSignals();
|
connectSignals();
|
||||||
ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
@ -71,6 +71,41 @@ void MainWindow::connectSignals()
|
|||||||
connect(ui->comboScale, qOverload<int>(&QComboBox::currentIndexChanged), this, &MainWindow::comboScaleChanged);
|
connect(ui->comboScale, qOverload<int>(&QComboBox::currentIndexChanged), this, &MainWindow::comboScaleChanged);
|
||||||
connect(ui->spinPreviewPage, qOverload<int>(&QSpinBox::valueChanged), this,
|
connect(ui->spinPreviewPage, qOverload<int>(&QSpinBox::valueChanged), this,
|
||||||
&MainWindow::spinPreviewPageValueChanged);
|
&MainWindow::spinPreviewPageValueChanged);
|
||||||
|
|
||||||
|
connect(ui->btnAddPath, &QPushButton::clicked, this,
|
||||||
|
[&]
|
||||||
|
{
|
||||||
|
this->ui->lstPaths->addItem(this->ui->txtPathScanAdd->text());
|
||||||
|
this->ui->txtPathScanAdd->clear();
|
||||||
|
});
|
||||||
|
connect(ui->txtPathScanAdd, &QLineEdit::returnPressed, this,
|
||||||
|
[&]
|
||||||
|
{
|
||||||
|
this->ui->lstPaths->addItem(this->ui->txtPathScanAdd->text());
|
||||||
|
this->ui->txtPathScanAdd->clear();
|
||||||
|
});
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::spinPreviewPageValueChanged(int val)
|
void MainWindow::spinPreviewPageValueChanged(int val)
|
||||||
@ -78,17 +113,49 @@ void MainWindow::spinPreviewPageValueChanged(int val)
|
|||||||
makePreviews(val);
|
makePreviews(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::startIndexing()
|
||||||
|
{
|
||||||
|
ui->txtPathScanAdd->setEnabled(false);
|
||||||
|
ui->txtSearch->setEnabled(false);
|
||||||
|
ui->previewProcessBar->setValue(0);
|
||||||
|
|
||||||
|
QVector<QString> paths;
|
||||||
|
for(int i = 0; i < ui->lstPaths->count(); i++)
|
||||||
|
{
|
||||||
|
paths.append(ui->lstPaths->item(i)->text());
|
||||||
|
}
|
||||||
|
this->indexer->setTargetPaths(paths);
|
||||||
|
this->indexer->beginIndexing();
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::comboScaleChanged(int i)
|
void MainWindow::comboScaleChanged(int i)
|
||||||
{
|
{
|
||||||
QSettings scaleSetting;
|
QSettings scaleSetting;
|
||||||
scaleSetting.setValue("currentScale", ui->comboScale->currentText());
|
scaleSetting.setValue("currentScale", ui->comboScale->currentText());
|
||||||
makePreviews(ui->spinPreviewPage->value());
|
makePreviews(ui->spinPreviewPage->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::previewTabActive()
|
bool MainWindow::previewTabActive()
|
||||||
{
|
{
|
||||||
return ui->tabWidget->currentIndex() == 1;
|
return ui->tabWidget->currentIndex() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::indexerTabActive()
|
||||||
|
{
|
||||||
|
return ui->tabWidget->currentIndex() == 2;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
bool quit =
|
bool quit =
|
||||||
@ -112,7 +179,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
void MainWindow::tabChanged()
|
void MainWindow::tabChanged()
|
||||||
{
|
{
|
||||||
if(previewTabActive())
|
if(previewTabActive() || indexerTabActive())
|
||||||
{
|
{
|
||||||
if(previewDirty)
|
if(previewDirty)
|
||||||
{
|
{
|
||||||
@ -120,6 +187,7 @@ void MainWindow::tabChanged()
|
|||||||
}
|
}
|
||||||
ui->previewProcessBar->show();
|
ui->previewProcessBar->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->previewProcessBar->hide();
|
ui->previewProcessBar->hide();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "previewworker.h"
|
#include "previewworker.h"
|
||||||
#include "../shared/looqsquery.h"
|
#include "../shared/looqsquery.h"
|
||||||
#include "ipcclient.h"
|
#include "ipcclient.h"
|
||||||
|
#include "indexer.h"
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -29,8 +30,11 @@ class MainWindow : public QMainWindow
|
|||||||
void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor);
|
void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DatabaseFactory *dbFactory;
|
||||||
|
SqliteDbService *dbService;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
IPCClient *ipcClient;
|
IPCClient *ipcClient;
|
||||||
|
Indexer *indexer;
|
||||||
QFileIconProvider iconProvider;
|
QFileIconProvider iconProvider;
|
||||||
bool previewDirty;
|
bool previewDirty;
|
||||||
QSqlDatabase db;
|
QSqlDatabase db;
|
||||||
@ -41,6 +45,7 @@ class MainWindow : public QMainWindow
|
|||||||
void connectSignals();
|
void connectSignals();
|
||||||
void makePreviews(int page);
|
void makePreviews(int page);
|
||||||
bool previewTabActive();
|
bool previewTabActive();
|
||||||
|
bool indexerTabActive();
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
unsigned int processedPdfPreviews;
|
unsigned int processedPdfPreviews;
|
||||||
void handleSearchResults(const QVector<SearchResult> &results);
|
void handleSearchResults(const QVector<SearchResult> &results);
|
||||||
@ -59,6 +64,8 @@ class MainWindow : public QMainWindow
|
|||||||
void previewReceived(QSharedPointer<PreviewResult> preview);
|
void previewReceived(QSharedPointer<PreviewResult> preview);
|
||||||
void comboScaleChanged(int i);
|
void comboScaleChanged(int i);
|
||||||
void spinPreviewPageValueChanged(int val);
|
void spinPreviewPageValueChanged(int val);
|
||||||
|
void startIndexing();
|
||||||
|
void finishIndexing();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1221</width>
|
<width>1221</width>
|
||||||
<height>614</height>
|
<height>674</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<enum>QTabWidget::South</enum>
|
<enum>QTabWidget::South</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="resultsTab">
|
<widget class="QWidget" name="resultsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1185</width>
|
<width>1185</width>
|
||||||
<height>324</height>
|
<height>419</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
@ -172,6 +172,168 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="indexerTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Index</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBoxPaths">
|
||||||
|
<property name="title">
|
||||||
|
<string>Add paths to scan</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLineEdit" name="txtPathScanAdd"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="5">
|
||||||
|
<widget class="QListWidget" name="lstPaths"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QToolButton" name="toolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="btnChoosePath">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="btnAddPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore patterns, separated by ';'. Example: *.js;*Downloads*</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBoxIndexProgress">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::PreventContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Index Progress</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblPathsFound">
|
||||||
|
<property name="text">
|
||||||
|
<string>Paths found:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblPathsFoundValue">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblAdded">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Added:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblAddedValue">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblSkipped">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Skipped:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblSkippedValue">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblFailed">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Failed:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblFailedValue">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QPushButton" name="btnStartIndexing">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start indexing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -190,16 +352,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1221</width>
|
|
||||||
<height>35</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user