Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / kopetestatusitems.h
blobe2a3fcc38400d4f85bc3ecf0c4ccfaad802a0d2c
1 /*
2 kopetestatusitems.h - Kopete Status Items
4 Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5 Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
8 * *
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU Lesser General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
13 * *
14 *************************************************************************
16 #ifndef KOPETESTATUSITEMS_H
17 #define KOPETESTATUSITEMS_H
19 #include <QtCore/QObject>
20 #include <QtCore/QList>
21 #include <QtCore/QString>
23 #include "kopete_export.h"
24 #include "kopeteonlinestatusmanager.h"
26 namespace Kopete {
28 namespace Status {
30 class StatusGroup;
32 /**
33 * StatusItem is a base class for all status items. The items store
34 * values that are needed to build status menu.
36 * The items are stored in StatusManager.
38 * IdentityManager is a singleton, you may uses it with @ref IdentityManager::self()
40 *@author Roman Jarosz <kedgedev@centrum.cz>
42 class KOPETE_EXPORT StatusItem : public QObject
44 Q_OBJECT
45 public:
46 /**
47 * StatusItem constructor
48 **/
49 StatusItem();
50 StatusItem( const QString& uid );
52 /**
53 * Sets category
54 **/
55 void setCategory( OnlineStatusManager::Categories category );
57 /**
58 * Returns category
59 **/
60 OnlineStatusManager::Categories category() const { return mCategory; }
62 /**
63 * Sets title
64 **/
65 void setTitle( const QString& title );
67 /**
68 * Returns title
69 **/
70 QString title() const { return mTitle; }
72 /**
73 * Returns unique identifier
74 **/
75 QString uid() const { return mUid; }
77 /**
78 * Returns true if StatusItem is group
79 **/
80 virtual bool isGroup() const = 0;
82 /**
83 * Returns number of childes
84 **/
85 virtual int childCount() const = 0;
87 /**
88 * Returns a StatusItem at given @p index or 0 if there is no item at given @p index
89 **/
90 virtual StatusItem *child( int /*index*/ ) const = 0;
92 /**
93 * Returns index of this Item in parent group
94 **/
95 int index() const;
97 /**
98 * Returns StatusGroup this Item belongs to
99 **/
100 StatusGroup *parentGroup() const;
103 * Creates a copy of StatusItem
105 * @note this copies also uid so it should only be used when we know
106 * that the original or copy object will be destroyed
108 virtual StatusItem* copy() const = 0;
110 Q_SIGNALS:
112 * This signal is emitted whenever the item's content changes
114 void changed();
116 private:
117 OnlineStatusManager::Categories mCategory;
118 QString mTitle;
119 QString mUid;
121 StatusGroup *mParentItem;
122 Q_DISABLE_COPY(StatusItem)
126 * StatusGroup represents a group that can contain other StatusItems
128 *@author Roman Jarosz <kedgedev@centrum.cz>
130 class KOPETE_EXPORT StatusGroup : public StatusItem
132 Q_OBJECT
133 public:
135 * StatusGroup constructor
137 StatusGroup();
138 StatusGroup( const QString& uid );
141 * Returns true if StatusItem is group
142 * @note for StatusGroup it always returns true;
144 virtual bool isGroup() const { return true; }
147 * Returns number of childes
149 virtual int childCount() const { return mChildItems.count(); }
152 * Returns a StatusItem at given @p index or 0 if there is no item at given @p index
154 virtual StatusItem *child( int index ) const { return mChildItems.value( index, 0 ); }
157 * Returns list of all childes
159 QList<StatusItem*> childList() const { return mChildItems; }
162 * Returns index for given StatusItem
164 int indexOf( StatusItem *child ) const { return mChildItems.indexOf( child ); }
167 * Inserts @p child at given @p index
169 void insertChild( int index, StatusItem *child );
172 * Inserts @p child at the end
174 void appendChild( Kopete::Status::StatusItem *child );
177 * Removes @p child
179 void removeChild( Kopete::Status::StatusItem *child );
182 * Creates a copy of this object
184 * @note this copies also uid so it should only be used when we know
185 * that the original or copy object will be destroyed
187 virtual StatusItem* copy() const;
188 Q_SIGNALS:
190 * This signal is emitted after new child was inserted is inserted at position @p index
192 void childInserted( int index, Kopete::Status::StatusItem *child );
195 * This signal is emitted after child was removed
197 void childRemoved( Kopete::Status::StatusItem *child );
199 private Q_SLOTS:
200 void childDestroyed( QObject *object );
202 private:
203 QList<StatusItem*> mChildItems;
207 * Status represents a status which has title, message and category.
208 * Values from this class are used to create status action with which user can change status.
210 *@author Roman Jarosz <kedgedev@centrum.cz>
212 class KOPETE_EXPORT Status : public StatusItem
214 Q_OBJECT
215 public:
217 * Status constructor
219 Status();
220 Status( const QString& uid );
223 * Returns true if the item is group
224 * @note for Status it always returns false;
226 virtual bool isGroup() const { return false; }
229 * Returns number of childes
230 * @note for Status it always returns 0;
232 virtual int childCount() const { return 0; }
235 * Returns the item at given @p index or 0 if there is no item at given @p index
236 * @note for Status it always returns 0;
238 virtual StatusItem *child( int ) const { return 0; }
241 * Set message
243 void setMessage( const QString& message );
246 * Returns message
248 QString message() const { return mMessage; }
251 * Creates a copy of this object
253 * @note this copies also uid so it should only be used when we know
254 * that the original or copy object will be destroyed
256 virtual StatusItem* copy() const;
258 private:
259 QString mMessage;
266 #endif