~touch-irc/touch-irc/trunk

4 by Joseph Mills
adding backend to the mix for build time
1
/*
2
* Copyright (C) 2008-2014 The Communi Project
3
*
4
* This library is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
12
* License for more details.
13
*/
14
15
#ifndef IRCBUFFERMODEL_P_H
16
#define IRCBUFFERMODEL_P_H
17
18
#include "ircbuffer.h"
19
#include "ircfilter.h"
20
#include "ircbuffermodel.h"
21
#include <qpointer.h>
22
23
IRC_BEGIN_NAMESPACE
24
25
class IrcBufferModelPrivate : public QObject, public IrcMessageFilter, public IrcCommandFilter
26
{
27
    Q_OBJECT
28
    Q_DECLARE_PUBLIC(IrcBufferModel)
29
    Q_INTERFACES(IrcMessageFilter IrcCommandFilter)
30
31
public:
32
    IrcBufferModelPrivate();
33
34
    bool messageFilter(IrcMessage* message);
35
    bool commandFilter(IrcCommand* command);
36
37
    IrcBuffer* createBufferHelper(const QString& title);
38
    IrcChannel* createChannelHelper(const QString& title);
39
40
    IrcBuffer* createBuffer(const QString& title);
41
    void destroyBuffer(const QString& title, bool force = false);
42
43
    void addBuffer(IrcBuffer* buffer, bool notify = true);
44
    void insertBuffer(int index, IrcBuffer* buffer, bool notify = true);
45
    void removeBuffer(IrcBuffer* buffer, bool notify = true);
46
    bool renameBuffer(const QString& from, const QString& to);
47
48
    bool processMessage(const QString& title, IrcMessage* message, bool create = false);
49
50
    void _irc_connected();
51
    void _irc_disconnected();
52
    void _irc_bufferDestroyed(IrcBuffer* buffer);
53
54
    static IrcBufferModelPrivate* get(IrcBufferModel* model)
55
    {
56
        return model->d_func();
57
    }
58
59
    IrcBufferModel* q_ptr;
60
    Irc::DataRole role;
61
    QPointer<IrcConnection> connection;
62
    QList<IrcBuffer*> bufferList;
63
    QMap<QString, IrcBuffer*> bufferMap;
64
    QHash<QString, QString> keys;
65
    QStringList channels;
66
    Irc::SortMethod sortMethod;
67
    Qt::SortOrder sortOrder;
68
    IrcBuffer* bufferProto;
69
    IrcChannel* channelProto;
70
};
71
72
IRC_END_NAMESPACE
73
74
#endif // IRCBUFFERMODEL_P_H