cmake: Autogenerate most of the .qrc resource files
[quassel.git] / src / client / networkmodel.cpp
index 8214966..5daec85 100644 (file)
@@ -22,9 +22,6 @@
 
 #include <QAbstractItemView>
 #include <QMimeData>
-#if QT_VERSION < 0x050000
-#include <QTextDocument>        // for Qt::escape()
-#endif
 
 #include "buffermodel.h"
 #include "buffersettings.h"
@@ -40,7 +37,7 @@
 *  Network Items
 *****************************************/
 NetworkItem::NetworkItem(const NetworkId &netid, AbstractTreeItem *parent)
-    : PropertyMapItem(QList<QString>() << "networkName" << "currentServer" << "nickCount", parent),
+    : PropertyMapItem(parent),
     _networkId(netid),
     _statusBufferItem(0)
 {
@@ -53,6 +50,13 @@ NetworkItem::NetworkItem(const NetworkId &netid, AbstractTreeItem *parent)
 }
 
 
+QStringList NetworkItem::propertyOrder() const
+{
+    static QStringList order{"networkName", "currentServer", "nickCount"};
+    return order;
+}
+
+
 QVariant NetworkItem::data(int column, int role) const
 {
     switch (role) {
@@ -79,11 +83,7 @@ QString NetworkItem::escapeHTML(const QString &string, bool useNonbreakingSpaces
 {
     // QString.replace() doesn't guarantee the source string will remain constant.
     // Use a local variable to avoid compiler errors.
-#if QT_VERSION < 0x050000
-    QString formattedString = Qt::escape(string);
-#else
     QString formattedString = string.toHtmlEscaped();
-#endif
     return (useNonbreakingSpaces ? formattedString.replace(" ", "&nbsp;") : formattedString);
 }
 
@@ -283,7 +283,7 @@ void NetworkItem::onNetworkDestroyed()
 *  Fancy Buffer Items
 *****************************************/
 BufferItem::BufferItem(const BufferInfo &bufferInfo, AbstractTreeItem *parent)
-    : PropertyMapItem(QStringList() << "bufferName" << "topic" << "nickCount", parent),
+    : PropertyMapItem(parent),
     _bufferInfo(bufferInfo),
     _activity(BufferInfo::NoActivity)
 {
@@ -291,6 +291,13 @@ BufferItem::BufferItem(const BufferInfo &bufferInfo, AbstractTreeItem *parent)
 }
 
 
+QStringList BufferItem::propertyOrder() const
+{
+    static QStringList order{"bufferName", "topic", "nickCount"};
+    return order;
+}
+
+
 void BufferItem::setActivityLevel(BufferInfo::ActivityLevel level)
 {
     if (_activity != level) {
@@ -641,8 +648,8 @@ QString QueryBufferItem::toolTip(int column) const
                    NetworkItem::escapeHTML(tr("Identified for this nick")),
                    !accountAdded);
             // Don't add the account row again if information's already added via account-notify
-            // Mark the row as added
-            accountAdded = true;
+            // Not used further down...
+            // accountAdded = true;
         } else {
             addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
                    NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),
@@ -992,7 +999,7 @@ void ChannelBufferItem::userModeChanged(IrcUser *ircUser)
 const QList<QChar> UserCategoryItem::categories = QList<QChar>() << 'q' << 'a' << 'o' << 'h' << 'v';
 
 UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
-    : PropertyMapItem(QStringList() << "categoryName", parent),
+    : PropertyMapItem(parent),
     _category(category)
 {
     setFlags(Qt::ItemIsEnabled);
@@ -1001,6 +1008,13 @@ UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
 }
 
 
+QStringList UserCategoryItem::propertyOrder() const
+{
+    static QStringList order{"categoryName"};
+    return order;
+}
+
+
 // caching this makes no sense, since we display the user number dynamically
 QString UserCategoryItem::categoryName() const
 {
@@ -1094,7 +1108,7 @@ QVariant UserCategoryItem::data(int column, int role) const
 *  Irc User Items
 *****************************************/
 IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
-    : PropertyMapItem(QStringList() << "nickName", parent),
+    : PropertyMapItem(parent),
     _ircUser(ircUser)
 {
     setObjectName(ircUser->nick());
@@ -1104,6 +1118,13 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
 }
 
 
+QStringList IrcUserItem::propertyOrder() const
+{
+    static QStringList order{"nickName"};
+    return order;
+}
+
+
 QVariant IrcUserItem::data(int column, int role) const
 {
     switch (role) {
@@ -1208,8 +1229,8 @@ QString IrcUserItem::toolTip(int column) const
                NetworkItem::escapeHTML(tr("Identified for this nick")),
                !accountAdded);
         // Don't add the account row again if information's already added via account-notify
-        // Mark the row as added
-        accountAdded = true;
+        // Not used further down...
+        // accountAdded = true;
     } else {
         addRow(NetworkItem::escapeHTML(tr("Service Reply"), true),
                NetworkItem::escapeHTML(_ircUser->whoisServiceReply()),