diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index a0789f9..644cfc8 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -217,14 +217,21 @@ void MainWindow::makePdfPreview() scaleText.chop(1); QVector wordsToHighlight; + QRegularExpression extractor(R"#("([^"]*)"|(\w+))#"); for(const Token &token : this->currentQuery.getTokens()) { if(token.type == FILTER_CONTENT_CONTAINS) { - auto splitted = token.value.split(" "); - for(QString &str : splitted) + QRegularExpressionMatchIterator i = extractor.globalMatch(token.value); + while(i.hasNext()) { - wordsToHighlight.append(str); + QRegularExpressionMatch m = i.next(); + QString value = m.captured(1); + if(value.isEmpty()) + { + value = m.captured(2); + } + wordsToHighlight.append(value); } } } diff --git a/gui/pdfworker.cpp b/gui/pdfworker.cpp index cd708d6..c3875aa 100644 --- a/gui/pdfworker.cpp +++ b/gui/pdfworker.cpp @@ -84,7 +84,7 @@ struct Renderer QImage img = pdfPage->renderToImage(scaleX, scaleY); for(QString &word : wordsToHighlight) { - QList rects = pdfPage->search(word); + QList rects = pdfPage->search(word, Poppler::Page::CaseInsensitive); for(QRectF &rect : rects) { QPainter painter(&img);