From: Shane Synan Date: Mon, 18 Jun 2018 00:17:21 +0000 (-0500) Subject: client: Clean up CoreAccount, add qDebug support X-Git-Tag: 0.13-rc1~41 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=db6e6642a43143bc45ddb0732d144815b68e37f8 client: Clean up CoreAccount, add qDebug support Clean up CoreAccount and CoreAccountModel, adding support for the negated equality operator '!=' and qDebug() printing. Modify CoreAccountSettingsPage::testHasChanged() to make use of the negated equality operator. --- diff --git a/src/client/coreaccount.cpp b/src/client/coreaccount.cpp index 6cb01681..ad0dedcd 100644 --- a/src/client/coreaccount.cpp +++ b/src/client/coreaccount.cpp @@ -169,7 +169,34 @@ void CoreAccount::fromVariantMap(const QVariantMap &v) } -bool CoreAccount::operator==(const CoreAccount &o) const +bool CoreAccount::operator==(const CoreAccount &other) const { - return toVariantMap(true) == o.toVariantMap(true); + return toVariantMap(true) == other.toVariantMap(true); +} + + +bool CoreAccount::operator!=(const CoreAccount &other) const +{ + return !(*this == other); +} + + +QDebug operator<<(QDebug dbg, const CoreAccount &acc) +{ + dbg.nospace() << qPrintable(QString("CoreAccount(AccountId:")) << acc.accountId() + << qPrintable(QString(", AccountName:")) << acc.accountName() + << qPrintable(QString(", Uuid:")) << acc.uuid() + << qPrintable(QString(", Internal:")) << acc.isInternal() + << qPrintable(QString(", User:")) << acc.user() + << qPrintable(QString(", Password:")) << acc.password() + << qPrintable(QString(", StorePassword:")) << acc.storePassword() + << qPrintable(QString(", HostName:")) << acc.hostName() + << qPrintable(QString(", Port:")) << acc.port() + << qPrintable(QString(", UseSSL:")) << acc.useSsl() + << qPrintable(QString(", ProxyType:")) << acc.proxyType() + << qPrintable(QString(", ProxyUser:")) << acc.proxyUser() + << qPrintable(QString(", ProxyPassword:")) << acc.proxyPassword() + << qPrintable(QString(", ProxyHostName:")) << acc.proxyHostName() + << qPrintable(QString(", ProxyPort:")) << acc.proxyPort(); + return dbg.space(); } diff --git a/src/client/coreaccount.h b/src/client/coreaccount.h index b608f9ee..d8acb428 100644 --- a/src/client/coreaccount.h +++ b/src/client/coreaccount.h @@ -22,6 +22,7 @@ #define COREACCOUNT_H_ #include +#include #include #include #include @@ -78,6 +79,7 @@ public: virtual void fromVariantMap(const QVariantMap &); bool operator==(const CoreAccount &other) const; + bool operator!=(const CoreAccount &other) const; private: AccountId _accountId; @@ -92,5 +94,6 @@ private: uint _proxyPort; }; +QDebug operator<<(QDebug dbg, const CoreAccount &msg); #endif diff --git a/src/client/coreaccountmodel.cpp b/src/client/coreaccountmodel.cpp index 267a3b6d..0e323bb4 100644 --- a/src/client/coreaccountmodel.cpp +++ b/src/client/coreaccountmodel.cpp @@ -155,6 +155,12 @@ bool CoreAccountModel::operator==(const CoreAccountModel &other) const } +bool CoreAccountModel::operator!=(const CoreAccountModel &other) const +{ + return !(*this == other); +} + + // TODO with Qt 4.6, use QAbstractItemModel move semantics to properly do this AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) { diff --git a/src/client/coreaccountmodel.h b/src/client/coreaccountmodel.h index 93d2d7ed..9814d08b 100644 --- a/src/client/coreaccountmodel.h +++ b/src/client/coreaccountmodel.h @@ -57,6 +57,7 @@ public: void update(const CoreAccountModel *other); bool operator==(const CoreAccountModel &other) const; + bool operator!=(const CoreAccountModel &other) const; public slots: void save(); diff --git a/src/qtui/settingspages/coreaccountsettingspage.cpp b/src/qtui/settingspages/coreaccountsettingspage.cpp index 870f78c6..0ccf5ad4 100644 --- a/src/qtui/settingspages/coreaccountsettingspage.cpp +++ b/src/qtui/settingspages/coreaccountsettingspage.cpp @@ -226,8 +226,9 @@ bool CoreAccountSettingsPage::testHasChanged() { if (ui.autoConnectAccount->currentIndex() != ui.autoConnectAccount->property("storedValue").toInt()) return true; - if (!(*model() == *Client::coreAccountModel())) + if (*model() != *Client::coreAccountModel()) { return true; + } return false; }