+
+QString NetworkItem::toolTip(int column) const {
+ Q_UNUSED(column);
+
+ QStringList toolTip(QString("<b>%1</b>").arg(networkName()));
+ toolTip.append(QString("Server: %1").arg(currentServer()));
+ toolTip.append(QString("Users: %1").arg(nickCount()));
+
+ return QString("<p> %1 </p>").arg(toolTip.join("<br />"));
+}
+
+
+/*****************************************
+* User Category Items (like @vh etc.)
+*****************************************/
+// we hardcode this even though we have PREFIX in network... but that wouldn't help with mapping modes to
+// category strings anyway.
+// TODO make this translateable depending on the number of users in a category
+// -> we can't set the real string here, because tr() needs to get the actual number as second param
+// -> tr("%n User(s)", n) needs to be used somewhere where we do know the user number n
+const QList<UserCategoryItem::Category> UserCategoryItem::categories = QList<UserCategoryItem::Category>()
+ << UserCategoryItem::Category('q', tr("Owners"))
+ << UserCategoryItem::Category('a', tr("Admins"))
+ << UserCategoryItem::Category('o', tr("Operators"))
+ << UserCategoryItem::Category('h', tr("Half-Ops"))
+ << UserCategoryItem::Category('v', tr("Voiced"));
+
+UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
+ : PropertyMapItem(QStringList() << "categoryId", parent),
+ _category(category)
+{
+}
+
+QString UserCategoryItem::categoryId() {
+ if(_category < categories.count())
+ return categories[_category].displayString;
+ else
+ return tr("Users");
+}
+
+quint64 UserCategoryItem::id() const {
+ return qHash(_category);
+}
+
+void UserCategoryItem::addUsers(const QList<IrcUser *> &ircUsers) {
+ QList<AbstractTreeItem *> userItems;
+ foreach(IrcUser *ircUser, ircUsers)
+ userItems << new IrcUserItem(ircUser, this);
+ newChilds(userItems);
+}
+
+bool UserCategoryItem::removeUser(IrcUser *ircUser) {
+ return removeChildById(qHash(ircUser));
+}
+
+int UserCategoryItem::categoryFromModes(const QString &modes) {
+ for(int i = 0; i < categories.count(); i++) {
+ if(modes.contains(categories[i].mode))
+ return i;
+ }
+ return categories.count();
+}
+
+QVariant UserCategoryItem::data(int column, int role) const {
+ switch(role) {
+ case NetworkModel::ItemActiveRole:
+ return true;
+ case NetworkModel::ItemTypeRole:
+ return NetworkModel::UserCategoryItemType;
+ case NetworkModel::BufferIdRole:
+ return parent()->data(column, role);
+ case NetworkModel::NetworkIdRole:
+ return parent()->data(column, role);
+ case NetworkModel::BufferInfoRole:
+ return parent()->data(column, role);
+ default:
+ return PropertyMapItem::data(column, role);
+ }
+}
+
+