* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * (at your option) version 3. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _BUFFERTREEMODEL_H_
-#define _BUFFERTREEMODEL_H_
+#ifndef NETWORKMODEL_H
+#define NETWORKMODEL_H
#include <QtCore>
#include "modelpropertymapper.h"
class MappedSelectionModel;
class QAbstractItemView;
+class NetworkInfo;
+class IrcChannel;
+class IrcUser;
/*****************************************
* Fancy Buffer Items
*****************************************/
-class BufferTreeItem : public TreeItem {
+class BufferItem : public PropertyMapItem {
Q_OBJECT
+ Q_PROPERTY(QString bufferName READ bufferName)
+ Q_PROPERTY(QString topic READ topic)
+ Q_PROPERTY(int nickCount READ nickCount)
public:
- BufferTreeItem(Buffer *, TreeItem *parent = 0);
+ BufferItem(Buffer *, AbstractTreeItem *parent = 0);
- virtual uint id() const;
- QVariant data(int column, int role) const;
+ virtual quint64 id() const;
+ virtual QVariant data(int column, int role) const;
+ void attachIrcChannel(IrcChannel *ircChannel);
+
+ QString bufferName() const;
+ QString topic() const;
+ int nickCount() const;
+
+
Buffer *buffer() const { return buf; }
void setActivity(const Buffer::ActivityLevel &);
+public slots:
+ void setTopic(const QString &topic);
+ void join(IrcUser *ircUser);
+ void part(IrcUser *ircUser);
+
private:
- QString text(int column) const;
QColor foreground(int column) const;
Buffer *buf;
Buffer::ActivityLevel activity;
+
+ QPointer<IrcChannel> _ircChannel;
};
/*****************************************
* Network Items
*****************************************/
-class NetworkTreeItem : public TreeItem {
+class NetworkItem : public PropertyMapItem {
Q_OBJECT
-
+ Q_PROPERTY(QString networkName READ networkName)
+ Q_PROPERTY(QString currentServer READ currentServer)
+ Q_PROPERTY(int nickCount READ nickCount)
+
public:
- NetworkTreeItem(const uint &netid, const QString &, TreeItem *parent = 0);
+ NetworkItem(const uint &netid, const QString &, AbstractTreeItem *parent = 0);
virtual QVariant data(int column, int row) const;
- virtual uint id() const;
+ virtual quint64 id() const;
+ QString networkName() const;
+ QString currentServer() const;
+ int nickCount() const;
+
+public slots:
+ void setNetworkName(const QString &networkName);
+ void setCurrentServer(const QString &serverName);
+
+ void attachNetworkInfo(NetworkInfo *networkInfo);
+ void attachIrcChannel(const QString &channelName);
+
private:
uint _networkId;
- QString net;
+ QString _networkName;
+
+ QPointer<NetworkInfo> _networkInfo;
};
/*****************************************
- * BufferTreeModel
+* Irc User Items
+*****************************************/
+class IrcUserItem : public PropertyMapItem {
+ Q_OBJECT
+ Q_PROPERTY(QString nickName READ nickName)
+
+public:
+ IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent);
+
+ QString nickName();
+
+private slots:
+ void setNick(QString newNick);
+ void ircUserDestroyed();
+
+private:
+ IrcUser *_ircUser;
+};
+
+
+/*****************************************
+ * NetworkModel
*****************************************/
-class BufferTreeModel : public TreeModel {
+class NetworkModel : public TreeModel {
Q_OBJECT
public:
BufferTypeRole = Qt::UserRole,
BufferActiveRole,
BufferUidRole,
- NetworkIdRole
+ NetworkIdRole,
+ ItemTypeRole
};
- BufferTreeModel(QObject *parent = 0);
+ enum itemTypes {
+ AbstractItemType,
+ SimpleItemType,
+ NetworkItemType,
+ BufferItemType,
+ NickItemType
+ };
+
+ NetworkModel(QObject *parent = 0);
static QList<QVariant> defaultHeader();
inline SelectionModelSynchronizer *selectionModelSynchronizer() { return _selectionModelSynchronizer; }
virtual QMimeData *mimeData(const QModelIndexList &) const;
virtual bool dropMimeData(const QMimeData *, Qt::DropAction, int, int, const QModelIndex &);
-
+ void attachNetworkInfo(NetworkInfo *networkInfo);
+
public slots:
void bufferUpdated(Buffer *);
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
signals:
void bufferSelected(Buffer *);
- void invalidateFilter();
void selectionChanged(const QModelIndex &);
private:
bool isBufferIndex(const QModelIndex &) const;
Buffer *getBufferByIndex(const QModelIndex &) const;
- QModelIndex getOrCreateNetworkItemIndex(Buffer *buffer);
- QModelIndex getOrCreateBufferItemIndex(Buffer *buffer);
+
+ QModelIndex networkIndex(uint networkId);
+ NetworkItem *network(uint networkId);
+ NetworkItem *newNetwork(uint networkId, const QString &networkName);
+
+ QModelIndex bufferIndex(BufferInfo bufferInfo);
+ BufferItem *buffer(BufferInfo bufferInfo);
+ BufferItem *newBuffer(BufferInfo bufferInfo);
QPointer<SelectionModelSynchronizer> _selectionModelSynchronizer;
QPointer<ModelPropertyMapper> _propertyMapper;
Buffer *currentBuffer;
};
-#endif
+#endif // NETWORKMODEL_H