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 *************************************************************************
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. *
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"
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
47 * StatusItem constructor
50 StatusItem( const QString
& uid
);
55 void setCategory( OnlineStatusManager::Categories category
);
60 OnlineStatusManager::Categories
category() const { return mCategory
; }
65 void setTitle( const QString
& title
);
70 QString
title() const { return mTitle
; }
73 * Returns unique identifier
75 QString
uid() const { return mUid
; }
78 * Returns true if StatusItem is group
80 virtual bool isGroup() const = 0;
83 * Returns number of childes
85 virtual int childCount() const = 0;
88 * Returns a StatusItem at given @p index or 0 if there is no item at given @p index
90 virtual StatusItem
*child( int /*index*/ ) const = 0;
93 * Returns index of this Item in parent group
98 * Returns StatusGroup this Item belongs to
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;
112 * This signal is emitted whenever the item's content changes
117 OnlineStatusManager::Categories mCategory
;
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
135 * StatusGroup constructor
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
);
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;
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
);
200 void childDestroyed( QObject
*object
);
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
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; }
243 void setMessage( const QString
& 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;