Fixing BR #147. Needs core update.
[quassel.git] / src / client / networkmodel.h
index 861d07c..8dceb5a 100644 (file)
@@ -33,12 +33,12 @@ class BufferInfo;
 #include "selectionmodelsynchronizer.h"
 #include "modelpropertymapper.h"
 #include "clientsettings.h"
+#include "ircuser.h"
 
 class MappedSelectionModel;
 class QAbstractItemView;
 class Network;
 class IrcChannel;
-class IrcUser;
 
 /*****************************************
  *  Fancy Buffer Items
@@ -72,7 +72,7 @@ public:
   bool isActive() const;
 
   inline Buffer::ActivityLevel activityLevel() const { return _activity; }
-  bool setActivityLevel(Buffer::ActivityLevel level);
+  void setActivityLevel(Buffer::ActivityLevel level);
   void updateActivityLevel(Buffer::ActivityLevel level);
 
   void setLastMsgInsert(QDateTime msgDate);
@@ -100,7 +100,7 @@ private:
   QString _bufferName;
   Buffer::ActivityLevel _activity;
 
-  QPointer<IrcChannel> _ircChannel;
+  IrcChannel *_ircChannel;
 };
 
 
@@ -146,12 +146,12 @@ private:
 *****************************************/
 class UserCategoryItem : public PropertyMapItem {
   Q_OBJECT
-  Q_PROPERTY(QString categoryId READ categoryId)
+  Q_PROPERTY(QString categoryName READ categoryName)
     
 public:
   UserCategoryItem(int category, AbstractTreeItem *parent);
 
-  QString categoryId();
+  QString categoryName() const;
   virtual quint64 id() const;
   virtual QVariant data(int column, int role) const;
   
@@ -163,13 +163,7 @@ public:
 private:
   int _category;
 
-  struct Category {
-    QChar mode;
-    QString displayString;
-    inline Category(QChar mode_, QString displayString_) : mode(mode_), displayString(displayString_) {};
-  };
-
-  static const QList<Category> categories;
+  static const QList<QChar> categories;
 };
 
 /*****************************************
@@ -185,8 +179,8 @@ public:
   QString nickName() const;
   bool isActive() const;
 
-  IrcUser *ircUser();
-  virtual quint64 id() const;
+  inline IrcUser *ircUser() { return _ircUser; }
+  inline virtual quint64 id() const { return _id; }
   virtual QVariant data(int column, int role) const;
   virtual QString toolTip(int column) const;
 
@@ -208,7 +202,7 @@ class NetworkModel : public TreeModel {
 
 public:
   enum myRoles {
-    BufferTypeRole = Qt::UserRole,
+    BufferTypeRole = TreeModel::UserRole,
     ItemActiveRole,
     BufferActivityRole,
     BufferIdRole,
@@ -217,12 +211,13 @@ public:
     ItemTypeRole
   };
 
-  enum itemTypes {
-    NetworkItemType,
-    BufferItemType,
-    UserCategoryItemType,
-    IrcUserItemType
+  enum itemType {
+    NetworkItemType = 0x01,
+    BufferItemType = 0x02,
+    UserCategoryItemType = 0x04,
+    IrcUserItemType = 0x08
   };
+  Q_DECLARE_FLAGS(itemTypes, itemType);
 
   NetworkModel(QObject *parent = 0);
   static QList<QVariant> defaultHeader();
@@ -238,6 +233,7 @@ public:
 
   bool isBufferIndex(const QModelIndex &) const;
   //Buffer *getBufferByIndex(const QModelIndex &) const;
+  QModelIndex networkIndex(NetworkId networkId);
   QModelIndex bufferIndex(BufferId bufferId);
 
   const Network *networkByIndex(const QModelIndex &index) const;
@@ -251,12 +247,12 @@ public slots:
   void networkRemoved(const NetworkId &networkId);
   
 private:
-  QModelIndex networkIndex(NetworkId networkId);
   NetworkItem *networkItem(NetworkId networkId);
   NetworkItem *existsNetworkItem(NetworkId networkId);
   BufferItem *bufferItem(const BufferInfo &bufferInfo);
   BufferItem *existsBufferItem(const BufferInfo &bufferInfo);
 
 };
+Q_DECLARE_OPERATORS_FOR_FLAGS(NetworkModel::itemTypes);
 
 #endif // NETWORKMODEL_H