1 /***************************************************************************
2 * Copyright (C) 2005-07 by the Quassel IRC Team *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include <QAbstractItemModel>
30 //! Represents the IrcUsers in a given IrcChannel.
31 /** This model is a wrapper around the nicks/IrcUsers stored in an IrcChannel. It provides a tree with two,
32 * levels, where the top-level items are the categories (such as Ops, Voiced etc), and the second-level items
33 * the actual nicks/users. Several roles are provided to access information about a nick.
35 * Note that the nicks are not sorted in any way. Use a QSortFilterProxyModel to do that instead.
37 class NickModel : public QAbstractItemModel {
41 NickModel(IrcChannel *channel = 0, QObject *parent = 0);
44 virtual QModelIndex index(int row, int col, const QModelIndex &parent) const;
45 virtual QModelIndex parent(const QModelIndex &index) const;
46 virtual int rowCount(const QModelIndex &) const;
47 virtual int columnCount(const QModelIndex &) const;
48 virtual QVariant data(const QModelIndex &, int role) const;
49 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
51 IrcChannel *ircChannel() const;
53 QModelIndex indexOfUser(IrcUser *) const;
54 int categoryFromModes(const QString &modes) const;
55 int categoryFromIndex(const QModelIndex &index) const;
56 int userCategory(IrcUser *) const;
59 void setIrcChannel(IrcChannel *);
60 void addUser(IrcUser *);
61 void removeUser(IrcUser *);
62 void removeUser(const QModelIndex &);
63 void renameUser(IrcUser *);
64 void changeUserModes(IrcUser *);
68 IrcChannel *_ircChannel;
69 QVector<QList<IrcUser *> > users;