tree: Move to Qt6

Este commit está contenido en:
Albert S. 2024-05-20 19:14:40 +02:00
padre 1f9c048838
commit 1e06ec5d69
Se han modificado 19 ficheros con 62 adiciones y 52 borrados

Ver fichero

@ -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:unix: LIBS += -L$$OUT_PWD/../shared/ -lshared
LIBS += -luchardet -lpoppler-qt5 -lquazip5
LIBS += -luchardet -lpoppler-qt6
packagesExist(quazip1-qt5) {
PKGCONFIG += quazip1-qt5
packagesExist(quazip1-qt6) {
PKGCONFIG += quazip1-qt6
CONFIG += link_pkgconfig
LIBS -= -lquazip5
}
INCLUDEPATH += $$PWD/../shared
INCLUDEPATH += /usr/include/poppler/qt5/
INCLUDEPATH += /usr/include/poppler/qt6/
DEPENDPATH += $$PWD/../shared

Ver fichero

@ -19,7 +19,6 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
closeButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
closeLayout->setMargin(10);
closeLayout->addStretch(10);
closeLayout->addWidget(closeButton);
@ -32,7 +31,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
QLabel *aboutLooqs = new QLabel(this);
QString html = "<h2>looqs</h2>";
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 += "Contact: looqs at quitesimple dot org<br><br>";
html += "Website: <a href=\"https://quitesimple.org\">https://quitesimple.org</a><br><br>";

Ver fichero

@ -71,8 +71,8 @@ HEADERS += \
FORMS += \
mainwindow.ui
INCLUDEPATH += /usr/include/poppler/qt5/
INCLUDEPATH += /usr/include/quazip5
INCLUDEPATH += /usr/include/poppler/qt6/
INCLUDEPATH += /usr/include/quazip6
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:unix: LIBS += -L$$OUT_PWD/../shared/ -lshared
LIBS += -luchardet -lpoppler-qt5 -lquazip5
LIBS += -luchardet -lpoppler-qt6 -lquazip6
packagesExist(quazip1-qt5) {
PKGCONFIG += quazip1-qt5
packagesExist(quazip1-qt6) {
PKGCONFIG += quazip1-qt6
CONFIG += link_pkgconfig
LIBS -= -lquazip5
LIBS -= -lquazip6
}
INCLUDEPATH += $$PWD/../shared

Ver fichero

@ -68,22 +68,25 @@ void IPCPreviewClient::start(RenderConfig config, const QVector<RenderTarget> &t
if(socket->isOpen() && socket->isWritable())
{
QDataStream stream(socket);
stream.startTransaction();
stream << GeneratePreviews;
stream << config;
stream << targets;
stream.commitTransaction();
socket->flush();
int numTarget = 0;
qsizetype numTarget = 0;
if(socket->isOpen() && socket->isReadable() && socket->state() == QLocalSocket::ConnectedState)
{
do
{
socket->waitForReadyRead(100);
socket->waitForReadyRead(5000);
stream.startTransaction();
stream >> numTarget;
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
if(numTarget != targets.count())
{
qDebug() << "Target count mismatch";
emit error("IPC Error: Server reports less targets than it should");
return;
}

Ver fichero

@ -51,7 +51,9 @@ void IpcServer::spawnerNewConnection()
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
if(socket->state() == QLocalSocket::ConnectedState)
{
stream.startTransaction();
stream << targets.count();
stream.commitTransaction();
socket->flush();
IPCPreviewWorker *previewWorker = new IPCPreviewWorker(socket);
connect(previewWorker, &IPCPreviewWorker::finished, this, [previewWorker] { delete previewWorker; });
@ -59,6 +61,7 @@ void IpcServer::spawnerNewConnection()
}
else
{
qDebug() << "Deleting socket...";
delete socket;
}
}

Ver fichero

@ -1,4 +1,4 @@
#include <poppler-qt5.h>
#include <poppler-qt6.h>
#include <QLabel>
#include <QtDebug>
#include <QFileInfo>
@ -15,10 +15,8 @@
#include <QFileDialog>
#include <QScreen>
#include <QProgressDialog>
#include <QDesktopWidget>
#include <QWidgetAction>
#include <QInputDialog>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "clicklabel.h"
@ -673,7 +671,7 @@ void MainWindow::previewReceived()
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
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();
@ -702,7 +700,7 @@ void MainWindow::previewReceived()
previewLayout->addWidget(headerLabel);
previewLayout->setMargin(0);
previewLayout->setContentsMargins(0, 0, 0, 0);
previewLayout->insertStretch(0, 1);
previewLayout->insertStretch(-1, 1);
previewLayout->setAlignment(Qt::AlignCenter);

Ver fichero

@ -13,20 +13,21 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path)
return documentcache.value(path);
}
locker.unlock();
Poppler::Document *result = Poppler::Document::load(path);
if(result == nullptr)
auto result = Poppler::Document::load(path);
if(!result)
{
qDebug() << "Failed to load document: " << path;
// TODO: some kind of user feedback would be nice
return nullptr;
}
result->setRenderHint(Poppler::Document::TextAntialiasing);
result->setRenderHint(Poppler::Document::TextHinting);
result->setRenderHint(Poppler::Document::TextSlightHinting);
auto ptr = result.release();
locker.relock();
documentcache.insert(path, result);
documentcache.insert(path, ptr);
locker.unlock();
return result;
return ptr;
}
QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config, QString documentPath,
@ -36,10 +37,12 @@ QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config,
Poppler::Document *doc = document(documentPath);
if(doc == nullptr)
{
qDebug() << "Failed to obtain document for: " << documentPath;
return QSharedPointer<PreviewResult>(result);
}
if(doc->isLocked())
{
qDebug() << "Failed to open document as its locked: " << documentPath;
return QSharedPointer<PreviewResult>(result);
}
int p = (int)page - 1;
@ -47,7 +50,12 @@ QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config,
{
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);
for(QString &word : config.wordsToHighlight)
{

Ver fichero

@ -1,6 +1,6 @@
#ifndef PREVIEWGENERATORPDF_H
#define PREVIEWGENERATORPDF_H
#include <poppler-qt5.h>
#include <poppler-qt6.h>
#include "previewgenerator.h"
#include "previewresultpdf.h"

Ver fichero

@ -1,6 +1,6 @@
#include <QFile>
#include <QDataStream>
#include <QTextCodec>
#include <QStringDecoder>
#include <QDebug>
#include "defaulttextprocessor.h"
@ -13,10 +13,10 @@ QString DefaultTextProcessor::processText(const QByteArray &data) const
QString encoding = encodingDetector.detectEncoding(data);
if(!encoding.isEmpty())
{
QTextCodec *codec = QTextCodec::codecForName(encoding.toUtf8());
if(codec != nullptr)
QStringDecoder decoder = QStringDecoder(encoding.toStdString().c_str());
if(decoder.isValid())
{
return codec->toUnicode(data);
return decoder(data);
}
qWarning() << "No codec found for " << encoding;
return QString(data);

Ver fichero

@ -3,6 +3,7 @@
#include <QMetaType>
#include <QDataStream>
#include <QString>
#include <QVector>
enum OutlineDestinationType
{

Ver fichero

@ -110,7 +110,7 @@ void IndexSyncer::sync()
if(!this->fileSaverOptions.keepGoing)
{
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 finished(totalUpdatesFilesCount, totalDeletedFilesCount, totalErroredFilesCount);
}

Ver fichero

@ -1,5 +1,4 @@
#include <QScopedPointer>
#include <poppler-qt5.h>
#include "pdfprocessor.h"
PdfProcessor::PdfProcessor()
{
@ -29,8 +28,8 @@ QVector<DocumentOutlineEntry> PdfProcessor::createOutline(const QVector<Poppler:
DocumentProcessResult PdfProcessor::process(const QByteArray &data) const
{
DocumentProcessResult result;
QScopedPointer<Poppler::Document> doc(Poppler::Document::loadFromData(data));
if(doc.isNull())
auto doc(Poppler::Document::loadFromData(data));
if(!doc)
{
throw LooqsGeneralException("Failed to process pdf data");
}

Ver fichero

@ -1,6 +1,6 @@
#ifndef PDFPROCESSOR_H
#define PDFPROCESSOR_H
#include <poppler-qt5.h>
#include <poppler-qt6.h>
#include "processor.h"
class PdfProcessor : public Processor
{

Ver fichero

@ -14,11 +14,11 @@ CONFIG += staticlib
CONFIG += c++17
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...
packagesExist(quazip1-qt5) {
PKGCONFIG += quazip1-qt5
packagesExist(quazip1-qt6) {
PKGCONFIG += quazip1-qt6
CONFIG += link_pkgconfig
}

Ver fichero

@ -2,6 +2,7 @@
#include <QFileInfo>
#include <QDateTime>
#include <QSqlError>
#include <QRegularExpression>
#include "looqsgeneralexception.h"
#include "sqlitedbservice.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
// https://bugreports.qt.io/browse/QTBUG-72539?focusedCommentId=439053&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel
bool usePattern = !wildCardPattern.isEmpty();
QRegExp regexPattern(wildCardPattern);
regexPattern.setPatternSyntax(QRegExp::PatternSyntax::WildcardUnix);
QRegularExpression regexPattern(QRegularExpression::wildcardToRegularExpression(wildCardPattern));
while(query.next())
{
QString absPath = query.value(0).toString();
if(!usePattern || regexPattern.exactMatch(absPath))
if(!usePattern || regexPattern.match(absPath).hasMatch())
{
FileData current;
current.absPath = absPath;

Ver fichero

@ -1,5 +1,5 @@
#include "tagstripperprocessor.h"
#include <QRegularExpression>
TagStripperProcessor::TagStripperProcessor()
{
}
@ -9,6 +9,6 @@ DocumentProcessResult TagStripperProcessor::process(const QByteArray &data) cons
auto result = DefaultTextProcessor::process(data);
// TODO: does not work properly with <br> and does not deal with entities...
Q_ASSERT(result.pages.size() > 0);
result.pages[0].content.remove(QRegExp("<[^>]*>"));
result.pages[0].content.remove(QRegularExpression("<[^>]*>"));
return result;
}

Ver fichero

@ -14,7 +14,7 @@ QByteArray Utils::readFile(QString path)
QByteArray data = file.readAll();
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;
}

Ver fichero

@ -5,9 +5,8 @@ void WildcardMatcher::setPatterns(QStringList patterns)
this->regexes.clear();
for(QString &str : patterns)
{
QRegExp regexp;
regexp.setPattern(str);
regexp.setPatternSyntax(QRegExp::WildcardUnix);
QRegularExpression regexp;
regexp.setPattern(QRegularExpression::wildcardToRegularExpression(str));
this->regexes.append(regexp);
}
}
@ -18,9 +17,10 @@ WildcardMatcher::WildcardMatcher()
bool WildcardMatcher::match(QString haystack) const
{
for(const QRegExp &regexp : this->regexes)
for(const QRegularExpression &regexp : this->regexes)
{
if(regexp.exactMatch(haystack))
QRegularExpressionMatch match = regexp.match(haystack);
if(match.hasMatch())
{
return true;
}

Ver fichero

@ -1,11 +1,11 @@
#ifndef WILDCARDMATCHER_H
#define WILDCARDMATCHER_H
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
class WildcardMatcher
{
private:
QVector<QRegExp> regexes;
QVector<QRegularExpression> regexes;
QStringList patterns;
public: