summaryrefslogtreecommitdiffstats
path: root/src/libcommuni/include/IrcModel
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcommuni/include/IrcModel')
-rw-r--r--src/libcommuni/include/IrcModel/IrcBuffer1
-rw-r--r--src/libcommuni/include/IrcModel/IrcBufferModel1
-rw-r--r--src/libcommuni/include/IrcModel/IrcChannel1
-rw-r--r--src/libcommuni/include/IrcModel/IrcModel1
-rw-r--r--src/libcommuni/include/IrcModel/IrcUser1
-rw-r--r--src/libcommuni/include/IrcModel/IrcUserModel1
-rw-r--r--src/libcommuni/include/IrcModel/ircbuffer.h126
-rw-r--r--src/libcommuni/include/IrcModel/ircbuffer_p.h90
-rw-r--r--src/libcommuni/include/IrcModel/ircbuffermodel.h158
-rw-r--r--src/libcommuni/include/IrcModel/ircbuffermodel_p.h89
-rw-r--r--src/libcommuni/include/IrcModel/ircchannel.h81
-rw-r--r--src/libcommuni/include/IrcModel/ircchannel_p.h99
-rw-r--r--src/libcommuni/include/IrcModel/ircmodel.h46
-rw-r--r--src/libcommuni/include/IrcModel/ircuser.h89
-rw-r--r--src/libcommuni/include/IrcModel/ircuser_p.h63
-rw-r--r--src/libcommuni/include/IrcModel/ircusermodel.h119
-rw-r--r--src/libcommuni/include/IrcModel/ircusermodel_p.h69
17 files changed, 1035 insertions, 0 deletions
diff --git a/src/libcommuni/include/IrcModel/IrcBuffer b/src/libcommuni/include/IrcModel/IrcBuffer
new file mode 100644
index 0000000..4c88f75
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcBuffer
@@ -0,0 +1 @@
+#include <ircbuffer.h>
diff --git a/src/libcommuni/include/IrcModel/IrcBufferModel b/src/libcommuni/include/IrcModel/IrcBufferModel
new file mode 100644
index 0000000..149310e
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcBufferModel
@@ -0,0 +1 @@
+#include <ircbuffermodel.h>
diff --git a/src/libcommuni/include/IrcModel/IrcChannel b/src/libcommuni/include/IrcModel/IrcChannel
new file mode 100644
index 0000000..9392686
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcChannel
@@ -0,0 +1 @@
+#include <ircchannel.h>
diff --git a/src/libcommuni/include/IrcModel/IrcModel b/src/libcommuni/include/IrcModel/IrcModel
new file mode 100644
index 0000000..0ca546f
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcModel
@@ -0,0 +1 @@
+#include <ircmodel.h>
diff --git a/src/libcommuni/include/IrcModel/IrcUser b/src/libcommuni/include/IrcModel/IrcUser
new file mode 100644
index 0000000..7b7b69e
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcUser
@@ -0,0 +1 @@
+#include <ircuser.h>
diff --git a/src/libcommuni/include/IrcModel/IrcUserModel b/src/libcommuni/include/IrcModel/IrcUserModel
new file mode 100644
index 0000000..90a67b7
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/IrcUserModel
@@ -0,0 +1 @@
+#include <ircusermodel.h>
diff --git a/src/libcommuni/include/IrcModel/ircbuffer.h b/src/libcommuni/include/IrcModel/ircbuffer.h
new file mode 100644
index 0000000..69cc69f
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircbuffer.h
@@ -0,0 +1,126 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCBUFFER_H
+#define IRCBUFFER_H
+
+#include <Irc>
+#include <IrcGlobal>
+#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qscopedpointer.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcChannel;
+class IrcCommand;
+class IrcMessage;
+class IrcNetwork;
+class IrcConnection;
+class IrcBufferModel;
+class IrcBufferPrivate;
+
+class IRC_MODEL_EXPORT IrcBuffer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
+ Q_PROPERTY(IrcConnection* connection READ connection CONSTANT)
+ Q_PROPERTY(IrcNetwork* network READ network CONSTANT)
+ Q_PROPERTY(IrcBufferModel* model READ model CONSTANT)
+ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ Q_PROPERTY(bool channel READ isChannel CONSTANT)
+ Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged)
+ Q_PROPERTY(bool persistent READ isPersistent WRITE setPersistent NOTIFY persistentChanged)
+ Q_PROPERTY(QVariantMap userData READ userData WRITE setUserData NOTIFY userDataChanged)
+
+public:
+ Q_INVOKABLE explicit IrcBuffer(QObject* parent = 0);
+ virtual ~IrcBuffer();
+
+ QString title() const;
+ QString name() const;
+ QString prefix() const;
+
+ bool isChannel() const;
+ Q_INVOKABLE IrcChannel* toChannel();
+
+ IrcConnection* connection() const;
+ IrcNetwork* network() const;
+ IrcBufferModel* model() const;
+
+ virtual bool isActive() const;
+
+ bool isSticky() const;
+ void setSticky(bool sticky);
+
+ bool isPersistent() const;
+ void setPersistent(bool persistent);
+
+ QVariantMap userData() const;
+ void setUserData(const QVariantMap& data);
+
+ Q_INVOKABLE bool sendCommand(IrcCommand* command);
+
+public Q_SLOTS:
+ void setName(const QString& name);
+ void setPrefix(const QString& prefix);
+ void receiveMessage(IrcMessage* message);
+ virtual void close(const QString& reason = QString());
+
+Q_SIGNALS:
+ void titleChanged(const QString& title);
+ void nameChanged(const QString& name);
+ void prefixChanged(const QString& name);
+ void messageReceived(IrcMessage* message);
+ void destroyed(IrcBuffer* buffer);
+ void activeChanged(bool active);
+ void stickyChanged(bool sticky);
+ void persistentChanged(bool persistent);
+ void userDataChanged(const QVariantMap& data);
+
+protected:
+ IrcBuffer(IrcBufferPrivate& dd, QObject* parent);
+
+ QScopedPointer<IrcBufferPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(IrcBuffer)
+ Q_DISABLE_COPY(IrcBuffer)
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+IRC_MODEL_EXPORT QDebug operator<<(QDebug debug, const IrcBuffer* buffer);
+#endif // QT_NO_DEBUG_STREAM
+
+IRC_END_NAMESPACE
+
+Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcBuffer*))
+Q_DECLARE_METATYPE(QList<IRC_PREPEND_NAMESPACE(IrcBuffer*)>)
+
+#endif // IRCBUFFER_H
diff --git a/src/libcommuni/include/IrcModel/ircbuffer_p.h b/src/libcommuni/include/IrcModel/ircbuffer_p.h
new file mode 100644
index 0000000..cadc043
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircbuffer_p.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCBUFFER_P_H
+#define IRCBUFFER_P_H
+
+#include "ircbuffer.h"
+#include "ircmessage.h"
+#include <qstringlist.h>
+#include <qlist.h>
+#include <qmap.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcUser;
+class IrcUserModel;
+
+class IrcBufferPrivate
+{
+ Q_DECLARE_PUBLIC(IrcBuffer)
+
+public:
+ IrcBufferPrivate();
+ virtual ~IrcBufferPrivate();
+
+ virtual void init(const QString& title, IrcBufferModel* model);
+ virtual void connected();
+ virtual void disconnected();
+
+ void setName(const QString& name);
+ void setPrefix(const QString& prefix);
+ void setModel(IrcBufferModel* model);
+
+ bool processMessage(IrcMessage* message);
+
+ virtual bool processJoinMessage(IrcJoinMessage* message);
+ virtual bool processKickMessage(IrcKickMessage* message);
+ virtual bool processModeMessage(IrcModeMessage* message);
+ virtual bool processNamesMessage(IrcNamesMessage* message);
+ virtual bool processNickMessage(IrcNickMessage* message);
+ virtual bool processNoticeMessage(IrcNoticeMessage* message);
+ virtual bool processNumericMessage(IrcNumericMessage* message);
+ virtual bool processPartMessage(IrcPartMessage* message);
+ virtual bool processPrivateMessage(IrcPrivateMessage* message);
+ virtual bool processQuitMessage(IrcQuitMessage* message);
+ virtual bool processTopicMessage(IrcTopicMessage* message);
+ virtual bool processWhoReplyMessage(IrcWhoReplyMessage* message);
+
+ static IrcBufferPrivate* get(IrcBuffer* buffer)
+ {
+ return buffer->d_func();
+ }
+
+ IrcBuffer* q_ptr;
+ IrcBufferModel* model;
+ QString name;
+ QString prefix;
+ bool persistent;
+ bool sticky;
+ QVariantMap userData;
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCBUFFER_P_H
diff --git a/src/libcommuni/include/IrcModel/ircbuffermodel.h b/src/libcommuni/include/IrcModel/ircbuffermodel.h
new file mode 100644
index 0000000..ef23fc4
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircbuffermodel.h
@@ -0,0 +1,158 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCBUFFERMODEL_H
+#define IRCBUFFERMODEL_H
+
+#include <Irc>
+#include <IrcGlobal>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qabstractitemmodel.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcBuffer;
+class IrcChannel;
+class IrcMessage;
+class IrcNetwork;
+class IrcConnection;
+class IrcBufferModelPrivate;
+
+class IRC_MODEL_EXPORT IrcBufferModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
+ Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder)
+ Q_PROPERTY(Irc::SortMethod sortMethod READ sortMethod WRITE setSortMethod)
+ Q_PROPERTY(QStringList channels READ channels NOTIFY channelsChanged)
+ Q_PROPERTY(Irc::DataRole displayRole READ displayRole WRITE setDisplayRole)
+ Q_PROPERTY(bool persistent READ isPersistent WRITE setPersistent NOTIFY persistentChanged)
+ Q_PROPERTY(QList<IrcBuffer*> buffers READ buffers NOTIFY buffersChanged)
+ Q_PROPERTY(IrcConnection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
+ Q_PROPERTY(IrcNetwork* network READ network NOTIFY networkChanged)
+ Q_PROPERTY(IrcBuffer* bufferPrototype READ bufferPrototype WRITE setBufferPrototype NOTIFY bufferPrototypeChanged)
+ Q_PROPERTY(IrcChannel* channelPrototype READ channelPrototype WRITE setChannelPrototype NOTIFY channelPrototypeChanged)
+
+public:
+ explicit 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);
+
+ Q_INVOKABLE QByteArray saveState(int version = 0) const;
+ Q_INVOKABLE bool restoreState(const QByteArray& state, int version = 0);
+
+public Q_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);
+
+Q_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);
+
+protected Q_SLOTS:
+ virtual IrcBuffer* createBuffer(const QString& title);
+ virtual IrcChannel* createChannel(const QString& title);
+
+protected:
+ virtual bool lessThan(IrcBuffer* one, IrcBuffer* another, Irc::SortMethod method) const;
+
+private:
+ friend class IrcBufferLessThan;
+ friend class IrcBufferGreaterThan;
+ QScopedPointer<IrcBufferModelPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(IrcBufferModel)
+ Q_DISABLE_COPY(IrcBufferModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _irc_connected())
+ Q_PRIVATE_SLOT(d_func(), void _irc_disconnected())
+ Q_PRIVATE_SLOT(d_func(), void _irc_bufferDestroyed(IrcBuffer*))
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCBUFFERMODEL_H
diff --git a/src/libcommuni/include/IrcModel/ircbuffermodel_p.h b/src/libcommuni/include/IrcModel/ircbuffermodel_p.h
new file mode 100644
index 0000000..c7446b0
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircbuffermodel_p.h
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCBUFFERMODEL_P_H
+#define IRCBUFFERMODEL_P_H
+
+#include "ircbuffer.h"
+#include "ircfilter.h"
+#include "ircbuffermodel.h"
+#include <qpointer.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcBufferModelPrivate : public QObject, public IrcMessageFilter, public IrcCommandFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(IrcBufferModel)
+ Q_INTERFACES(IrcMessageFilter IrcCommandFilter)
+
+public:
+ IrcBufferModelPrivate();
+
+ bool messageFilter(IrcMessage* message);
+ bool commandFilter(IrcCommand* command);
+
+ IrcBuffer* createBufferHelper(const QString& title);
+ IrcChannel* createChannelHelper(const QString& title);
+
+ IrcBuffer* createBuffer(const QString& title);
+ void destroyBuffer(const QString& title, bool force = false);
+
+ void addBuffer(IrcBuffer* buffer, bool notify = true);
+ void insertBuffer(int index, IrcBuffer* buffer, bool notify = true);
+ void removeBuffer(IrcBuffer* buffer, bool notify = true);
+ bool renameBuffer(const QString& from, const QString& to);
+
+ bool processMessage(const QString& title, IrcMessage* message, bool create = false);
+
+ void _irc_connected();
+ void _irc_disconnected();
+ void _irc_bufferDestroyed(IrcBuffer* buffer);
+
+ static IrcBufferModelPrivate* get(IrcBufferModel* model)
+ {
+ return model->d_func();
+ }
+
+ IrcBufferModel* q_ptr;
+ Irc::DataRole role;
+ QPointer<IrcConnection> connection;
+ QList<IrcBuffer*> bufferList;
+ QMap<QString, IrcBuffer*> bufferMap;
+ QHash<QString, QString> keys;
+ QStringList channels;
+ Irc::SortMethod sortMethod;
+ Qt::SortOrder sortOrder;
+ IrcBuffer* bufferProto;
+ IrcChannel* channelProto;
+ bool persistent;
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCBUFFERMODEL_P_H
diff --git a/src/libcommuni/include/IrcModel/ircchannel.h b/src/libcommuni/include/IrcModel/ircchannel.h
new file mode 100644
index 0000000..e16de90
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircchannel.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCCHANNEL_H
+#define IRCCHANNEL_H
+
+#include <IrcGlobal>
+#include <IrcBuffer>
+#include <QtCore/qmetatype.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcChannelPrivate;
+
+class IRC_MODEL_EXPORT IrcChannel : public IrcBuffer
+{
+ Q_OBJECT
+ Q_PROPERTY(QString key READ key NOTIFY keyChanged)
+ Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
+ Q_PROPERTY(QString topic READ topic NOTIFY topicChanged)
+
+public:
+ Q_INVOKABLE explicit IrcChannel(QObject* parent = 0);
+ virtual ~IrcChannel();
+
+ QString key() const;
+ QString mode() const;
+ QString topic() const;
+
+ virtual bool isActive() const;
+
+public Q_SLOTS:
+ void join(const QString& key = QString());
+ void part(const QString& reason = QString());
+ void close(const QString& reason = QString());
+
+Q_SIGNALS:
+ void keyChanged(const QString& key);
+ void modeChanged(const QString& mode);
+ void topicChanged(const QString& topic);
+ void destroyed(IrcChannel* channel);
+private:
+ Q_DECLARE_PRIVATE(IrcChannel)
+ Q_DISABLE_COPY(IrcChannel)
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+IRC_MODEL_EXPORT QDebug operator<<(QDebug debug, const IrcChannel* channel);
+#endif // QT_NO_DEBUG_STREAM
+
+IRC_END_NAMESPACE
+
+Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcChannel*))
+Q_DECLARE_METATYPE(QList<IRC_PREPEND_NAMESPACE(IrcChannel*)>)
+
+#endif // IRCCHANNEL
diff --git a/src/libcommuni/include/IrcModel/ircchannel_p.h b/src/libcommuni/include/IrcModel/ircchannel_p.h
new file mode 100644
index 0000000..9da375b
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircchannel_p.h
@@ -0,0 +1,99 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCCHANNEL_P_H
+#define IRCCHANNEL_P_H
+
+#include "ircchannel.h"
+#include "ircnetwork.h"
+#include "ircbuffer_p.h"
+#include <qstringlist.h>
+#include <qlist.h>
+#include <qmap.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcChannelPrivate : public IrcBufferPrivate
+{
+ Q_DECLARE_PUBLIC(IrcChannel)
+
+public:
+ IrcChannelPrivate();
+ virtual ~IrcChannelPrivate();
+
+ virtual void init(const QString& title, IrcBufferModel* model);
+ virtual void connected();
+ virtual void disconnected();
+
+ void setActive(bool active);
+
+ void changeModes(const QString& value, const QStringList& arguments);
+ void setModes(const QString& value, const QStringList& arguments);
+ void setTopic(const QString& value);
+ void setKey(const QString& value);
+
+ void addUser(const QString& user);
+ bool removeUser(const QString& user);
+ void setUsers(const QStringList& users);
+ bool renameUser(const QString& from, const QString& to);
+ void setUserMode(const QString& user, const QString& mode);
+ void promoteUser(const QString& user);
+ void setUserAway(const QString &name, const bool& away);
+ void setUserServOp(const QString &name, const bool& servOp);
+
+ virtual bool processJoinMessage(IrcJoinMessage* message);
+ virtual bool processKickMessage(IrcKickMessage* message);
+ virtual bool processModeMessage(IrcModeMessage* message);
+ virtual bool processNamesMessage(IrcNamesMessage* message);
+ virtual bool processNickMessage(IrcNickMessage* message);
+ virtual bool processNoticeMessage(IrcNoticeMessage* message);
+ virtual bool processNumericMessage(IrcNumericMessage* message);
+ virtual bool processPartMessage(IrcPartMessage* message);
+ virtual bool processPrivateMessage(IrcPrivateMessage* message);
+ virtual bool processQuitMessage(IrcQuitMessage* message);
+ virtual bool processTopicMessage(IrcTopicMessage* message);
+ virtual bool processWhoReplyMessage(IrcWhoReplyMessage* message);
+
+ static IrcChannelPrivate* get(IrcChannel* channel)
+ {
+ return channel->d_func();
+ }
+
+ QMap<QString, QString> modes;
+ QString topic;
+ bool active;
+ QStringList names;
+ QList<IrcUser*> userList;
+ QList<IrcUser*> activeUsers;
+ QMap<QString, IrcUser*> userMap;
+ QList<IrcUserModel*> userModels;
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCCHANNEL_P_H
diff --git a/src/libcommuni/include/IrcModel/ircmodel.h b/src/libcommuni/include/IrcModel/ircmodel.h
new file mode 100644
index 0000000..45ac4bd
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircmodel.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCMODEL_H
+#define IRCMODEL_H
+
+#include "ircbuffer.h"
+#include "ircbuffermodel.h"
+#include "ircchannel.h"
+#include "ircuser.h"
+#include "ircusermodel.h"
+
+IRC_BEGIN_NAMESPACE
+
+namespace IrcModel {
+ void registerMetaTypes();
+}
+
+IRC_END_NAMESPACE
+
+#endif // IRCMODEL_H
diff --git a/src/libcommuni/include/IrcModel/ircuser.h b/src/libcommuni/include/IrcModel/ircuser.h
new file mode 100644
index 0000000..9e59a9f
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircuser.h
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCUSER_H
+#define IRCUSER_H
+
+#include <IrcGlobal>
+#include <QtCore/qobject.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qscopedpointer.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcChannel;
+class IrcUserPrivate;
+
+class IRC_MODEL_EXPORT IrcUser : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
+ Q_PROPERTY(QString prefix READ prefix NOTIFY prefixChanged)
+ Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
+ Q_PROPERTY(bool servOp READ isServOp NOTIFY servOpChanged)
+ Q_PROPERTY(bool away READ isAway NOTIFY awayChanged)
+ Q_PROPERTY(IrcChannel* channel READ channel CONSTANT)
+
+public:
+ explicit IrcUser(QObject* parent = 0);
+ virtual ~IrcUser();
+
+ QString title() const;
+ QString name() const;
+ QString prefix() const;
+ QString mode() const;
+ bool isServOp() const;
+ bool isAway() const;
+
+ IrcChannel* channel() const;
+
+Q_SIGNALS:
+ void titleChanged(const QString& title);
+ void nameChanged(const QString& name);
+ void prefixChanged(const QString& prefix);
+ void modeChanged(const QString& mode);
+ void servOpChanged(bool servOp);
+ void awayChanged(bool away);
+
+private:
+ QScopedPointer<IrcUserPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(IrcUser)
+ Q_DISABLE_COPY(IrcUser)
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+IRC_MODEL_EXPORT QDebug operator<<(QDebug debug, const IrcUser* user);
+#endif // QT_NO_DEBUG_STREAM
+
+IRC_END_NAMESPACE
+
+Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcUser*))
+Q_DECLARE_METATYPE(QList<IRC_PREPEND_NAMESPACE(IrcUser*)>)
+
+#endif // IRCUSER_H
diff --git a/src/libcommuni/include/IrcModel/ircuser_p.h b/src/libcommuni/include/IrcModel/ircuser_p.h
new file mode 100644
index 0000000..0e88e6b
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircuser_p.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCUSER_P_H
+#define IRCUSER_P_H
+
+#include "ircuser.h"
+
+IRC_BEGIN_NAMESPACE
+
+class IrcUserPrivate
+{
+ Q_DECLARE_PUBLIC(IrcUser)
+
+public:
+ void setName(const QString& n);
+ void setPrefix(const QString& p);
+ void setMode(const QString& m);
+ void setServOp(const bool& o);
+ void setAway(const bool& a);
+
+ static IrcUserPrivate* get(IrcUser* user)
+ {
+ return user->d_func();
+ }
+
+ IrcUser* q_ptr;
+ IrcChannel* channel;
+ QString name;
+ QString prefix;
+ QString mode;
+ bool servOp;
+ bool away;
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCUSER_P_H
diff --git a/src/libcommuni/include/IrcModel/ircusermodel.h b/src/libcommuni/include/IrcModel/ircusermodel.h
new file mode 100644
index 0000000..331af37
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircusermodel.h
@@ -0,0 +1,119 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCUSERMODEL_H
+#define IRCUSERMODEL_H
+
+#include <Irc>
+#include <IrcGlobal>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qabstractitemmodel.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcUser;
+class IrcChannel;
+class IrcMessage;
+class IrcUserModelPrivate;
+
+class IRC_MODEL_EXPORT IrcUserModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
+ Q_PROPERTY(QStringList names READ names NOTIFY namesChanged)
+ Q_PROPERTY(QList<IrcUser*> users READ users NOTIFY usersChanged)
+ Q_PROPERTY(Irc::DataRole displayRole READ displayRole WRITE setDisplayRole)
+ Q_PROPERTY(IrcChannel* channel READ channel WRITE setChannel NOTIFY channelChanged)
+ Q_PROPERTY(Irc::SortMethod sortMethod READ sortMethod WRITE setSortMethod)
+ Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder)
+
+public:
+ explicit IrcUserModel(QObject* parent = 0);
+ virtual ~IrcUserModel();
+
+ IrcChannel* channel() const;
+ void setChannel(IrcChannel* channel);
+
+ int count() const;
+ bool isEmpty() const;
+ QStringList names() const;
+ QList<IrcUser*> users() const;
+ Q_INVOKABLE IrcUser* get(int index) const;
+ Q_INVOKABLE IrcUser* find(const QString& name) const;
+ Q_INVOKABLE bool contains(const QString& name) const;
+ Q_INVOKABLE int indexOf(IrcUser* user) const;
+
+ Irc::DataRole displayRole() const;
+ void setDisplayRole(Irc::DataRole role);
+
+ Irc::SortMethod sortMethod() const;
+ void setSortMethod(Irc::SortMethod method);
+
+ Qt::SortOrder sortOrder() const;
+ void setSortOrder(Qt::SortOrder order);
+
+ QModelIndex index(IrcUser* user) const;
+ IrcUser* user(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;
+
+public Q_SLOTS:
+ void clear();
+ void sort(int column = 0, Qt::SortOrder order = Qt::AscendingOrder);
+ void sort(Irc::SortMethod method, Qt::SortOrder order = Qt::AscendingOrder);
+
+Q_SIGNALS:
+ void added(IrcUser* user);
+ void removed(IrcUser* user);
+ void aboutToBeAdded(IrcUser* user);
+ void aboutToBeRemoved(IrcUser* user);
+ void countChanged(int count);
+ void emptyChanged(bool empty);
+ void namesChanged(const QStringList& names);
+ void usersChanged(const QList<IrcUser*>& users);
+ void channelChanged(IrcChannel* channel);
+
+protected:
+ virtual bool lessThan(IrcUser* one, IrcUser* another, Irc::SortMethod method) const;
+
+private:
+ friend class IrcUserLessThan;
+ friend class IrcChannelPrivate;
+ friend class IrcUserGreaterThan;
+ QScopedPointer<IrcUserModelPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(IrcUserModel)
+ Q_DISABLE_COPY(IrcUserModel)
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCUSERMODEL_H
diff --git a/src/libcommuni/include/IrcModel/ircusermodel_p.h b/src/libcommuni/include/IrcModel/ircusermodel_p.h
new file mode 100644
index 0000000..45c00bb
--- /dev/null
+++ b/src/libcommuni/include/IrcModel/ircusermodel_p.h
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2008-2014 The Communi Project
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IRCUSERMODEL_P_H
+#define IRCUSERMODEL_P_H
+
+#include "ircuser.h"
+#include "ircchannel_p.h"
+#include "ircusermodel.h"
+#include <qpointer.h>
+
+IRC_BEGIN_NAMESPACE
+
+class IrcUserModelPrivate
+{
+ Q_DECLARE_PUBLIC(IrcUserModel)
+
+public:
+ IrcUserModelPrivate();
+
+ void addUser(IrcUser* user, bool notify = true);
+ void insertUser(int index, IrcUser* user, bool notify = true);
+ void removeUser(IrcUser* user, bool notify = true);
+ void setUsers(const QList<IrcUser*>& users, bool reset = true);
+ void renameUser(IrcUser* user);
+ void setUserMode(IrcUser* user);
+ void promoteUser(IrcUser* user);
+
+ static IrcUserModelPrivate* get(IrcUserModel* model)
+ {
+ return model->d_func();
+ }
+
+ IrcUserModel* q_ptr;
+ Irc::DataRole role;
+ QList<IrcUser*> userList;
+ QPointer<IrcChannel> channel;
+ Irc::SortMethod sortMethod;
+ Qt::SortOrder sortOrder;
+};
+
+IRC_END_NAMESPACE
+
+#endif // IRCUSERMODEL_P_H