Keeps track of channel users.
More...
#include <IrcUserModel>
Inherits QAbstractListModel.
|
| void | clear () |
| |
| void | sort (int column=0, Qt::SortOrder order=Qt::AscendingOrder) override |
| |
| void | sort (Irc::SortMethod method, Qt::SortOrder order=Qt::AscendingOrder) |
| |
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.
{
nickCompleter->setModel(model);
userListView->setModel(model);
}
Keeps track of channel status.
Definition: ircchannel.h:41
Keeps track of channel users.
Definition: ircusermodel.h:46
void added(IrcUser *user)
IrcUserModel(QObject *parent=nullptr)
Definition: ircusermodel.cpp:282
void removed(IrcUser *user)
Keeps track of user status on a channel.
Definition: ircuser.h:43
◆ IrcUserModel()
| IrcUserModel::IrcUserModel |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
Constructs a new model with parent.
- Note
- If parent is an instance of IrcChannel, it will be automatically assigned to channel.
◆ ~IrcUserModel()
| IrcUserModel::~IrcUserModel |
( |
| ) |
|
|
override |
◆ aboutToBeAdded
| void IrcUserModel::aboutToBeAdded |
( |
IrcUser * |
user | ) |
|
|
signal |
This signal is emitted just before a user is added to the list of users.
◆ aboutToBeRemoved
| void IrcUserModel::aboutToBeRemoved |
( |
IrcUser * |
user | ) |
|
|
signal |
This signal is emitted just before a user is removed from the list of users.
◆ added
| void IrcUserModel::added |
( |
IrcUser * |
user | ) |
|
|
signal |
This signal is emitted when a user is added to the list of users.
◆ channel()
This property holds the channel.
- Access functions:
-
- Notifier signal:
-
◆ clear
| void IrcUserModel::clear |
( |
| ) |
|
|
slot |
◆ contains()
| bool IrcUserModel::contains |
( |
const QString & |
name | ) |
const |
Returns true if the model contains name.
◆ count()
| int IrcUserModel::count |
( |
| ) |
const |
This property holds the number of users on the channel.
- Access function:
-
- Notifier signal:
- void countChanged(int count)
◆ data()
| QVariant IrcUserModel::data |
( |
const QModelIndex & |
index, |
|
|
int |
role = Qt::DisplayRole |
|
) |
| const |
|
override |
◆ displayRole()
This property holds the display role.
The specified data role is returned for Qt::DisplayRole.
The default value is Irc::TitleRole.
- Access functions:
-
◆ find()
| IrcUser * IrcUserModel::find |
( |
const QString & |
name | ) |
const |
Returns the user object for name or 0 if not found.
◆ get()
| IrcUser * IrcUserModel::get |
( |
int |
index | ) |
const |
Returns the user object at index.
◆ index() [1/2]
| QModelIndex IrcUserModel::index |
( |
int |
row, |
|
|
int |
column = 0, |
|
|
const QModelIndex & |
parent = QModelIndex() |
|
) |
| const |
|
override |
Returns the index of the item in the model specified by the given row, column and parent index.
◆ index() [2/2]
| QModelIndex IrcUserModel::index |
( |
IrcUser * |
user | ) |
const |
Returns the model index for user.
◆ indexOf()
| int IrcUserModel::indexOf |
( |
IrcUser * |
user | ) |
const |
Returns the index of the specified user, or -1 if the model does not contain the user.
◆ lessThan()
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.
- See also
- sort(), sortMethod
◆ names()
| QStringList IrcUserModel::names |
( |
| ) |
const |
This property holds the list of names in alphabetical order.
- Access function:
- QStringList names() const
- Notifier signal:
- void namesChanged(const QStringList& names)
◆ removed
| void IrcUserModel::removed |
( |
IrcUser * |
user | ) |
|
|
signal |
This signal is emitted when a user is removed from the list of users.
◆ roleNames()
| QHash< int, QByteArray > IrcUserModel::roleNames |
( |
| ) |
const |
|
override |
The following role names are provided by default:
1) The type depends on displayRole.
◆ rowCount()
| int IrcUserModel::rowCount |
( |
const QModelIndex & |
parent = QModelIndex() | ) |
const |
|
override |
Returns the number of users on the channel.
◆ sort [1/2]
| void IrcUserModel::sort |
( |
int |
column = 0, |
|
|
Qt::SortOrder |
order = Qt::AscendingOrder |
|
) |
| |
|
overrideslot |
Sorts the model using the given order.
◆ sort [2/2]
| void IrcUserModel::sort |
( |
Irc::SortMethod |
method, |
|
|
Qt::SortOrder |
order = Qt::AscendingOrder |
|
) |
| |
|
slot |
Sorts the model using the given method and order.
- See also
- lessThan()
◆ sortMethod()
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.
- Access functions:
-
- See also
- sort(), lessThan()
◆ sortOrder()
| Qt::SortOrder IrcUserModel::sortOrder |
( |
| ) |
const |
This property holds the model sort order.
The default value is Qt::AscendingOrder.
- Access functions:
- Qt::SortOrder sortOrder() const
- void setSortOrder(Qt::SortOrder order)
- See also
- sort(), lessThan()
◆ titles()
| QStringList IrcUserModel::titles |
( |
| ) |
const |
- Since
- 3.3
This property holds the list of titles.
- Access function:
- QStringList titles() const
- Notifier signal:
- void titlesChanged(const QStringList& titles)
◆ user()
| IrcUser * IrcUserModel::user |
( |
const QModelIndex & |
index | ) |
const |
Returns the user for model index.
◆ users()
| QList< IrcUser * > IrcUserModel::users |
( |
| ) |
const |
This property holds the list of users.
The order of users is kept as sent from the server.
- Access function:
-
- Notifier signal:
- void usersChanged(const QList<IrcUser*>& users)
◆ empty
- Since
- 3.1
This property holds the whether the model is empty.
- Access function:
-
- Notifier signal:
- void emptyChanged(bool empty)