lint refactor

This commit is contained in:
Agel committed 2026-10-30 16:48:58 +01:00
1 parent da8abf0332
commit 85ae0d4ad9
53 files changed
+891 -670

No files matched your search

+3 -3
View File
@@ -17,17 +17,17 @@ QQuickTextureFactory *AsyncImageResponse::textureFactory() const
void AsyncImageResponse::cancel()
{
m_cancelled.storeRelaxed(1);
m_cancelled.store(true, std::memory_order_release);
}
void AsyncImageResponse::run()
{
if (m_cancelled.loadRelaxed())
if (m_cancelled.load(std::memory_order_acquire))
return;
m_image = m_job();
if (m_cancelled.loadRelaxed())
if (m_cancelled.load(std::memory_order_acquire))
return;
emit finished();
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include <atomic>
#include <functional>
#include <QAtomicInt>
#include <QImage>
#include <QQuickImageResponse>
#include <QRunnable>
@@ -19,6 +19,6 @@ public:
private:
std::function<QImage()> m_job;
QAtomicInt m_cancelled{0};
std::atomic<bool> m_cancelled{false};
QImage m_image;
};
+2 -2
View File
@@ -33,7 +33,7 @@ QString AuthorAttribution::mapRole(const std::optional<QString> &roleCode)
QString AuthorAttribution::formatCreators(const QList<CreatorItem> &creators)
{
QList<QString> roleOrder;
QStringList roleOrder;
QHash<QString, QStringList> roleToNames;
for (const auto &creator : creators) {
@@ -60,7 +60,7 @@ QString AuthorAttribution::formatCreators(const QList<CreatorItem> &creators)
QStringList formattedGroups;
formattedGroups.reserve(roleOrder.size());
for (const auto &role : roleOrder) {
formattedGroups.append(QStringLiteral("%1: %2").arg(role, roleToNames[role].join(QStringLiteral(", "))));
formattedGroups.append(QStringLiteral("%1: %2").arg(role).arg(roleToNames[role].join(QStringLiteral(", "))));
}
return formattedGroups.join(QStringLiteral(", "));
+7 -7
View File
@@ -6,10 +6,10 @@
#include <optional>
struct StructuredAuthor {
std::optional<QString> firstName;
std::optional<QString> middleName;
std::optional<QString> lastName;
std::optional<QString> nickname;
std::optional<QString> firstName = std::nullopt;
std::optional<QString> middleName = std::nullopt;
std::optional<QString> lastName = std::nullopt;
std::optional<QString> nickname = std::nullopt;
bool operator==(const StructuredAuthor &other) const
{
@@ -25,7 +25,7 @@ struct StructuredAuthor {
};
struct CreatorItem {
std::optional<QString> roleCode;
std::optional<QString> roleCode = std::nullopt;
QString name;
bool operator==(const CreatorItem &other) const
@@ -62,7 +62,7 @@ struct BookMetadata {
MetadataStatus status = MetadataStatus::Unparsed;
QList<CreatorItem> rawDcCreators;
QList<StructuredAuthor> rawStructuredAuthors;
std::optional<QString> authorAttribution;
std::optional<QString> authorAttribution = std::nullopt;
bool operator==(const BookMetadata &other) const
{
@@ -121,7 +121,7 @@ public:
private:
BookMetadata m_metadata;
bool m_engineActive;
bool m_engineActive = true;
};
#endif // AUTHORATTRIBUTION_H
+8 -4
View File
@@ -97,15 +97,19 @@ bool EpubReader::parseOpf(const QByteArray &data, IByteSource &source, bool meta
} else if (name == QLatin1String("itemref")) {
const auto attrs = xml.attributes();
const QString idref = attrs.value(QLatin1String("idref")).toString();
if (m_manifest.contains(idref)) {
const QString resolved = QDir::cleanPath(m_opfDir + m_manifest[idref].href);
auto it = m_manifest.constFind(idref);
if (it != m_manifest.constEnd()) {
const QString resolved = QDir::cleanPath(m_opfDir + it.value().href);
m_spineHrefs.append(resolved);
}
}
}
if (!coverId.isEmpty() && m_manifest.contains(coverId)) {
m_coverEntry = QDir::cleanPath(m_opfDir + m_manifest[coverId].href);
if (!coverId.isEmpty()) {
auto it = m_manifest.constFind(coverId);
if (it != m_manifest.constEnd()) {
m_coverEntry = QDir::cleanPath(m_opfDir + it.value().href);
}
} else {
// Fallback: look for item with id cover/cover-image and image media type
for (auto it = m_manifest.begin(); it != m_manifest.end(); ++it) {
+5 -5
View File
@@ -8,10 +8,10 @@
#include "backend/reading/layout/HtmlBlockParser.h"
struct AuthorName {
std::optional<QString> first_name;
std::optional<QString> middle_name;
std::optional<QString> last_name;
std::optional<QString> nickname;
std::optional<QString> first_name = std::nullopt;
std::optional<QString> middle_name = std::nullopt;
std::optional<QString> last_name = std::nullopt;
std::optional<QString> nickname = std::nullopt;
bool has_structured_name() const
{
@@ -51,7 +51,7 @@ struct AuthorName {
struct BinaryResource {
QString id;
std::optional<QString> content_type;
std::optional<QString> content_type = std::nullopt;
QByteArray decoded_bytes;
bool operator==(const BinaryResource &o) const
+2 -1
View File
@@ -3,6 +3,7 @@
#include <QRegularExpression>
#include <QStringDecoder>
#include <QtGlobal>
#include <algorithm>
#include <iconv.h>
namespace TextEncoding {
@@ -16,7 +17,7 @@ QString detectEncoding(const QByteArray &bytes)
if (bytes.startsWith("\xFE\xFF"))
return QStringLiteral("UTF-16BE");
const int checkLen = qMin(1024, bytes.size());
const int checkLen = (std::min)(1024, static_cast<int>(bytes.size()));
const QString headerStr = QString::fromLatin1(bytes.constData(), checkLen);
// 1. XML declaration: <?xml version="1.0" encoding="..."?>
+11 -5
View File
@@ -13,6 +13,9 @@
#include <QStandardPaths>
#include <QThreadPool>
#include <QUrl>
#if QT_CONFIG(ssl)
#include <QSslError>
#endif
#include "AsyncImageResponse.h"
#include "ImageScaling.h"
@@ -87,14 +90,17 @@ static QByteArray defaultHttpFetch(const QString &urlString)
QEventLoop loop;
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
#if QT_CONFIG(ssl)
QObject::connect(reply, &QNetworkReply::sslErrors, &loop, [&loop](const QList<QSslError> &) {
loop.quit();
});
#endif
loop.exec();
if (reply->error() != QNetworkReply::NoError) {
reply->deleteLater();
return {};
QByteArray data;
if (reply->error() == QNetworkReply::NoError) {
data = reply->readAll();
}
const QByteArray data = reply->readAll();
reply->deleteLater();
return data;
}
+4 -3
View File
@@ -162,9 +162,10 @@ bool ComicReader::parseOpenSource(const QString &filePath, IByteSource &source,
if (!data.isEmpty()) {
QBuffer buf;
buf.setData(data);
buf.open(QIODevice::ReadOnly);
QImageReader reader(&buf);
naturalSize = reader.size();
if (buf.open(QIODevice::ReadOnly)) {
QImageReader reader(&buf);
naturalSize = reader.size();
}
}
}
m_pageEntries.append({entry, naturalSize});
@@ -4,6 +4,7 @@
#include <QFileInfo>
#include <QRegularExpression>
#include <QXmlStreamReader>
#include <algorithm>
#include "backend/formats/sources/ZipByteSource.h"
@@ -31,7 +32,7 @@ qsizetype findCaseInsensitive(const QByteArray &haystack, const QByteArray &need
const qsizetype hLen = haystack.size();
if (nLen == 0 || from >= hLen)
return -1;
for (qsizetype i = qMax(qsizetype(0), from); i <= hLen - nLen; ++i) {
for (qsizetype i = (std::max)(qsizetype(0), from); i <= hLen - nLen; ++i) {
bool match = true;
for (qsizetype j = 0; j < nLen; ++j) {
char c1 = haystack[i + j];
@@ -82,8 +82,8 @@ bool ZipByteSource::open(const QString &path)
if (unzGoToFirstFile(zf) == UNZ_OK) {
do {
char name[4096];
unz_file_info64 info{};
unz64_file_pos pos{};
unz_file_info64 info = {};
unz64_file_pos pos = {};
unzGetFilePos64(zf, &pos);
if (unzGetCurrentFileInfo64(zf, &info, name, static_cast<uLong>(sizeof(name) - 1),
nullptr, 0, nullptr, 0) == UNZ_OK) {