X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fnickmodel.h;h=8a65e9d7f59b463bb5dc02e54086f720a5835ea1;hb=69952553cf2f5248a0c7e964d6d5844065d26612;hp=b49ebf1da430f45e849d6314998e68a1e0237753;hpb=e671e9da1edaab37ec403f575979f9a92a766e9a;p=quassel.git diff --git a/src/client/nickmodel.h b/src/client/nickmodel.h index b49ebf1d..8a65e9d7 100644 --- a/src/client/nickmodel.h +++ b/src/client/nickmodel.h @@ -22,6 +22,7 @@ #define _NICKMODEL_H_ #include +#include #include class IrcChannel; @@ -32,12 +33,14 @@ class IrcUser; * levels, where the top-level items are the categories (such as Ops, Voiced etc), and the second-level items * the actual nicks/users. Several roles are provided to access information about a nick. * - * Note that the nicks are not sorted in any way. Use a QSortFilterProxyModel to do that instead. + * Note that the nicks are not sorted in any way. Use a FilteredNickModel instead. */ class NickModel : public QAbstractItemModel { Q_OBJECT public: + enum NickModelRole { SortKeyRole = Qt::UserRole }; + NickModel(IrcChannel *channel = 0, QObject *parent = 0); virtual ~NickModel(); @@ -56,7 +59,7 @@ class NickModel : public QAbstractItemModel { int userCategory(IrcUser *) const; public slots: - void setIrcChannel(IrcChannel *); + void setIrcChannel(IrcChannel *chan = 0); void addUser(IrcUser *); void removeUser(IrcUser *); void removeUser(const QModelIndex &); @@ -70,4 +73,16 @@ class NickModel : public QAbstractItemModel { }; +//! This ProxyModel can be used on top of a NickModel in order to provide a sorted nicklist and to hide unused categories. +class FilteredNickModel : public QSortFilterProxyModel { + Q_OBJECT + + public: + FilteredNickModel(QObject *parent = 0); + + protected: + virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; + +}; + #endif