Communi  3.0.0
A cross-platform IRC framework written with Qt
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Macros Groups Pages
ircbuffer.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2008-2013 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 IRCBUFFER_H
16 #define IRCBUFFER_H
17 
18 #include <Irc>
19 #include <IrcGlobal>
20 #include <QtCore/qobject.h>
21 #include <QtCore/qmetatype.h>
22 #include <QtCore/qscopedpointer.h>
23 
24 IRC_BEGIN_NAMESPACE
25 
26 class IrcChannel;
27 class IrcCommand;
28 class IrcMessage;
29 class IrcNetwork;
30 class IrcConnection;
31 class IrcBufferModel;
32 class IrcBufferPrivate;
33 
34 class IRC_MODEL_EXPORT IrcBuffer : public QObject
35 {
36  Q_OBJECT
37  Q_PROPERTY(QString title READ title NOTIFY titleChanged)
38  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
39  Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
40  Q_PROPERTY(IrcConnection* connection READ connection CONSTANT)
41  Q_PROPERTY(IrcNetwork* network READ network CONSTANT)
42  Q_PROPERTY(IrcBufferModel* model READ model CONSTANT)
43  Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
44  Q_PROPERTY(bool channel READ isChannel CONSTANT)
45  Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged)
46  Q_PROPERTY(bool persistent READ isPersistent WRITE setPersistent NOTIFY persistentChanged)
47 
48 public:
49  Q_INVOKABLE explicit IrcBuffer(QObject* parent = 0);
50  virtual ~IrcBuffer();
51 
52  QString title() const;
53  QString name() const;
54  QString prefix() const;
55 
56  bool isChannel() const;
57  Q_INVOKABLE IrcChannel* toChannel();
58 
59  IrcConnection* connection() const;
60  IrcNetwork* network() const;
61  IrcBufferModel* model() const;
62 
63  virtual bool isActive() const;
64 
65  bool isSticky() const;
66  void setSticky(bool sticky);
67 
68  bool isPersistent() const;
69  void setPersistent(bool persistent);
70 
71  Q_INVOKABLE bool sendCommand(IrcCommand* command);
72 
73 public Q_SLOTS:
74  void setName(const QString& name);
75  void setPrefix(const QString& prefix);
76  void receiveMessage(IrcMessage* message);
77 
78 Q_SIGNALS:
79  void titleChanged(const QString& title);
80  void nameChanged(const QString& name);
81  void prefixChanged(const QString& name);
82  void messageReceived(IrcMessage* message);
83  void destroyed(IrcBuffer* buffer);
84  void activeChanged(bool active);
85  void stickyChanged(bool sticky);
86  void persistentChanged(bool persistent);
87 
88 protected:
89  IrcBuffer(IrcBufferPrivate& dd, QObject* parent);
90 
91  QScopedPointer<IrcBufferPrivate> d_ptr;
92  Q_DECLARE_PRIVATE(IrcBuffer)
93  Q_DISABLE_COPY(IrcBuffer)
94 };
95 
96 #ifndef QT_NO_DEBUG_STREAM
97 IRC_MODEL_EXPORT QDebug operator<<(QDebug debug, const IrcBuffer* buffer);
98 #endif // QT_NO_DEBUG_STREAM
99 
100 IRC_END_NAMESPACE
101 
102 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcBuffer*))
103 Q_DECLARE_METATYPE(QList<IRC_PREPEND_NAMESPACE(IrcBuffer*)>)
104 
105 #endif // IRCBUFFER_H
Provides the most common commands.
Definition: irccommand.h:29
Keeps track of channel status.
Definition: ircchannel.h:26
Keeps track of buffer status.
Definition: ircbuffer.h:34
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:32
The base class of all messages.
Definition: ircmessage.h:32
Keeps track of buffers.
Definition: ircbuffermodel.h:32
Provides network information and capability management.
Definition: ircnetwork.h:29