Fix some clazy warnings

master
Jonah Brüchert 2020-08-20 00:52:45 +02:00 committed by Linus Jahn
parent f23661c0bf
commit 60ed9e2b48
8 changed files with 23 additions and 22 deletions

View File

@ -55,7 +55,7 @@
#include "VCardManager.h"
ClientWorker::ClientWorker(Caches *caches, Kaidan *kaidan, bool enableLogging, QObject* parent)
: QObject(parent), m_caches(caches), m_kaidan(kaidan), m_enableLogging(enableLogging)
: QObject(parent), m_caches(caches), m_kaidan(kaidan), m_enableLogging(enableLogging), m_isApplicationWindowActive(true)
{
m_client = new QXmppClient(this);
m_logger = new LogHandler(m_client, this);
@ -201,7 +201,7 @@ void ClientWorker::handleAccountDeletedFromServer()
m_isAccountDeletedFromServer = true;
}
void ClientWorker::handleAccountDeletionFromServerFailed(QXmppStanza::Error error)
void ClientWorker::handleAccountDeletionFromServerFailed(const QXmppStanza::Error &error)
{
emit m_kaidan->passiveNotificationRequested(tr("Your account could not be deleted from the server. Therefore, it was also not removed from this app: %1").arg(error.text()));
@ -278,7 +278,7 @@ void ClientWorker::onConnected()
m_displayNameToBeSetOnNextConnect.clear();
}
emit m_caches->msgModel->sendPendingMessages();
m_caches->msgModel->sendPendingMessages();
}
void ClientWorker::onDisconnected()
@ -357,7 +357,7 @@ void ClientWorker::setIsApplicationWindowActive(bool active)
m_isApplicationWindowActive = active;
}
QString ClientWorker::generateJidResourceWithRandomSuffix(const QString jidResourcePrefix, unsigned int length) const
QString ClientWorker::generateJidResourceWithRandomSuffix(const QString &jidResourcePrefix, unsigned int length) const
{
return jidResourcePrefix % "." % QXmppUtils::generateStanzaHash(length);
}

View File

@ -134,6 +134,13 @@ public:
*/
Caches *caches() const;
/**
* Returns whether the application window is active.
*
* The application window is active when it is in the foreground and focused.
*/
bool isApplicationWindowActive() const;
public slots:
/**
* Main function of the client thread
@ -187,7 +194,7 @@ public slots:
*
* @param error error of the failed account deletion
*/
void handleAccountDeletionFromServerFailed(QXmppStanza::Error error);
void handleAccountDeletionFromServerFailed(const QXmppStanza::Error &error);
/**
* Changes the user's password.
@ -205,13 +212,6 @@ public slots:
*/
void changeDisplayName(const QString &displayName);
/**
* Returns whether the application window is active.
*
* The application window is active when it is in the foreground and focused.
*/
bool isApplicationWindowActive() const;
signals:
/**
* Requests to show a notification for a chat message via the system's notification channel.
@ -269,7 +269,7 @@ private:
*
* @param length number of random alphanumeric characters the suffix should consist of after the dot
*/
QString generateJidResourceWithRandomSuffix(const QString jidResourcePrefix, unsigned int length = 4) const;
QString generateJidResourceWithRandomSuffix(const QString &jidResourcePrefix, unsigned int length = 4) const;
Caches *m_caches;

View File

@ -170,7 +170,7 @@ void Kaidan::setConnectionState(QXmppClient::State state)
// This is needed because the XMPP URIs can't be opened when Kaidan is not connected.
if (m_connectionState == ConnectionState::StateConnected && !m_openUriCache.isEmpty()) {
// delay is needed because sometimes the RosterPage needs to be loaded first
QTimer::singleShot(300, [=] () {
QTimer::singleShot(300, this, [=] () {
emit xmppUriReceived(m_openUriCache);
m_openUriCache = "";
});

View File

@ -426,7 +426,7 @@ Enums::MessageType MediaUtils::messageType(const QUrl &url)
mimeTypes = s_mimeDB.mimeTypesForFileName(fileInfo.fileName());
}
for (const QMimeType &mimeType: mimeTypes) {
for (const QMimeType &mimeType : std::as_const(mimeTypes)) {
const Enums::MessageType messageType = MediaUtils::messageType(mimeType);
if (messageType != Enums::MessageType::MessageUnknown) {

View File

@ -67,7 +67,7 @@ QImage QrCodeGenerator::generateQrCode(const QString &text, int edgePixelCount)
const ZXing::BitMatrix &bitMatrix = writer.encode(text.toStdWString(), edgePixelCount, edgePixelCount);
return toImage(bitMatrix);
} catch (const std::invalid_argument &e) {
Kaidan::instance()->passiveNotificationRequested(tr("Generating the QR code failed: %1").arg(e.what()));
emit Kaidan::instance()->passiveNotificationRequested(tr("Generating the QR code failed: %1").arg(e.what()));
}
return {};

View File

@ -116,7 +116,7 @@ void VCardModel::setJid(const QString &jid)
m_jid = jid;
emit jidChanged();
Kaidan::instance()->vCardRequested(jid);
emit Kaidan::instance()->vCardRequested(jid);
}
VCardModel::Item::Item(const QString &key, const QString &value)

View File

@ -297,8 +297,8 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
<< "You can enable multiple instances by specifying '--multiple'.";
// send a possible link to the primary instance
if (!parser.positionalArguments().isEmpty())
app.sendMessage(parser.positionalArguments().first().toUtf8());
if (const auto positionalArguments = parser.positionalArguments(); !positionalArguments.isEmpty())
app.sendMessage(positionalArguments.first().toUtf8());
return 0;
}
#endif
@ -315,8 +315,8 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
#endif
// open the XMPP-URI/link (if given)
if (!parser.positionalArguments().isEmpty())
kaidan->addOpenUri(parser.positionalArguments().first());
if (const auto positionalArguments = parser.positionalArguments(); !positionalArguments.isEmpty())
kaidan->addOpenUri(positionalArguments.first());
//
// QML-GUI

View File

@ -119,7 +119,8 @@ QXmppUri::QXmppUri(QString input)
if (!query.queryItems().size())
return;
m_action = Action(ACTION_STRINGS.indexOf(query.queryItems().first().first));
const auto queryItems = query.queryItems();
m_action = Action(ACTION_STRINGS.indexOf(queryItems.first().first));
switch (m_action) {
case Message: