new future: highlight searched words in pdf preview

This commit is contained in:
2019-08-18 23:23:11 +02:00
부모 cff481a57e
커밋 22bcc888b9
4개의 변경된 파일39개의 추가작업 그리고 8개의 파일을 삭제

파일 보기

@ -16,7 +16,6 @@
#include "clicklabel.h"
#include "../shared/sqlitesearch.h"
#include "../shared/qssgeneralexception.h"
#include "../shared/qssquery.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
@ -164,7 +163,8 @@ void MainWindow::lineEditReturnPressed()
[&, q]()
{
SqliteSearch searcher(db);
return searcher.search(QSSQuery::build(q));
this->currentQuery = QSSQuery::build(q);
return searcher.search(this->currentQuery);
});
searchWatcher.setFuture(searchFuture);
}
@ -215,8 +215,22 @@ void MainWindow::makePdfPreview()
processedPdfPreviews = 0;
QString scaleText = ui->comboScale->currentText();
scaleText.chop(1);
QVector<QString> wordsToHighlight;
for(const Token &token : this->currentQuery.getTokens())
{
if(token.type == FILTER_CONTENT_CONTAINS)
{
auto splitted = token.value.split(" ");
for(QString &str : splitted)
{
wordsToHighlight.append(str);
}
}
}
PdfWorker worker;
this->pdfWorkerWatcher.setFuture(worker.generatePreviews(this->pdfSearchResults, scaleText.toInt() / 100.));
this->pdfWorkerWatcher.setFuture(
worker.generatePreviews(this->pdfSearchResults, wordsToHighlight, scaleText.toInt() / 100.));
ui->pdfProcessBar->setMaximum(this->pdfWorkerWatcher.progressMaximum());
ui->pdfProcessBar->setMinimum(this->pdfWorkerWatcher.progressMinimum());
}