Mudlet
0
Mudclient
|
#include <IrcBufferModel>
Public Slots | |
void | clear () |
void | receiveMessage (IrcMessage *message) |
void | sort (int column=0, Qt::SortOrder order=Qt::AscendingOrder) |
void | sort (Irc::SortMethod method, Qt::SortOrder order=Qt::AscendingOrder) |
Signals | |
void | countChanged (int count) |
void | emptyChanged (bool empty) |
void | added (IrcBuffer *buffer) |
void | removed (IrcBuffer *buffer) |
void | aboutToBeAdded (IrcBuffer *buffer) |
void | aboutToBeRemoved (IrcBuffer *buffer) |
void | persistentChanged (bool persistent) |
void | buffersChanged (const QList< IrcBuffer *> &buffers) |
void | channelsChanged (const QStringList &channels) |
void | connectionChanged (IrcConnection *connection) |
void | networkChanged (IrcNetwork *network) |
void | messageIgnored (IrcMessage *message) |
void | bufferPrototypeChanged (IrcBuffer *prototype) |
void | channelPrototypeChanged (IrcChannel *prototype) |
void | destroyed (IrcBufferModel *model) |
void | joinDelayChanged (int delay) |
void | monitorEnabledChanged (bool enabled) |
Public Member Functions | |
IrcBufferModel (QObject *parent=0) | |
virtual | ~IrcBufferModel () |
IrcConnection * | connection () const |
void | setConnection (IrcConnection *connection) |
IrcNetwork * | network () const |
int | count () const |
bool | isEmpty () const |
QStringList | channels () const |
QList< IrcBuffer * > | buffers () const |
Q_INVOKABLE IrcBuffer * | get (int index) const |
Q_INVOKABLE IrcBuffer * | find (const QString &title) const |
Q_INVOKABLE bool | contains (const QString &title) const |
Q_INVOKABLE int | indexOf (IrcBuffer *buffer) const |
Q_INVOKABLE IrcBuffer * | add (const QString &title) |
Q_INVOKABLE void | add (IrcBuffer *buffer) |
Q_INVOKABLE void | remove (const QString &title) |
Q_INVOKABLE void | remove (IrcBuffer *buffer) |
Qt::SortOrder | sortOrder () const |
void | setSortOrder (Qt::SortOrder order) |
Irc::SortMethod | sortMethod () const |
void | setSortMethod (Irc::SortMethod method) |
Irc::DataRole | displayRole () const |
void | setDisplayRole (Irc::DataRole role) |
bool | isPersistent () const |
void | setPersistent (bool persistent) |
QModelIndex | index (IrcBuffer *buffer) const |
IrcBuffer * | buffer (const QModelIndex &index) const |
QHash< int, QByteArray > | roleNames () const |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
QModelIndex | index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const |
IrcBuffer * | bufferPrototype () const |
void | setBufferPrototype (IrcBuffer *prototype) |
IrcChannel * | channelPrototype () const |
void | setChannelPrototype (IrcChannel *prototype) |
int | joinDelay () const |
void | setJoinDelay (int delay) |
bool | isMonitorEnabled () const |
void | setMonitorEnabled (bool enabled) |
Q_INVOKABLE QByteArray | saveState (int version=0) const |
Q_INVOKABLE bool | restoreState (const QByteArray &state, int version=0) |
Protected Slots | |
virtual IrcBuffer * | createBuffer (const QString &title) |
virtual IrcChannel * | createChannel (const QString &title) |
Protected Member Functions | |
virtual bool | lessThan (IrcBuffer *one, IrcBuffer *another, Irc::SortMethod method) const |
Properties | |
int | count |
bool | empty |
Qt::SortOrder | sortOrder |
Irc::SortMethod | sortMethod |
QStringList | channels |
Irc::DataRole | displayRole |
bool | persistent |
QList< IrcBuffer * > | buffers |
IrcConnection | connection |
IrcNetwork | network |
IrcBuffer | bufferPrototype |
IrcChannel | channelPrototype |
int | joinDelay |
bool | monitorEnabled |
Private Member Functions | |
Q_PRIVATE_SLOT (d_func(), void _irc_connected()) Q_PRIVATE_SLOT(d_func() | |
void | _irc_initialized ()) Q_PRIVATE_SLOT(d_func() |
void void | _irc_disconnected ()) Q_PRIVATE_SLOT(d_func() |
void void void | _irc_bufferDestroyed (IrcBuffer *)) Q_PRIVATE_SLOT(d_func() |
void void void void | _irc_restoreBuffers ()) Q_PRIVATE_SLOT(d_func() |
Private Attributes | |
QScopedPointer< IrcBufferModelPrivate > | d_ptr |
Friends | |
class | IrcBufferLessThan |
class | IrcBufferGreaterThan |
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.
Definition at line 47 of file ircbuffermodel.h.
|
explicit |
Constructs a new model with parent.
Definition at line 580 of file ircbuffermodel.cpp.
References setBufferPrototype(), setChannelPrototype(), and setConnection().
|
virtual |
Destructs the model.
Definition at line 593 of file ircbuffermodel.cpp.
References buffer(), connection(), and destroyed().
IrcConnection* IrcBufferModel::connection | ( | ) | const |
void IrcBufferModel::setConnection | ( | IrcConnection * | connection | ) |
Definition at line 621 of file ircbuffermodel.cpp.
References _irc_disconnected(), _irc_initialized(), connection(), connectionChanged(), count(), IrcConnection::installMessageFilter(), network(), networkChanged(), and rowCount().
Referenced by IrcBufferModel().
IrcNetwork* IrcBufferModel::network | ( | ) | const |
int IrcBufferModel::count | ( | ) | const |
bool IrcBufferModel::isEmpty | ( | ) | const |
Definition at line 678 of file ircbuffermodel.cpp.
References buffers(), and channels().
QStringList IrcBufferModel::channels | ( | ) | const |
QList<IrcBuffer*> IrcBufferModel::buffers | ( | ) | const |
Referenced by isEmpty(), restoreState(), and saveState().
Returns the buffer object for title or 0
if not found.
Definition at line 726 of file ircbuffermodel.cpp.
Referenced by dlgIRC::processCustomCommand().
Returns the index of the specified buffer, or -1
if the model does not contain the buffer.
Definition at line 745 of file ircbuffermodel.cpp.
Adds a buffer with title to the model and returns it.
Definition at line 754 of file ircbuffermodel.cpp.
Referenced by dlgIRC::setupBuffers(), and dlgIRC::slot_onUserActivated().
void IrcBufferModel::add | ( | IrcBuffer * | buffer | ) |
void IrcBufferModel::remove | ( | const QString & | title | ) |
Removes and destroys a buffer with title from the model.
Definition at line 772 of file ircbuffermodel.cpp.
Referenced by dlgIRC::ircRestart().
void IrcBufferModel::remove | ( | IrcBuffer * | buffer | ) |
Removes and destroys a buffer from the model.
Definition at line 781 of file ircbuffermodel.cpp.
References buffer(), and displayRole().
Qt::SortOrder IrcBufferModel::sortOrder | ( | ) | const |
void IrcBufferModel::setSortOrder | ( | Qt::SortOrder | order | ) |
Definition at line 881 of file ircbuffermodel.cpp.
References sort(), Irc::SortByHand, and sortMethod().
Irc::SortMethod IrcBufferModel::sortMethod | ( | ) | const |
void IrcBufferModel::setSortMethod | ( | Irc::SortMethod | method | ) |
Definition at line 917 of file ircbuffermodel.cpp.
References sort(), and Irc::SortByHand.
Irc::DataRole IrcBufferModel::displayRole | ( | ) | const |
void IrcBufferModel::setDisplayRole | ( | Irc::DataRole | role | ) |
Definition at line 803 of file ircbuffermodel.cpp.
bool IrcBufferModel::isPersistent | ( | ) | const |
Definition at line 829 of file ircbuffermodel.cpp.
void IrcBufferModel::setPersistent | ( | bool | persistent | ) |
Definition at line 835 of file ircbuffermodel.cpp.
References persistent, and persistentChanged().
QModelIndex IrcBufferModel::index | ( | IrcBuffer * | buffer | ) | const |
Returns the model index for buffer.
Definition at line 847 of file ircbuffermodel.cpp.
Referenced by dlgIRC::processCustomCommand(), dlgIRC::slot_onBufferAdded(), dlgIRC::slot_onUserActivated(), and sort().
IrcBuffer * IrcBufferModel::buffer | ( | const QModelIndex & | index | ) | const |
Returns the buffer for model index.
Definition at line 856 of file ircbuffermodel.cpp.
References sortOrder().
Referenced by clear(), data(), remove(), saveState(), sort(), and ~IrcBufferModel().
QHash< int, QByteArray > IrcBufferModel::roleNames | ( | ) | const |
The following role names are provided by default:
Role | Name | Type | Example |
---|---|---|---|
Qt::DisplayRole | "display" | 1) | - |
Irc::BufferRole | "buffer" | IrcBuffer* | <object> |
Irc::ChannelRole | "channel" | IrcChannel* | <object> |
Irc::NameRole | "name" | QString | "communi" |
Irc::PrefixRole | "prefix" | QString | "#" |
Irc::TitleRole | "title" | QString | "#communi" |
1) The type depends on displayRole.
Definition at line 1112 of file ircbuffermodel.cpp.
References Irc::BufferRole, Irc::ChannelRole, Irc::NameRole, Irc::PrefixRole, and Irc::TitleRole.
int IrcBufferModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Returns the number of buffers.
Definition at line 1127 of file ircbuffermodel.cpp.
Referenced by setConnection().
QVariant IrcBufferModel::data | ( | const QModelIndex & | index, |
int | role = Qt::DisplayRole |
||
) | const |
Returns the data for specified role and user referred to by by the index.
Definition at line 1139 of file ircbuffermodel.cpp.
References buffer(), Irc::BufferRole, Irc::ChannelRole, IrcBuffer::name, Irc::NameRole, IrcBuffer::prefix, Irc::PrefixRole, IrcBuffer::title, Irc::TitleRole, and IrcBuffer::toChannel().
QModelIndex IrcBufferModel::index | ( | int | row, |
int | column = 0 , |
||
const QModelIndex & | parent = QModelIndex() |
||
) | const |
Returns the index of the item in the model specified by the given row, column and parent index.
Definition at line 1169 of file ircbuffermodel.cpp.
References bufferPrototype().
IrcBuffer* IrcBufferModel::bufferPrototype | ( | ) | const |
void IrcBufferModel::setBufferPrototype | ( | IrcBuffer * | prototype | ) |
Definition at line 1195 of file ircbuffermodel.cpp.
References bufferPrototypeChanged(), and channelPrototype().
Referenced by IrcBufferModel().
IrcChannel* IrcBufferModel::channelPrototype | ( | ) | const |
void IrcBufferModel::setChannelPrototype | ( | IrcChannel * | prototype | ) |
Definition at line 1223 of file ircbuffermodel.cpp.
References channelPrototypeChanged(), and joinDelay().
Referenced by IrcBufferModel().
int IrcBufferModel::joinDelay | ( | ) | const |
void IrcBufferModel::setJoinDelay | ( | int | delay | ) |
Definition at line 1256 of file ircbuffermodel.cpp.
References joinDelayChanged().
bool IrcBufferModel::isMonitorEnabled | ( | ) | const |
Definition at line 1282 of file ircbuffermodel.cpp.
void IrcBufferModel::setMonitorEnabled | ( | bool | enabled | ) |
Definition at line 1288 of file ircbuffermodel.cpp.
References monitorEnabledChanged().
QByteArray IrcBufferModel::saveState | ( | int | version = 0 | ) | const |
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().
Definition at line 1304 of file ircbuffermodel.cpp.
References buffer(), buffers(), and IrcBuffer::title.
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.
Definition at line 1334 of file ircbuffermodel.cpp.
References _irc_restoreBuffers(), buffers(), and IRC_END_NAMESPACE.
|
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.
Definition at line 934 of file ircbuffermodel.cpp.
References buffer(), buffersChanged(), channelsChanged(), countChanged(), emptyChanged(), IrcBuffer::isChannel(), IrcBuffer::isPersistent(), and IrcBuffer::title.
|
slot |
|
slot |
Sorts the model using the given order.
Definition at line 978 of file ircbuffermodel.cpp.
Referenced by setSortMethod(), and setSortOrder().
|
slot |
Sorts the model using the given method and order.
Definition at line 990 of file ircbuffermodel.cpp.
References buffer(), index(), IrcBufferGreaterThan, IrcBufferLessThan, and Irc::SortByHand.
|
signal |
|
signal |
|
signal |
This signal is emitted when a buffer is added to the list of buffers.
Referenced by dlgIRC::setupBuffers().
|
signal |
This signal is emitted when a buffer is removed from the list of buffers.
Referenced by dlgIRC::setupBuffers().
|
signal |
This signal is emitted just before a buffer is added to the list of buffers.
|
signal |
This signal is emitted just before a buffer is removed from the list of buffers.
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
This signal is emitted when a message was ignored.
IrcBufferModel handles only buffer specific messages and delivers them to the appropriate IrcBuffer instances. When applications decide to handle IrcBuffer::messageReceived(), this signal makes it easy to implement handling for the rest, non-buffer specific messages.
Referenced by dlgIRC::setupBuffers().
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
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.
Definition at line 1027 of file ircbuffermodel.cpp.
|
protectedvirtualslot |
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.
Definition at line 1046 of file ircbuffermodel.cpp.
|
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.
Definition at line 1063 of file ircbuffermodel.cpp.
References IrcBufferPrivate::activity, IrcNetwork::channelTypes, IrcBufferPrivate::get(), IrcBuffer::isSticky(), IrcBuffer::name, IrcBuffer::network, IrcBuffer::prefix, Irc::SortByActivity, and Irc::SortByTitle.
Referenced by IrcBufferLessThan::operator()(), and IrcBufferGreaterThan::operator()().
|
private |
|
private |
|
private |
|
private |
|
private |
|
friend |
Definition at line 156 of file ircbuffermodel.h.
Referenced by sort().
|
friend |
Definition at line 157 of file ircbuffermodel.h.
Referenced by sort().
|
private |
Definition at line 158 of file ircbuffermodel.h.
|
read |
This property holds the number of buffers.
Definition at line 50 of file ircbuffermodel.h.
|
read |
This property holds the whether the model is empty.
Definition at line 51 of file ircbuffermodel.h.
|
readwrite |
This property holds the model sort order.
The default value is Qt::AscendingOrder
.
Definition at line 52 of file ircbuffermodel.h.
|
readwrite |
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. | - |
Definition at line 53 of file ircbuffermodel.h.
|
read |
This property holds the list of channel names.
Definition at line 54 of file ircbuffermodel.h.
|
readwrite |
This property holds the display role.
The specified data role is returned for Qt::DisplayRole.
The default value is Irc::TitleRole.
Definition at line 55 of file ircbuffermodel.h.
|
readwrite |
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.
Definition at line 56 of file ircbuffermodel.h.
Referenced by setPersistent().
|
read |
This property holds the list of buffers.
Definition at line 57 of file ircbuffermodel.h.
Referenced by dlgIRC::slot_onBufferAdded(), and dlgIRC::slot_onUserActivated().
|
readwrite |
This property holds the connection.
Definition at line 58 of file ircbuffermodel.h.
|
read |
This property holds the network.
Definition at line 59 of file ircbuffermodel.h.
Referenced by IrcChannelPrivate::init(), and IrcChannelPrivate::setUserMode().
|
readwrite |
This property holds the buffer prototype.
The prototype is used by the default implementation of createBuffer().
Definition at line 60 of file ircbuffermodel.h.
|
readwrite |
This property holds the channel prototype.
The prototype is used by the default implementation of createChannel().
Definition at line 61 of file ircbuffermodel.h.
|
readwrite |
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.
Definition at line 62 of file ircbuffermodel.h.
|
readwrite |
This property holds whether automatic monitor is enabled.
The default value is false
.
Definition at line 63 of file ircbuffermodel.h.