İşlemeleri karşılaştır

..

Ortak bir işleme yok. "dbe4061c5833ae6e1fe2a3f7cba7ee4b871861c5" ve "20a1f8b2cd2687df95732ff32ebd6a497b48bdae" tamamen farklı geçmişlere sahip.

7 değiştirilmiş dosya ile 84 ekleme ve 202 silme

Dosyayı Görüntüle

@ -34,7 +34,6 @@ SOURCES += \
main.cpp \
mainwindow.cpp \
clicklabel.cpp \
previewcoordinator.cpp \
previewgenerator.cpp \
previewgeneratormapfunctor.cpp \
previewgeneratorodt.cpp \
@ -55,7 +54,6 @@ HEADERS += \
ipcserver.h \
mainwindow.h \
clicklabel.h \
previewcoordinator.h \
previewgenerator.h \
previewgeneratormapfunctor.h \
previewgeneratorodt.h \

Dosyayı Görüntüle

@ -28,7 +28,7 @@ void enableIpcSandbox()
policy->namespace_options = EXILE_UNSHARE_USER | EXILE_UNSHARE_MOUNT | EXILE_UNSHARE_NETWORK;
policy->no_new_privs = 1;
policy->drop_caps = 1;
policy->vow_promises = exile_vows_from_str("thread cpath rpath wpath unix stdio proc error");
policy->vow_promises = exile_vows_from_str("thread cpath rpath unix stdio proc error");
policy->mount_path_policies_to_chroot = 1;
QString ipcSocketPath = Common::ipcSocketPath();

Dosyayı Görüntüle

@ -22,6 +22,7 @@
#include "../shared/sqlitesearch.h"
#include "../shared/looqsgeneralexception.h"
#include "../shared/common.h"
#include "ipcpreviewclient.h"
#include "previewgenerator.h"
#include "aboutdialog.h"
@ -31,7 +32,8 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
this->progressDialog.cancel(); // because constructing it shows it, quite weird
ui->setupUi(this);
setWindowTitle(QCoreApplication::applicationName());
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
this->ipcPreviewClient.setSocketPath(socketPath);
QSettings settings;
this->dbFactory = new DatabaseFactory(Common::databasePath());
@ -76,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
ui->txtSearch->installEventFilter(this);
ui->scrollArea->viewport()->installEventFilter(this);
this->previewCoordinator.setSocketPath(socketPath);
this->ipcClientThread.start();
}
void MainWindow::addPathToIndex()
@ -206,9 +208,9 @@ void MainWindow::connectSignals()
}
},
Qt::QueuedConnection);
connect(&previewCoordinator, &PreviewCoordinator::previewReady, this, &MainWindow::previewReceived,
connect(&ipcPreviewClient, &IPCPreviewClient::previewReceived, this, &MainWindow::previewReceived,
Qt::QueuedConnection);
connect(&previewCoordinator, &PreviewCoordinator::completedGeneration, this,
connect(&ipcPreviewClient, &IPCPreviewClient::finished, this,
[&]
{
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->maximum());
@ -216,17 +218,17 @@ void MainWindow::connectSignals()
this->ui->comboPreviewFiles->setEnabled(true);
ui->txtSearch->setEnabled(true);
});
connect(&previewCoordinator, &PreviewCoordinator::error, this,
connect(&ipcPreviewClient, &IPCPreviewClient::error, this,
[this](QString msg)
{
qCritical() << msg << Qt::endl;
QMessageBox::critical(this, "IPC error", msg);
});
/*connect(this, &MainWindow::startIpcPreviews, &previewCoordinator, &IPCPreviewClient::startGeneration,
connect(this, &MainWindow::startIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::startGeneration,
Qt::QueuedConnection);
connect(this, &MainWindow::stopIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::stopGeneration,
Qt::QueuedConnection); */
Qt::QueuedConnection);
}
void MainWindow::exportFailedPaths()
@ -630,17 +632,13 @@ void MainWindow::saveSettings()
qApp->quit();
}
void MainWindow::previewReceived()
void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration)
{
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->value() + 1);
QBoxLayout *layout = static_cast<QBoxLayout *>(ui->scrollAreaWidgetContents->layout());
int index = layout->count();
if(index > 0)
if(previewGeneration < this->currentPreviewGeneration)
{
--index;
return;
}
QSharedPointer<PreviewResult> preview = this->previewCoordinator.resultAt(index);
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->value() + 1);
if(!preview.isNull() && preview->hasPreview())
{
QString docPath = preview->getDocumentPath();
@ -663,7 +661,7 @@ void MainWindow::previewReceived()
{
QFileInfo fileInfo{docPath};
QMenu menu("labeRightClick", this);
createSearchResultMenu(menu, fileInfo);
createSearchResutlMenu(menu, fileInfo);
menu.addAction("Copy page number",
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
menu.exec(QCursor::pos());
@ -686,7 +684,24 @@ void MainWindow::previewReceived()
previewWidget->setLayout(previewLayout);
layout->insertWidget(index, previewWidget);
QBoxLayout *layout = static_cast<QBoxLayout *>(ui->scrollAreaWidgetContents->layout());
int pos = previewOrder[docPath + QString::number(previewPage)];
if(pos <= layout->count())
{
layout->insertWidget(pos, previewWidget);
for(auto it = previewWidgetOrderCache.constKeyValueBegin();
it != previewWidgetOrderCache.constKeyValueEnd(); it++)
{
if(it->first <= layout->count())
{
layout->insertWidget(it->first, it->second);
}
}
}
else
{
previewWidgetOrderCache[pos] = previewWidget;
}
}
}
@ -803,6 +818,7 @@ void MainWindow::lineEditReturnPressed()
void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
{
this->previewableSearchResults.clear();
qDeleteAll(ui->scrollAreaWidgetContents->children());
ui->treeResultsList->clear();
@ -811,8 +827,6 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
ui->comboPreviewFiles->setVisible(true);
ui->lblTotalPreviewPagesCount->setText("");
this->previewCoordinator.init(results);
bool hasDeleted = false;
QHash<QString, bool> seenMap;
for(const SearchResult &result : results)
@ -833,29 +847,34 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
item->setText(3, this->locale().formattedDataSize(result.fileData.size));
}
bool exists = pathInfo.exists();
if(!exists)
if(exists)
{
if(result.wasContentSearch)
{
if(!pathInfo.suffix().contains("htm")) // hack until we can preview them properly...
{
if(PreviewGenerator::get(pathInfo) != nullptr)
{
this->previewableSearchResults.append(result);
if(!seenMap.contains(result.fileData.absPath))
{
ui->comboPreviewFiles->addItem(result.fileData.absPath);
}
}
}
}
}
else
{
hasDeleted = true;
}
seenMap[absPath] = true;
}
seenMap.clear();
for(const SearchResult &result : this->previewCoordinator.getPreviewableSearchResults())
{
const QString &absPath = result.fileData.absPath;
if(!seenMap.contains(absPath))
{
ui->comboPreviewFiles->addItem(absPath);
}
seenMap[absPath] = true;
}
ui->treeResultsList->resizeColumnToContents(0);
ui->treeResultsList->resizeColumnToContents(1);
ui->treeResultsList->resizeColumnToContents(2);
previewDirty = this->previewCoordinator.previewableCount() > 0;
previewDirty = !this->previewableSearchResults.empty();
ui->spinPreviewPage->setValue(1);
@ -865,7 +884,7 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
}
QString statusText = "Results: " + QString::number(results.size()) + " files";
statusText += ", previewable: " + QString::number(this->previewCoordinator.previewableCount());
statusText += ", previewable: " + QString::number(this->previewableSearchResults.count());
if(hasDeleted)
{
statusText += " WARNING: Some files are inaccessible. No preview available for those. Index may be out of sync";
@ -882,7 +901,7 @@ int MainWindow::currentSelectedScale()
void MainWindow::makePreviews(int page)
{
if(this->previewCoordinator.previewableCount() == 0)
if(this->previewableSearchResults.empty())
{
return;
}
@ -899,7 +918,8 @@ void MainWindow::makePreviews(int page)
ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignCenter);
}
ui->previewProcessBar->setMaximum(this->previewCoordinator.previewableCount());
ui->previewProcessBar->setMaximum(this->previewableSearchResults.size());
processedPdfPreviews = 0;
QVector<QString> wordsToHighlight;
QRegularExpression extractor(R"#("([^"]*)"|([^\s]+))#");
@ -934,9 +954,12 @@ void MainWindow::makePreviews(int page)
renderConfig.scaleY = QGuiApplication::primaryScreen()->physicalDotsPerInchY() * (currentScale / 100.);
renderConfig.wordsToHighlight = wordsToHighlight;
this->previewOrder.clear();
this->previewWidgetOrderCache.clear();
int previewPos = 0;
QVector<RenderTarget> targets;
for(const SearchResult &sr : this->previewCoordinator.getPreviewableSearchResults())
for(SearchResult &sr : this->previewableSearchResults)
{
if(ui->comboPreviewFiles->currentIndex() != 0)
{
@ -948,8 +971,11 @@ void MainWindow::makePreviews(int page)
RenderTarget renderTarget;
renderTarget.path = sr.fileData.absPath;
renderTarget.page = (int)sr.page;
targets.append(renderTarget);
int pos = previewPos - beginOffset;
this->previewOrder[renderTarget.path + QString::number(renderTarget.page)] = pos;
++previewPos;
}
int numpages = ceil(static_cast<double>(targets.size()) / previewsPerPage);
ui->spinPreviewPage->setMaximum(numpages);
@ -959,12 +985,12 @@ void MainWindow::makePreviews(int page)
ui->previewProcessBar->setMaximum(targets.count());
ui->previewProcessBar->setMinimum(0);
ui->previewProcessBar->setValue(0);
ui->previewProcessBar->setVisible(this->previewCoordinator.previewableCount() > 0);
ui->previewProcessBar->setVisible(this->previewableSearchResults.size() > 0);
++this->currentPreviewGeneration;
this->ui->spinPreviewPage->setEnabled(false);
this->ui->comboPreviewFiles->setEnabled(false);
this->ui->txtSearch->setEnabled(false);
this->previewCoordinator.startGeneration(renderConfig, targets);
emit startIpcPreviews(renderConfig, targets);
}
void MainWindow::handleSearchError(QString error)
@ -972,7 +998,7 @@ void MainWindow::handleSearchError(QString error)
ui->lblSearchResults->setText("Error:" + error);
}
void MainWindow::createSearchResultMenu(QMenu &menu, const QFileInfo &fileInfo)
void MainWindow::createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo)
{
menu.addAction("Copy filename to clipboard",
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
@ -980,12 +1006,11 @@ void MainWindow::createSearchResultMenu(QMenu &menu, const QFileInfo &fileInfo)
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
menu.addAction("Open containing folder", [this, &fileInfo] { this->openFile(fileInfo.absolutePath()); });
auto previewables = this->previewCoordinator.getPreviewableSearchResults();
auto result =
std::find_if(previewables.begin(), previewables.end(),
std::find_if(this->previewableSearchResults.begin(), this->previewableSearchResults.end(),
[this, &fileInfo](SearchResult &a) { return fileInfo.absoluteFilePath() == a.fileData.absPath; });
if(result != previewables.end())
if(result != this->previewableSearchResults.end())
{
menu.addAction("Show previews for this file",
[this, &fileInfo]
@ -1037,13 +1062,14 @@ void MainWindow::showSearchResultsContextMenu(const QPoint &point)
}
QFileInfo pathinfo(item->text(1));
QMenu menu("SearchResults", this);
createSearchResultMenu(menu, pathinfo);
createSearchResutlMenu(menu, pathinfo);
menu.exec(QCursor::pos());
}
MainWindow::~MainWindow()
{
syncerThread.terminate();
ipcClientThread.terminate();
delete this->indexSyncer;
delete this->dbService;
delete this->dbFactory;

Dosyayı Görüntüle

@ -12,7 +12,7 @@
#include <QProgressDialog>
#include "../shared/looqsquery.h"
#include "../shared/indexsyncer.h"
#include "previewcoordinator.h"
#include "ipcpreviewclient.h"
#include "indexer.h"
namespace Ui
{
@ -27,9 +27,8 @@ class MainWindow : public QMainWindow
DatabaseFactory *dbFactory;
SqliteDbService *dbService;
Ui::MainWindow *ui;
PreviewCoordinator previewCoordinator;
IPCPreviewClient ipcPreviewClient;
QThread ipcClientThread;
QThread syncerThread;
Indexer *indexer;
IndexSyncer *indexSyncer;
@ -37,12 +36,18 @@ class MainWindow : public QMainWindow
QFileIconProvider iconProvider;
QSqlDatabase db;
QFutureWatcher<QVector<SearchResult>> searchWatcher;
QVector<SearchResult> previewableSearchResults;
LooqsQuery contentSearchQuery;
QVector<QString> searchHistory;
int currentSearchHistoryIndex = 0;
QString currentSavedSearchText;
QHash<QString, int> previewOrder; /* Quick lookup for the order a preview should have */
QMap<int, QWidget *>
previewWidgetOrderCache /* Saves those that arrived out of order to be inserted later at the correct pos */;
bool previewDirty = false;
int previewsPerPage = 20;
unsigned int processedPdfPreviews = 0;
unsigned int currentPreviewGeneration = 1;
void connectSignals();
void makePreviews(int page);
@ -51,7 +56,7 @@ class MainWindow : public QMainWindow
void keyPressEvent(QKeyEvent *event) override;
void handleSearchResults(const QVector<SearchResult> &results);
void handleSearchError(QString error);
void createSearchResultMenu(QMenu &menu, const QFileInfo &fileInfo);
void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo);
void openDocument(QString path, int num);
void openFile(QString path);
void initSettingsTabs();
@ -64,7 +69,7 @@ class MainWindow : public QMainWindow
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
void showSearchResultsContextMenu(const QPoint &point);
void tabChanged();
void previewReceived();
void previewReceived(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration);
void comboScaleChanged(int i);
void spinPreviewPageValueChanged(int val);
void startIndexing();

Dosyayı Görüntüle

@ -1,97 +0,0 @@
#include "previewcoordinator.h"
#include <QFileInfo>
PreviewCoordinator::PreviewCoordinator()
{
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
connect(&ipcPreviewClient, &IPCPreviewClient::previewReceived, this, &PreviewCoordinator::handleReceivedPreview,
Qt::QueuedConnection);
connect(&ipcPreviewClient, &IPCPreviewClient::finished, this, [&] { emit completedGeneration(); });
connect(this, &PreviewCoordinator::ipcStartGeneration, &ipcPreviewClient, &IPCPreviewClient::startGeneration,
Qt::QueuedConnection);
this->ipcClientThread.start();
}
void PreviewCoordinator::init(const QVector<SearchResult> &searchResults)
{
this->previewableSearchResults.clear();
for(const SearchResult &result : searchResults)
{
if(result.wasContentSearch)
{
QString path = result.fileData.absPath;
// HACK until we can preview them properly
if(path.endsWith(".html") || path.endsWith(".htm"))
{
continue;
}
QFileInfo info{path};
if(info.exists())
{
this->previewableSearchResults.append(result);
}
}
}
}
void PreviewCoordinator::setSocketPath(QString socketPath)
{
this->socketPath = socketPath;
this->ipcPreviewClient.setSocketPath(socketPath);
}
int PreviewCoordinator::previewableCount() const
{
return this->previewableSearchResults.count();
}
QSharedPointer<PreviewResult> PreviewCoordinator::resultAt(int index)
{
if(this->previewResults.size() > index)
{
return {this->previewResults[index]};
}
return {nullptr};
}
const QVector<SearchResult> &PreviewCoordinator::getPreviewableSearchResults() const
{
return this->previewableSearchResults;
}
void PreviewCoordinator::handleReceivedPreview(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration)
{
if(previewGeneration < this->currentPreviewGeneration)
{
return;
}
if(!preview.isNull() && preview->hasPreview())
{
QString docPath = preview->getDocumentPath();
auto previewPage = preview->getPage();
int pos = previewOrder[docPath + QString::number(previewPage)];
this->previewResults[pos] = preview;
emit previewReady();
}
}
void PreviewCoordinator::startGeneration(RenderConfig config, const QVector<RenderTarget> &targets)
{
++this->currentPreviewGeneration;
this->previewOrder.clear();
this->previewResults.clear();
this->previewResults.resize(targets.size());
this->previewResults.fill(nullptr);
int i = 0;
for(const RenderTarget &target : targets)
{
this->previewOrder[target.path + QString::number(target.page)] = i++;
}
emit ipcStartGeneration(config, targets);
}

Dosyayı Görüntüle

@ -1,48 +0,0 @@
#ifndef PREVIEWCOORDINATOR_H
#define PREVIEWCOORDINATOR_H
#include <QVector>
#include <QObject>
#include <QThread>
#include "searchresult.h"
#include "previewresult.h"
#include "ipcpreviewclient.h"
#include "rendertarget.h"
class PreviewCoordinator : public QObject
{
Q_OBJECT
private:
QThread ipcClientThread;
IPCPreviewClient ipcPreviewClient;
QString socketPath;
QVector<QSharedPointer<PreviewResult>> previewResults;
QVector<SearchResult> previewableSearchResults;
unsigned int currentPreviewGeneration = 1;
/* Quick lookup table for the order a preview should have */
QHash<QString, int> previewOrder;
public:
PreviewCoordinator();
void init(const QVector<SearchResult> &searchResults);
int previewableCount() const;
const QVector<SearchResult> &getPreviewableSearchResults() const;
QSharedPointer<PreviewResult> resultAt(int index);
void setSocketPath(QString socketPath);
public slots:
void startGeneration(RenderConfig config, const QVector<RenderTarget> &targets);
void handleReceivedPreview(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration);
signals:
void previewReady();
void completedGeneration();
void error(QString);
void ipcStartGeneration(RenderConfig config, const QVector<RenderTarget> &targets);
};
#endif // PREVIEWCOORDINATOR_H

Dosyayı Görüntüle

@ -20,8 +20,6 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path)
return nullptr;
}
result->setRenderHint(Poppler::Document::TextAntialiasing);
result->setRenderHint(Poppler::Document::TextHinting);
result->setRenderHint(Poppler::Document::TextSlightHinting);
locker.relock();
documentcache.insert(path, result);