+QVariant BufferItem::data(int column, int role) const {
+ switch(role) {
+ case NetworkModel::ItemTypeRole:
+ return NetworkModel::BufferItemType;
+ case NetworkModel::BufferUidRole:
+ return buf->bufferInfo().uid();
+ case NetworkModel::NetworkIdRole:
+ return buf->bufferInfo().networkId();
+ case NetworkModel::BufferTypeRole:
+ return int(buf->bufferType());
+ case NetworkModel::BufferActiveRole:
+ return buf->isActive();
+ case Qt::ForegroundRole:
+ return foreground(column);
+ default:
+ return PropertyMapItem::data(column, role);
+ }
+}
+
+void BufferItem::attachIrcChannel(IrcChannel *ircChannel) {
+ if(!ircChannel)
+ return;
+
+ _ircChannel = ircChannel;
+
+ connect(ircChannel, SIGNAL(topicSet(QString)),
+ this, SLOT(setTopic(QString)));
+ connect(ircChannel, SIGNAL(ircUserJoined(IrcUser *)),
+ this, SLOT(join(IrcUser *)));
+ connect(ircChannel, SIGNAL(ircUserParted(IrcUser *)),
+ this, SLOT(part(IrcUser *)));
+}
+
+QString BufferItem::bufferName() const {
+ return buf->name();
+}
+
+QString BufferItem::topic() const {
+ if(_ircChannel)
+ return _ircChannel->topic();
+ else
+ return QString();
+}
+
+int BufferItem::nickCount() const {
+ if(_ircChannel)
+ return _ircChannel->ircUsers().count();
+ else
+ return 0;
+}
+
+void BufferItem::setTopic(const QString &topic) {
+ Q_UNUSED(topic);
+ emit dataChanged(1);
+}
+
+void BufferItem::join(IrcUser *ircUser) {
+// emit newChild(new IrcUserItem(ircUser, this));
+// emit dataChanged(2);
+}
+
+void BufferItem::part(IrcUser *ircUser) {
+ Q_UNUSED(ircUser);
+ emit dataChanged(2);
+}
+
+/*****************************************
+* Network Items
+*****************************************/
+NetworkItem::NetworkItem(const uint &netid, const QString &network, AbstractTreeItem *parent)
+ : PropertyMapItem(QList<QString>() << "networkName" << "currentServer" << "nickCount", parent),
+ _networkId(netid),
+ _networkName(network)
+{
+ setFlags(Qt::ItemIsEnabled);
+}