tree: Move to Qt6
This commit is contained in:
@ -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);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QMetaType>
|
||||
#include <QDataStream>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
enum OutlineDestinationType
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 ®exp : this->regexes)
|
||||
for(const QRegularExpression ®exp : this->regexes)
|
||||
{
|
||||
if(regexp.exactMatch(haystack))
|
||||
QRegularExpressionMatch match = regexp.match(haystack);
|
||||
if(match.hasMatch())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user