From: APTX Date: Sat, 7 Mar 2026 05:12:03 +0000 (+0900) Subject: Clazy fixes X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=HEAD;p=anidbudpclient.git Clazy fixes --- diff --git a/anidbudpclient_global.h b/anidbudpclient_global.h index d1a99dc..a581a44 100644 --- a/anidbudpclient_global.h +++ b/anidbudpclient_global.h @@ -38,6 +38,7 @@ namespace AniDBUdpClient EncryptionError, UnknownError, }; + Q_ENUM_NS(Error); enum IdlePolicy { @@ -46,6 +47,7 @@ namespace AniDBUdpClient ImmediateLogoutIdlePolicy, KeepAliveIdlePolicy, }; + Q_ENUM_NS(IdlePolicy); enum ReplyCode { @@ -211,6 +213,7 @@ namespace AniDBUdpClient VERSION = 998, }; + Q_ENUM_NS(ReplyCode); enum State { StateUnknown = 0, @@ -219,6 +222,7 @@ namespace AniDBUdpClient StateDeleted = 3, StateOnExternalStorage = 4, }; + Q_ENUM_NS(State); enum FileState { FileStateNormal = 0, @@ -232,8 +236,7 @@ namespace AniDBUdpClient FileStateStreamed = 15, FileStateOther = 100 }; - - Q_ENUMS(Error IdlePolicy ReplyCode State FileState); + Q_ENUM_NS(FileState); namespace FileFlag { enum FileFlag : quint64 diff --git a/client.cpp b/client.cpp index 2c41465..0a7972e 100644 --- a/client.cpp +++ b/client.cpp @@ -333,9 +333,9 @@ qDebug() << "Host lookup finished"; << "to the following addresses:"; for (auto&& address : hostInfo.addresses()) qDebug() << address; - qDebug() << "Using" << hostInfo.addresses()[0]; + qDebug() << "Using" << hostInfo.addresses().at(0); - m_hostAddress = hostInfo.addresses()[0]; + m_hostAddress = hostInfo.addresses().at(0); // TODO could it be nicer? enterConnectingState(); diff --git a/client.h b/client.h index 09595c9..663d26e 100644 --- a/client.h +++ b/client.h @@ -94,10 +94,10 @@ protected: public slots: - void send(AbstractReply *reply); + void send(AniDBUdpClient::AbstractReply *reply); void sendRaw(QByteArray command); - void cancel(AbstractReply *command); + void cancel(AniDBUdpClient::AbstractReply *command); void clearErrors(); diff --git a/clientinterface.h b/clientinterface.h index 9851ad4..21e3b90 100644 --- a/clientinterface.h +++ b/clientinterface.h @@ -59,10 +59,9 @@ public slots: virtual void connect() = 0; virtual void disconnect(bool graceful = false) = 0; - virtual void send(AbstractReply *reply) = 0; + virtual void send(AniDBUdpClient::AbstractReply *reply) = 0; -// virtual void sendRaw(QByteArray command) = 0; - virtual void cancel(AbstractReply *command) = 0; + virtual void cancel(AniDBUdpClient::AbstractReply *command) = 0; signals: void connectionError(); diff --git a/episodecommand.cpp b/episodecommand.cpp index 0a1c2cd..48a44db 100644 --- a/episodecommand.cpp +++ b/episodecommand.cpp @@ -210,7 +210,7 @@ void EpisodeReply::setRawReply(ReplyCode replyCode, const QString &reply) } else { - m_epnoAsInt = m_epno.mid(1).toInt(); + m_epnoAsInt = QStringView{m_epno}.mid(1).toInt(); } } m_titleEnglish = parts[6]; diff --git a/file.cpp b/file.cpp index 3ce3635..30e94a6 100644 --- a/file.cpp +++ b/file.cpp @@ -291,13 +291,13 @@ qDebug() << "lid = " << m_lid; } else { - newFileName = tr("%1 - %2 - %3 - [%4](%5).%6") - .arg(name) - .arg(fileReply->value(FileAnimeFlag::EpNo).toString()) - .arg(fileReply->value(FileAnimeFlag::EpName).toString()) - .arg(fileReply->value(FileAnimeFlag::GroupShortName).toString()) - .arg(fileReply->value(FileFlag::Crc32).toString()) - .arg(fileReply->value(FileFlag::FileType).toString()); + newFileName = + tr("%1 - %2 - %3 - [%4](%5).%6") + .arg(name, fileReply->value(FileAnimeFlag::EpNo).toString(), + fileReply->value(FileAnimeFlag::EpName).toString(), + fileReply->value(FileAnimeFlag::GroupShortName).toString(), + fileReply->value(FileFlag::Crc32).toString(), + fileReply->value(FileFlag::FileType).toString()); } newFileName.replace('"', "'"); static QRegularExpression rx1("[\\/]"); diff --git a/file.h b/file.h index fc1235c..c698dc5 100644 --- a/file.h +++ b/file.h @@ -44,6 +44,7 @@ public: All = -1, }; + Q_ENUM(Action); enum ActionState { NotStarted = 0x00000001, @@ -55,8 +56,7 @@ public: OkToContinue = NotStarted | Failure, }; - - Q_ENUMS(Action ActionState); + Q_ENUM(ActionState); File(QObject *parent = 0); File(const QFileInfo &file, QObject *parent = 0); diff --git a/hash.h b/hash.h index 1a0b9b8..639da49 100644 --- a/hash.h +++ b/hash.h @@ -32,7 +32,7 @@ public: static void destroy(); signals: - void resultReady(HashResult *result); + void resultReady(AniDBUdpClient::HashResult *result); void fileProgress(int percent); void progress(int percent); void finished(); diff --git a/renameparser/AniAdd/lexer.cpp b/renameparser/AniAdd/lexer.cpp index b12a7d7..4c23d2d 100644 --- a/renameparser/AniAdd/lexer.cpp +++ b/renameparser/AniAdd/lexer.cpp @@ -44,7 +44,7 @@ bool Lexer::next() m_column += m_last_match.capturedLength(); if (m_last_match.captured() == "\n" || - m_last_match.captured()[0] == QChar('#') || + m_last_match.captured().at(0) == QChar('#') || m_last_match.captured().left(2) == "//") { ++m_line; @@ -57,8 +57,8 @@ bool Lexer::next() { m_type = tokenMap.value(m_last_match.captured()); } - else if (m_last_match.captured()[0] == QChar('"') || - m_last_match.captured()[0] == QChar('\'')) + else if (m_last_match.captured().at(0) == QChar('"') || + m_last_match.captured().at(0) == QChar('\'')) { m_type = RenameGrammar::STRING; } diff --git a/updatecommand.cpp b/updatecommand.cpp index 33d58d1..2727f65 100644 --- a/updatecommand.cpp +++ b/updatecommand.cpp @@ -109,14 +109,14 @@ void UpdateReply::setRawReply(ReplyCode replyCode, const QString &reply) m_entity = parts[0].toInt(&ok, 10); m_totalCount = parts[1].toInt(&ok); m_lastUpdateDate = QDateTime::fromMSecsSinceEpoch(1000 * QString(parts[2]).toLongLong(&ok)); - QStringList aidList = parts[3].split(','); + const QStringList aidList = parts[3].split(','); m_aid.clear(); m_aid.reserve(aidList.count()); - for (auto aid : aidList) + for (const auto &aid : aidList) { m_aid << aid.toInt(&ok); } - replyReady(true); + emit replyReady(true); } break; case NO_UPDATES: @@ -124,11 +124,11 @@ void UpdateReply::setRawReply(ReplyCode replyCode, const QString &reply) m_totalCount = 0; m_lastUpdateDate = QDateTime{}; m_aid.clear(); - replyReady(true); - break; + emit replyReady(true); + break; default: - replyReady(false); - break; + emit replyReady(false); + break; } }