Keeps track of channel users. More...
Inherits QAbstractListModel.
Public Slots | |
| void | clear () |
| void | sort (int column=0, Qt::SortOrder order=Qt::AscendingOrder) |
| void | sort (Irc::SortMethod method, Qt::SortOrder order=Qt::AscendingOrder) |
Signals | |
| void | aboutToBeAdded (IrcUser *user) |
| void | aboutToBeRemoved (IrcUser *user) |
| void | added (IrcUser *user) |
| void | removed (IrcUser *user) |
Public Member Functions | |
| IrcUserModel (QObject *parent=0) | |
| virtual | ~IrcUserModel () |
| Q_INVOKABLE bool | contains (const QString &name) const |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
| Q_INVOKABLE IrcUser * | find (const QString &name) const |
| Q_INVOKABLE IrcUser * | get (int index) const |
| QModelIndex | index (IrcUser *user) const |
| QModelIndex | index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const |
| Q_INVOKABLE int | indexOf (IrcUser *user) const |
| QHash< int, QByteArray > | roleNames () const |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| IrcUser * | user (const QModelIndex &index) const |
Protected Member Functions | |
| virtual bool | lessThan (IrcUser *one, IrcUser *another, Irc::SortMethod method) const |
Properties | |
| IrcChannel | channel |
| int | count |
| Irc::DataRole | displayRole |
| bool | empty |
| QStringList | names |
| Irc::SortMethod | sortMethod |
| Qt::SortOrder | sortOrder |
| QStringList | titles |
| QList< IrcUser * > | users |
In order to keep track of channel users, create an instance of IrcUserModel. It will notify via signals when users are added and/or removed. IrcUserModel can be used directly as a data model for Qt's item views - both in C++ and QML.
|
explicit |
Constructs a new model with parent.
|
virtual |
Destructs the model.
|
signal |
This signal is emitted just before a user is added to the list of users.
|
signal |
This signal is emitted just before a user is removed from the list of users.
|
signal |
This signal is emitted when a user is added to the list of users.
|
slot |
Clears the model.
| bool IrcUserModel::contains | ( | const QString & | name | ) | const |
Returns true if the model contains name.
| QVariant IrcUserModel::data | ( | const QModelIndex & | index, |
| int | role = Qt::DisplayRole |
||
| ) | const |
Returns the data for specified role referred to by the index.
Returns the user object for name or 0 if not found.
| IrcUser * IrcUserModel::get | ( | int | index | ) | const |
Returns the user object at index.
| QModelIndex IrcUserModel::index | ( | IrcUser * | user | ) | const |
Returns the model index for user.
|
virtual |
Returns the index of the item in the model specified by the given row, column and parent index.
Reimplemented from QAbstractListModel.
| int IrcUserModel::indexOf | ( | IrcUser * | user | ) | const |
Returns the index of the specified user, or -1 if the model does not contain the user.
|
protectedvirtual |
Returns true if one buffer is "less than" another, otherwise returns false.
The default implementation sorts according to the specified sort method. Reimplement this function in order to customize the sort order.
|
signal |
This signal is emitted when a user is removed from the list of users.
|
virtual |
The following role names are provided by default:
| Role | Name | Type | Example |
|---|---|---|---|
| Qt::DisplayRole | "display" | 1) | - |
| Irc::UserRole | "user" | IrcUser* | <object> |
| Irc::NameRole | "name" | QString | "jpnurmi" |
| Irc::PrefixRole | "prefix" | QString | "@" |
| Irc::ModeRole | "mode" | QString | "o" |
| Irc::TitleRole | "title" | QString | "@jpnurmi" |
1) The type depends on displayRole.
Reimplemented from QAbstractItemModel.
| int IrcUserModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Returns the number of users on the channel.
|
slot |
Sorts the model using the given order.
|
slot |
Sorts the model using the given method and order.
| IrcUser * IrcUserModel::user | ( | const QModelIndex & | index | ) | const |
Returns the user for model index.
|
readwrite |
This property holds the channel.
|
read |
This property holds the number of users on the channel.
|
readwrite |
This property holds the display role.
The specified data role is returned for Qt::DisplayRole.
The default value is Irc::TitleRole.
|
read |
This property holds the whether the model is empty.
|
read |
This property holds the list of names in alphabetical order.
|
readwrite |
This property holds the model sort method.
The default value is Irc::SortByHand.
| Method | Description | Example |
|---|---|---|
| Irc::SortByHand | Users are not sorted automatically, but only by calling sort(). | - |
| Irc::SortByName | Users are sorted alphabetically, ignoring any mode prefix. | "bot", "@ChanServ", "jpnurmi", "+qtassistant" |
| Irc::SortByTitle | Users are sorted alphabetically, and special users (operators, voiced users) before normal users. | "@ChanServ", "+qtassistant", "bot", "jpnurmi" |
| Irc::SortByActivity | Users are sorted based on their activity, last active and mentioned (1) users first. | - |
1) For performance reasons, IrcUserModel does not scan the whole channel messages to find out if a channel user was mentioned. IrcUserModel merely checks if channel messages begin with the name of a user in the model.
|
readwrite |
This property holds the model sort order.
The default value is Qt::AscendingOrder.
|
read |
This property holds the list of titles.
1.8.9.1