client: Clean up CoreAccount, add qDebug support
authorShane Synan <digitalcircuit36939@gmail.com>
Mon, 18 Jun 2018 00:17:21 +0000 (19:17 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 18 Jun 2018 19:27:30 +0000 (21:27 +0200)
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.

src/client/coreaccount.cpp
src/client/coreaccount.h
src/client/coreaccountmodel.cpp
src/client/coreaccountmodel.h
src/qtui/settingspages/coreaccountsettingspage.cpp

index 6cb0168..ad0dedc 100644 (file)
@@ -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();
 }
 }
index b608f9e..d8acb42 100644 (file)
@@ -22,6 +22,7 @@
 #define COREACCOUNT_H_
 
 #include <QCoreApplication>
 #define COREACCOUNT_H_
 
 #include <QCoreApplication>
+#include <QDebug>
 #include <QNetworkProxy>
 #include <QUuid>
 #include <QVariantMap>
 #include <QNetworkProxy>
 #include <QUuid>
 #include <QVariantMap>
@@ -78,6 +79,7 @@ public:
     virtual void fromVariantMap(const QVariantMap &);
 
     bool operator==(const CoreAccount &other) const;
     virtual void fromVariantMap(const QVariantMap &);
 
     bool operator==(const CoreAccount &other) const;
+    bool operator!=(const CoreAccount &other) const;
 
 private:
     AccountId _accountId;
 
 private:
     AccountId _accountId;
@@ -92,5 +94,6 @@ private:
     uint _proxyPort;
 };
 
     uint _proxyPort;
 };
 
+QDebug operator<<(QDebug dbg, const CoreAccount &msg);
 
 #endif
 
 #endif
index 267a3b6..0e323bb 100644 (file)
@@ -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)
 {
 // TODO with Qt 4.6, use QAbstractItemModel move semantics to properly do this
 AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc)
 {
index 93d2d7e..9814d08 100644 (file)
@@ -57,6 +57,7 @@ public:
     void update(const CoreAccountModel *other);
 
     bool operator==(const CoreAccountModel &other) const;
     void update(const CoreAccountModel *other);
 
     bool operator==(const CoreAccountModel &other) const;
+    bool operator!=(const CoreAccountModel &other) const;
 
 public slots:
     void save();
 
 public slots:
     void save();
index 870f78c..0ccf5ad 100644 (file)
@@ -226,8 +226,9 @@ bool CoreAccountSettingsPage::testHasChanged()
 {
     if (ui.autoConnectAccount->currentIndex() != ui.autoConnectAccount->property("storedValue").toInt())
         return true;
 {
     if (ui.autoConnectAccount->currentIndex() != ui.autoConnectAccount->property("storedValue").toInt())
         return true;
-    if (!(*model() == *Client::coreAccountModel()))
+    if (*model() != *Client::coreAccountModel()) {
         return true;
         return true;
+    }
 
     return false;
 }
 
     return false;
 }