1 /* 2 Copyright (C) 2008-2020 The Communi Project 3 4 You may use this file under the terms of BSD license as follows: 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 * Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright 11 notice, this list of conditions and the following disclaimer in the 12 documentation and/or other materials provided with the distribution. 13 * Neither the name of the copyright holder nor the names of its 14 contributors may be used to endorse or promote products derived 15 from this software without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef IRCBUFFERMODEL_P_H 30 #define IRCBUFFERMODEL_P_H 31 32 #include "ircbuffer.h" 33 #include "ircfilter.h" 34 #include "ircbuffermodel.h" 35 #include <qpointer.h> 36 37 IRC_BEGIN_NAMESPACE 38 39 class IrcBufferModelPrivate : public QObject, public IrcMessageFilter, public IrcCommandFilter 40 { 41 Q_OBJECT 42 Q_DECLARE_PUBLIC(IrcBufferModel) 43 Q_INTERFACES(IrcMessageFilter IrcCommandFilter) 44 45 public: 46 IrcBufferModelPrivate(); 47 48 bool messageFilter(IrcMessage* message) override; 49 bool commandFilter(IrcCommand* command) override; 50 51 IrcBuffer* createBufferHelper(const QString& title); 52 IrcChannel* createChannelHelper(const QString& title); 53 54 IrcBuffer* createBuffer(const QString& title); 55 void destroyBuffer(const QString& title, bool force = false); 56 57 void addBuffer(IrcBuffer* buffer, bool notify = true); 58 void insertBuffer(int index, IrcBuffer* buffer, bool notify = true); 59 void removeBuffer(IrcBuffer* buffer, bool notify = true); 60 bool renameBuffer(const QString& from, const QString& to); 61 void promoteBuffer(IrcBuffer* buffer); 62 63 void restoreBuffer(IrcBuffer* buffer); 64 QVariantMap saveBuffer(IrcBuffer* buffer) const; 65 66 bool processMessage(const QString& title, IrcMessage* message, bool create = false); 67 68 void _irc_connected(); 69 void _irc_initialized(); 70 void _irc_disconnected(); 71 void _irc_bufferDestroyed(IrcBuffer* buffer); 72 73 void _irc_restoreBuffers(); 74 void _irc_monitorStatus(); 75 get(IrcBufferModel * model)76 static IrcBufferModelPrivate* get(IrcBufferModel* model) 77 { 78 return model->d_func(); 79 } 80 81 IrcBufferModel* q_ptr = nullptr; 82 Irc::DataRole role = Irc::TitleRole; 83 QPointer<IrcConnection> connection; 84 QList<IrcBuffer*> bufferList; 85 QMap<QString, IrcBuffer*> bufferMap; 86 QHash<QString, QString> keys; 87 QVariantMap bufferStates; 88 QStringList channels; 89 Irc::SortMethod sortMethod = Irc::SortByHand; 90 Qt::SortOrder sortOrder = Qt::AscendingOrder; 91 IrcBuffer* bufferProto = nullptr; 92 IrcChannel* channelProto = nullptr; 93 bool persistent = false; 94 int joinDelay = 0; 95 bool monitorEnabled = false; 96 bool monitorPending = false; 97 }; 98 99 IRC_END_NAMESPACE 100 101 #endif // IRCBUFFERMODEL_P_H 102