tree: Move to Qt6
This commit is contained in:
parent
1f9c048838
commit
1e06ec5d69
@ -37,16 +37,15 @@ win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../shared/release/ -ls
|
|||||||
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
|
LIBS += -luchardet -lpoppler-qt6
|
||||||
|
|
||||||
packagesExist(quazip1-qt5) {
|
packagesExist(quazip1-qt6) {
|
||||||
PKGCONFIG += quazip1-qt5
|
PKGCONFIG += quazip1-qt6
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
LIBS -= -lquazip5
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../shared
|
INCLUDEPATH += $$PWD/../shared
|
||||||
INCLUDEPATH += /usr/include/poppler/qt5/
|
INCLUDEPATH += /usr/include/poppler/qt6/
|
||||||
|
|
||||||
DEPENDPATH += $$PWD/../shared
|
DEPENDPATH += $$PWD/../shared
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
|
|||||||
closeButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
closeButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||||
|
|
||||||
closeLayout->setMargin(10);
|
|
||||||
closeLayout->addStretch(10);
|
closeLayout->addStretch(10);
|
||||||
closeLayout->addWidget(closeButton);
|
closeLayout->addWidget(closeButton);
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
|
|||||||
QLabel *aboutLooqs = new QLabel(this);
|
QLabel *aboutLooqs = new QLabel(this);
|
||||||
QString html = "<h2>looqs</h2>";
|
QString html = "<h2>looqs</h2>";
|
||||||
html += "Full-text search with previews for your files<br><br>";
|
html += "Full-text search with previews for your files<br><br>";
|
||||||
html += "Copyright (c) 2018-2022: Albert Schwarzkopf<br><br>";
|
html += "Copyright (c) 2018-2024: Albert Schwarzkopf<br><br>";
|
||||||
html += QString("Version: %1<br><br>").arg(Common::versionText());
|
html += QString("Version: %1<br><br>").arg(Common::versionText());
|
||||||
html += "Contact: looqs at quitesimple dot org<br><br>";
|
html += "Contact: looqs at quitesimple dot org<br><br>";
|
||||||
html += "Website: <a href=\"https://quitesimple.org\">https://quitesimple.org</a><br><br>";
|
html += "Website: <a href=\"https://quitesimple.org\">https://quitesimple.org</a><br><br>";
|
||||||
|
12
gui/gui.pro
12
gui/gui.pro
@ -71,8 +71,8 @@ HEADERS += \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
INCLUDEPATH += /usr/include/poppler/qt5/
|
INCLUDEPATH += /usr/include/poppler/qt6/
|
||||||
INCLUDEPATH += /usr/include/quazip5
|
INCLUDEPATH += /usr/include/quazip6
|
||||||
|
|
||||||
QT += widgets sql
|
QT += widgets sql
|
||||||
|
|
||||||
@ -80,12 +80,12 @@ win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../shared/release/ -ls
|
|||||||
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
|
LIBS += -luchardet -lpoppler-qt6 -lquazip6
|
||||||
|
|
||||||
packagesExist(quazip1-qt5) {
|
packagesExist(quazip1-qt6) {
|
||||||
PKGCONFIG += quazip1-qt5
|
PKGCONFIG += quazip1-qt6
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
LIBS -= -lquazip5
|
LIBS -= -lquazip6
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../shared
|
INCLUDEPATH += $$PWD/../shared
|
||||||
|
@ -68,22 +68,25 @@ void IPCPreviewClient::start(RenderConfig config, const QVector<RenderTarget> &t
|
|||||||
if(socket->isOpen() && socket->isWritable())
|
if(socket->isOpen() && socket->isWritable())
|
||||||
{
|
{
|
||||||
QDataStream stream(socket);
|
QDataStream stream(socket);
|
||||||
|
stream.startTransaction();
|
||||||
stream << GeneratePreviews;
|
stream << GeneratePreviews;
|
||||||
stream << config;
|
stream << config;
|
||||||
stream << targets;
|
stream << targets;
|
||||||
|
stream.commitTransaction();
|
||||||
socket->flush();
|
socket->flush();
|
||||||
|
|
||||||
int numTarget = 0;
|
qsizetype numTarget = 0;
|
||||||
if(socket->isOpen() && socket->isReadable() && socket->state() == QLocalSocket::ConnectedState)
|
if(socket->isOpen() && socket->isReadable() && socket->state() == QLocalSocket::ConnectedState)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
socket->waitForReadyRead(100);
|
socket->waitForReadyRead(5000);
|
||||||
stream.startTransaction();
|
stream.startTransaction();
|
||||||
stream >> numTarget;
|
stream >> numTarget;
|
||||||
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
|
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
|
||||||
if(numTarget != targets.count())
|
if(numTarget != targets.count())
|
||||||
{
|
{
|
||||||
|
qDebug() << "Target count mismatch";
|
||||||
emit error("IPC Error: Server reports less targets than it should");
|
emit error("IPC Error: Server reports less targets than it should");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,9 @@ void IpcServer::spawnerNewConnection()
|
|||||||
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
|
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
|
||||||
if(socket->state() == QLocalSocket::ConnectedState)
|
if(socket->state() == QLocalSocket::ConnectedState)
|
||||||
{
|
{
|
||||||
|
stream.startTransaction();
|
||||||
stream << targets.count();
|
stream << targets.count();
|
||||||
|
stream.commitTransaction();
|
||||||
socket->flush();
|
socket->flush();
|
||||||
IPCPreviewWorker *previewWorker = new IPCPreviewWorker(socket);
|
IPCPreviewWorker *previewWorker = new IPCPreviewWorker(socket);
|
||||||
connect(previewWorker, &IPCPreviewWorker::finished, this, [previewWorker] { delete previewWorker; });
|
connect(previewWorker, &IPCPreviewWorker::finished, this, [previewWorker] { delete previewWorker; });
|
||||||
@ -59,6 +61,7 @@ void IpcServer::spawnerNewConnection()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug() << "Deleting socket...";
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <poppler-qt5.h>
|
#include <poppler-qt6.h>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -15,10 +15,8 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "clicklabel.h"
|
#include "clicklabel.h"
|
||||||
@ -673,7 +671,7 @@ void MainWindow::previewReceived()
|
|||||||
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
|
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
|
||||||
|
|
||||||
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
||||||
label->setMaximumWidth(QApplication::desktop()->availableGeometry().width() - 200);
|
label->setMaximumWidth(QApplication::primaryScreen()->availableGeometry().width() - 200);
|
||||||
|
|
||||||
QVBoxLayout *previewLayout = new QVBoxLayout();
|
QVBoxLayout *previewLayout = new QVBoxLayout();
|
||||||
|
|
||||||
@ -702,7 +700,7 @@ void MainWindow::previewReceived()
|
|||||||
|
|
||||||
previewLayout->addWidget(headerLabel);
|
previewLayout->addWidget(headerLabel);
|
||||||
|
|
||||||
previewLayout->setMargin(0);
|
previewLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
previewLayout->insertStretch(0, 1);
|
previewLayout->insertStretch(0, 1);
|
||||||
previewLayout->insertStretch(-1, 1);
|
previewLayout->insertStretch(-1, 1);
|
||||||
previewLayout->setAlignment(Qt::AlignCenter);
|
previewLayout->setAlignment(Qt::AlignCenter);
|
||||||
|
@ -13,20 +13,21 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path)
|
|||||||
return documentcache.value(path);
|
return documentcache.value(path);
|
||||||
}
|
}
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
Poppler::Document *result = Poppler::Document::load(path);
|
auto result = Poppler::Document::load(path);
|
||||||
if(result == nullptr)
|
if(!result)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Failed to load document: " << path;
|
||||||
// TODO: some kind of user feedback would be nice
|
// TODO: some kind of user feedback would be nice
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result->setRenderHint(Poppler::Document::TextAntialiasing);
|
result->setRenderHint(Poppler::Document::TextAntialiasing);
|
||||||
result->setRenderHint(Poppler::Document::TextHinting);
|
result->setRenderHint(Poppler::Document::TextHinting);
|
||||||
result->setRenderHint(Poppler::Document::TextSlightHinting);
|
result->setRenderHint(Poppler::Document::TextSlightHinting);
|
||||||
|
auto ptr = result.release();
|
||||||
locker.relock();
|
locker.relock();
|
||||||
documentcache.insert(path, result);
|
documentcache.insert(path, ptr);
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
return result;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config, QString documentPath,
|
QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config, QString documentPath,
|
||||||
@ -36,10 +37,12 @@ QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config,
|
|||||||
Poppler::Document *doc = document(documentPath);
|
Poppler::Document *doc = document(documentPath);
|
||||||
if(doc == nullptr)
|
if(doc == nullptr)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Failed to obtain document for: " << documentPath;
|
||||||
return QSharedPointer<PreviewResult>(result);
|
return QSharedPointer<PreviewResult>(result);
|
||||||
}
|
}
|
||||||
if(doc->isLocked())
|
if(doc->isLocked())
|
||||||
{
|
{
|
||||||
|
qDebug() << "Failed to open document as its locked: " << documentPath;
|
||||||
return QSharedPointer<PreviewResult>(result);
|
return QSharedPointer<PreviewResult>(result);
|
||||||
}
|
}
|
||||||
int p = (int)page - 1;
|
int p = (int)page - 1;
|
||||||
@ -47,7 +50,12 @@ QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config,
|
|||||||
{
|
{
|
||||||
p = 0;
|
p = 0;
|
||||||
}
|
}
|
||||||
Poppler::Page *pdfPage = doc->page(p);
|
auto pdfPage = doc->page(p);
|
||||||
|
if(!pdfPage)
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to open page " << p << " for document" << documentPath;
|
||||||
|
return QSharedPointer<PreviewResult>(result);
|
||||||
|
}
|
||||||
QImage img = pdfPage->renderToImage(config.scaleX, config.scaleY);
|
QImage img = pdfPage->renderToImage(config.scaleX, config.scaleY);
|
||||||
for(QString &word : config.wordsToHighlight)
|
for(QString &word : config.wordsToHighlight)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef PREVIEWGENERATORPDF_H
|
#ifndef PREVIEWGENERATORPDF_H
|
||||||
#define PREVIEWGENERATORPDF_H
|
#define PREVIEWGENERATORPDF_H
|
||||||
#include <poppler-qt5.h>
|
#include <poppler-qt6.h>
|
||||||
#include "previewgenerator.h"
|
#include "previewgenerator.h"
|
||||||
#include "previewresultpdf.h"
|
#include "previewresultpdf.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QTextCodec>
|
#include <QStringDecoder>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "defaulttextprocessor.h"
|
#include "defaulttextprocessor.h"
|
||||||
|
|
||||||
@ -13,10 +13,10 @@ QString DefaultTextProcessor::processText(const QByteArray &data) const
|
|||||||
QString encoding = encodingDetector.detectEncoding(data);
|
QString encoding = encodingDetector.detectEncoding(data);
|
||||||
if(!encoding.isEmpty())
|
if(!encoding.isEmpty())
|
||||||
{
|
{
|
||||||
QTextCodec *codec = QTextCodec::codecForName(encoding.toUtf8());
|
QStringDecoder decoder = QStringDecoder(encoding.toStdString().c_str());
|
||||||
if(codec != nullptr)
|
if(decoder.isValid())
|
||||||
{
|
{
|
||||||
return codec->toUnicode(data);
|
return decoder(data);
|
||||||
}
|
}
|
||||||
qWarning() << "No codec found for " << encoding;
|
qWarning() << "No codec found for " << encoding;
|
||||||
return QString(data);
|
return QString(data);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
enum OutlineDestinationType
|
enum OutlineDestinationType
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ void IndexSyncer::sync()
|
|||||||
if(!this->fileSaverOptions.keepGoing)
|
if(!this->fileSaverOptions.keepGoing)
|
||||||
{
|
{
|
||||||
QString errorMsg = QString("Failed to update all files selected for updating in this batch. Updated") +
|
QString errorMsg = QString("Failed to update all files selected for updating in this batch. Updated") +
|
||||||
updatedFilesCount + "out of" + shouldHaveUpdatedCount + "selected for updating";
|
QString::number(updatedFilesCount) + "out of" + QString::number(shouldHaveUpdatedCount) + "selected for updating";
|
||||||
emit error(errorMsg);
|
emit error(errorMsg);
|
||||||
emit finished(totalUpdatesFilesCount, totalDeletedFilesCount, totalErroredFilesCount);
|
emit finished(totalUpdatesFilesCount, totalDeletedFilesCount, totalErroredFilesCount);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <poppler-qt5.h>
|
|
||||||
#include "pdfprocessor.h"
|
#include "pdfprocessor.h"
|
||||||
PdfProcessor::PdfProcessor()
|
PdfProcessor::PdfProcessor()
|
||||||
{
|
{
|
||||||
@ -29,8 +28,8 @@ QVector<DocumentOutlineEntry> PdfProcessor::createOutline(const QVector<Poppler:
|
|||||||
DocumentProcessResult PdfProcessor::process(const QByteArray &data) const
|
DocumentProcessResult PdfProcessor::process(const QByteArray &data) const
|
||||||
{
|
{
|
||||||
DocumentProcessResult result;
|
DocumentProcessResult result;
|
||||||
QScopedPointer<Poppler::Document> doc(Poppler::Document::loadFromData(data));
|
auto doc(Poppler::Document::loadFromData(data));
|
||||||
if(doc.isNull())
|
if(!doc)
|
||||||
{
|
{
|
||||||
throw LooqsGeneralException("Failed to process pdf data");
|
throw LooqsGeneralException("Failed to process pdf data");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef PDFPROCESSOR_H
|
#ifndef PDFPROCESSOR_H
|
||||||
#define PDFPROCESSOR_H
|
#define PDFPROCESSOR_H
|
||||||
#include <poppler-qt5.h>
|
#include <poppler-qt6.h>
|
||||||
#include "processor.h"
|
#include "processor.h"
|
||||||
class PdfProcessor : public Processor
|
class PdfProcessor : public Processor
|
||||||
{
|
{
|
||||||
|
@ -14,11 +14,11 @@ CONFIG += staticlib
|
|||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../sandbox/exile.h/
|
INCLUDEPATH += $$PWD/../sandbox/exile.h/
|
||||||
INCLUDEPATH += /usr/include/poppler/qt5/ /usr/include/quazip5
|
INCLUDEPATH += /usr/include/poppler/qt6/ /usr/include/quazip5
|
||||||
|
|
||||||
# Dirty, we only need the includes here but well this magic works, so...
|
# Dirty, we only need the includes here but well this magic works, so...
|
||||||
packagesExist(quazip1-qt5) {
|
packagesExist(quazip1-qt6) {
|
||||||
PKGCONFIG += quazip1-qt5
|
PKGCONFIG += quazip1-qt6
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include "looqsgeneralexception.h"
|
#include "looqsgeneralexception.h"
|
||||||
#include "sqlitedbservice.h"
|
#include "sqlitedbservice.h"
|
||||||
#include "filedata.h"
|
#include "filedata.h"
|
||||||
@ -84,13 +85,12 @@ unsigned int SqliteDbService::getFiles(QVector<FileData> &results, QString wildC
|
|||||||
// TODO: port this to QRegularExpression once >5.12 gets more widespread because of this bug
|
// TODO: port this to QRegularExpression once >5.12 gets more widespread because of this bug
|
||||||
// https://bugreports.qt.io/browse/QTBUG-72539?focusedCommentId=439053&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel
|
// https://bugreports.qt.io/browse/QTBUG-72539?focusedCommentId=439053&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel
|
||||||
bool usePattern = !wildCardPattern.isEmpty();
|
bool usePattern = !wildCardPattern.isEmpty();
|
||||||
QRegExp regexPattern(wildCardPattern);
|
QRegularExpression regexPattern(QRegularExpression::wildcardToRegularExpression(wildCardPattern));
|
||||||
regexPattern.setPatternSyntax(QRegExp::PatternSyntax::WildcardUnix);
|
|
||||||
|
|
||||||
while(query.next())
|
while(query.next())
|
||||||
{
|
{
|
||||||
QString absPath = query.value(0).toString();
|
QString absPath = query.value(0).toString();
|
||||||
if(!usePattern || regexPattern.exactMatch(absPath))
|
if(!usePattern || regexPattern.match(absPath).hasMatch())
|
||||||
{
|
{
|
||||||
FileData current;
|
FileData current;
|
||||||
current.absPath = absPath;
|
current.absPath = absPath;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "tagstripperprocessor.h"
|
#include "tagstripperprocessor.h"
|
||||||
|
#include <QRegularExpression>
|
||||||
TagStripperProcessor::TagStripperProcessor()
|
TagStripperProcessor::TagStripperProcessor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -9,6 +9,6 @@ DocumentProcessResult TagStripperProcessor::process(const QByteArray &data) cons
|
|||||||
auto result = DefaultTextProcessor::process(data);
|
auto result = DefaultTextProcessor::process(data);
|
||||||
// TODO: does not work properly with <br> and does not deal with entities...
|
// TODO: does not work properly with <br> and does not deal with entities...
|
||||||
Q_ASSERT(result.pages.size() > 0);
|
Q_ASSERT(result.pages.size() > 0);
|
||||||
result.pages[0].content.remove(QRegExp("<[^>]*>"));
|
result.pages[0].content.remove(QRegularExpression("<[^>]*>"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ QByteArray Utils::readFile(QString path)
|
|||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
if(data.isEmpty() && file.error() != QFileDevice::FileError::NoError)
|
if(data.isEmpty() && file.error() != QFileDevice::FileError::NoError)
|
||||||
{
|
{
|
||||||
throw LooqsGeneralException("Error reading file: " + path + ", Error: " + file.error());
|
throw LooqsGeneralException("Error reading file: " + path + ", Error: " + QString::number(file.error()));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,8 @@ void WildcardMatcher::setPatterns(QStringList patterns)
|
|||||||
this->regexes.clear();
|
this->regexes.clear();
|
||||||
for(QString &str : patterns)
|
for(QString &str : patterns)
|
||||||
{
|
{
|
||||||
QRegExp regexp;
|
QRegularExpression regexp;
|
||||||
regexp.setPattern(str);
|
regexp.setPattern(QRegularExpression::wildcardToRegularExpression(str));
|
||||||
regexp.setPatternSyntax(QRegExp::WildcardUnix);
|
|
||||||
this->regexes.append(regexp);
|
this->regexes.append(regexp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,9 +17,10 @@ WildcardMatcher::WildcardMatcher()
|
|||||||
|
|
||||||
bool WildcardMatcher::match(QString haystack) const
|
bool WildcardMatcher::match(QString haystack) const
|
||||||
{
|
{
|
||||||
for(const QRegExp ®exp : this->regexes)
|
for(const QRegularExpression ®exp : this->regexes)
|
||||||
{
|
{
|
||||||
if(regexp.exactMatch(haystack))
|
QRegularExpressionMatch match = regexp.match(haystack);
|
||||||
|
if(match.hasMatch())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef WILDCARDMATCHER_H
|
#ifndef WILDCARDMATCHER_H
|
||||||
#define WILDCARDMATCHER_H
|
#define WILDCARDMATCHER_H
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
class WildcardMatcher
|
class WildcardMatcher
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
QVector<QRegExp> regexes;
|
QVector<QRegularExpression> regexes;
|
||||||
QStringList patterns;
|
QStringList patterns;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user