Keeps track of buffers.
More...
Inherits QAbstractListModel.
IrcBufferModel automatically keeps track of channel and query buffers and manages IrcBuffer instances for them. It will notify via signals when channel and query buffers are added and/or removed. IrcBufferModel can be used directly as a data model for Qt's item views - both in C++ and QML.
listView->setModel(model);
IrcBufferModel::IrcBufferModel |
( |
QObject * |
parent = 0 | ) |
|
|
explicit |
Constructs a new model with parent.
- Note
- If parent is an instance of IrcConnection, it will be automatically assigned to connection.
IrcBufferModel::~IrcBufferModel |
( |
| ) |
|
|
virtual |
void IrcBufferModel::aboutToBeAdded |
( |
IrcBuffer * |
buffer | ) |
|
|
signal |
This signal is emitted just before a buffer is added to the list of buffers.
void IrcBufferModel::aboutToBeRemoved |
( |
IrcBuffer * |
buffer | ) |
|
|
signal |
This signal is emitted just before a buffer is removed from the list of buffers.
Adds a buffer with title to the model and returns it.
void IrcBufferModel::add |
( |
IrcBuffer * |
buffer | ) |
|
Adds the buffer to the model.
void IrcBufferModel::added |
( |
IrcBuffer * |
buffer | ) |
|
|
signal |
This signal is emitted when a buffer is added to the list of buffers.
Returns the buffer for model index.
void IrcBufferModel::clear |
( |
| ) |
|
|
slot |
Clears the model.
All buffers except persistent buffers are removed and destroyed.
In order to remove a persistent buffer, either explicitly call remove() or delete the buffer.
bool IrcBufferModel::contains |
( |
const QString & |
title | ) |
const |
Returns true
if the model contains title.
Creates a buffer object with title.
IrcBufferModel will automatically call this factory method when a need for the buffer object occurs ie. a private message is received.
The default implementation creates an instance of the buffer prototype. Reimplement this function in order to alter the default behavior.
- See also
- bufferPrototype
Creates a channel object with title.
IrcBufferModel will automatically call this factory method when a need for the channel object occurs ie. a channel is being joined.
The default implementation creates an instance of the channel prototype. Reimplement this function in order to alter the default behavior.
- See also
- channelPrototype
Returns the data for specified role and user referred to by by the index.
Returns the buffer object for title or 0
if not found.
IrcBuffer * IrcBufferModel::get |
( |
int |
index | ) |
const |
Returns the buffer object at index.
Returns the model index for buffer.
Returns the index of the item in the model specified by the given row, column and parent index.
Reimplemented from QAbstractListModel.
int IrcBufferModel::indexOf |
( |
IrcBuffer * |
buffer | ) |
const |
Returns the index of the specified buffer, or -1
if the model does not contain the buffer.
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
void IrcBufferModel::messageIgnored |
( |
IrcMessage * |
message | ) |
|
|
signal |
void IrcBufferModel::receiveMessage |
( |
IrcMessage * |
message | ) |
|
|
slot |
Makes the model receive and handle message.
void IrcBufferModel::remove |
( |
const QString & |
title | ) |
|
Removes and destroys a buffer with title from the model.
void IrcBufferModel::remove |
( |
IrcBuffer * |
buffer | ) |
|
Removes and destroys a buffer from the model.
void IrcBufferModel::removed |
( |
IrcBuffer * |
buffer | ) |
|
|
signal |
This signal is emitted when a buffer is removed from the list of buffers.
bool IrcBufferModel::restoreState |
( |
const QByteArray & |
state, |
|
|
int |
version = 0 |
|
) |
| |
- Since
- 3.1
Restores the state of the model. The version number is compared with that stored in state. If they do not match, the model state is left unchanged, and this function returns false
; otherwise, the state is restored, and true
is returned.
- See also
- saveState()
Returns the number of buffers.
QByteArray IrcBufferModel::saveState |
( |
int |
version = 0 | ) |
const |
- Since
- 3.1
Saves the state of the model. The version number is stored as part of the state data.
To restore the saved state, pass the return value and version number to restoreState().
void IrcBufferModel::sort |
( |
int |
column = 0 , |
|
|
Qt::SortOrder |
order = Qt::AscendingOrder |
|
) |
| |
|
slot |
Sorts the model using the given order.
void IrcBufferModel::sort |
( |
Irc::SortMethod |
method, |
|
|
Qt::SortOrder |
order = Qt::AscendingOrder |
|
) |
| |
|
slot |
Sorts the model using the given method and order.
- See also
- lessThan()
This property holds the buffer prototype.
The prototype is used by the default implementation of createBuffer().
- Note
- The prototype must have an invokable constructor.
- Access functions:
-
This property holds the list of buffers.
- Access function:
-
- Notifier signal:
-
This property holds the channel prototype.
The prototype is used by the default implementation of createChannel().
- Note
- The prototype must have an invokable constructor.
- Access functions:
-
This property holds the list of channel names.
- Access function:
-
- Notifier signal:
-
This property holds the connection.
- Access functions:
-
- Warning
- Changing the connection on the fly is not supported.
int IrcBufferModel::count |
|
read |
This property holds the number of buffers.
- Access function:
-
- Notifier signal:
- void countChanged(int count)
This property holds the display role.
The specified data role is returned for Qt::DisplayRole.
The default value is Irc::TitleRole.
- Access functions:
-
bool IrcBufferModel::empty |
|
read |
- Since
- 3.1
This property holds the whether the model is empty.
- Access function:
-
- Notifier signal:
- void emptyChanged(bool empty)
int IrcBufferModel::joinDelay |
|
readwrite |
- Since
- 3.3
This property holds the join delay in seconds.
The default value is 0
- channels are joined immediately after getting connected. A negative value disables automatic joining of channels.
- Access function:
- int joinDelay() const
- void setJoinDelay(int delay)
- Notifier signal:
- void joinDelayChanged(int delay)
bool IrcBufferModel::monitorEnabled |
|
readwrite |
- Since
- 3.4
This property holds whether automatic monitor is enabled.
The default value is false
.
- Access function:
- bool isMonitorEnabled() const
- void setMonitorEnabled(bool enabled)
- Notifier signal:
- void monitorEnabledChanged(bool enabled)
- See also
- IRCv3 support
This property holds the network.
- Access functions:
-
bool IrcBufferModel::persistent |
|
readwrite |
- Since
- 3.1
This property holds whether the model is persistent.
The default value is false
.
A persistent model does not remove and destruct channel buffers automatically when leaving the corresponding channels. In order to remove buffers from a persistent model, either call IrcBufferModel::remove() or delete the buffer.
- Access functions:
- bool isPersistent() const
- void setPersistent(bool persistent)
- Notifier signal:
- void persistentChanged(bool persistent)
This property holds the model sort method.
The default value is Irc::SortByHand
.
Method | Description | Example |
Irc::SortByHand | Buffers are not sorted automatically, but only by calling sort(). | - |
Irc::SortByName | Buffers are sorted alphabetically, ignoring any channel prefix. | "bot", "#communi", "#freenode", "jpnurmi", "#qt" |
Irc::SortByTitle | Buffers are sorted alphabetically, and channels before queries. | "#communi", "#freenode", "#qt", "bot", "jpnurmi" |
Irc::SortByActivity | Buffers are sorted based on their messaging activity, last active buffers first. | - |
- Note
- Irc::SortByActivity support was added in version 3.4.
- Access functions:
-
- See also
- sort(), lessThan()
Qt::SortOrder IrcBufferModel::sortOrder |
|
readwrite |
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()