1 | /* |
2 | kopetegroup.h - Kopete (Meta)Contact Group |
3 | |
4 | Copyright (c) 2002-2005 by Olivier Goffart <ogoffart@kde.org> |
5 | Copyright (c) 2003 by Martijn Klingens <klingens@kde.org> |
6 | |
7 | Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org> |
8 | |
9 | ************************************************************************* |
10 | * * |
11 | * This library is free software; you can redistribute it and/or * |
12 | * modify it under the terms of the GNU Lesser General Public * |
13 | * License as published by the Free Software Foundation; either * |
14 | * version 2 of the License, or (at your option) any later version. * |
15 | * * |
16 | ************************************************************************* |
17 | */ |
18 | |
19 | #ifndef KOPETEGROUP_H |
20 | #define KOPETEGROUP_H |
21 | |
22 | #include <QtCore/QList> |
23 | |
24 | #include "kopetecontactlistelement.h" |
25 | |
26 | #include "kopete_export.h" |
27 | |
28 | |
29 | namespace Kopete { |
30 | |
31 | |
32 | class MetaContact; |
33 | class Message; |
34 | |
35 | /** |
36 | * Class which represents the Group. |
37 | * |
38 | * A Group is a ConstacListElement which means plugin can save data. |
39 | * |
40 | * some static group are availavle from this class: topLevel and temporary |
41 | * |
42 | * @author Olivier Goffart <ogoffart@kde.org> |
43 | */ |
44 | class KOPETE_EXPORT Group : public ContactListElement |
45 | { |
46 | Q_PROPERTY( QString displayName READ displayName WRITE setDisplayName ) |
47 | Q_PROPERTY( uint groupId READ groupId ) |
48 | Q_PROPERTY( bool expanded READ isExpanded WRITE setExpanded ) |
49 | |
50 | Q_OBJECT |
51 | |
52 | public: |
53 | typedef QList<Group*> List; |
54 | |
55 | /** Kinds of groups. */ |
56 | enum GroupType { Normal=0, Temporary, TopLevel, Offline }; |
57 | |
58 | /** |
59 | * \brief Create an empty group |
60 | * |
61 | * Note that the constructor will not add the group automatically to the contact list. |
62 | * Use @ref ContactList::addGroup() to add it |
63 | */ |
64 | Group(); |
65 | |
66 | /** |
67 | * \brief Create a group of the specified type |
68 | * |
69 | * Overloaded constructor to create a group with a display name and Normal type. |
70 | */ |
71 | explicit Group( const QString &displayName ); |
72 | |
73 | ~Group(); |
74 | |
75 | /** |
76 | * \brief Return the group's display name |
77 | * |
78 | * \return the display name of the group |
79 | */ |
80 | QString displayName() const; |
81 | |
82 | /** |
83 | * \brief Rename the group |
84 | */ |
85 | void setDisplayName( const QString &newName ); |
86 | |
87 | /** |
88 | * \return the group type |
89 | */ |
90 | GroupType type() const; |
91 | |
92 | /** |
93 | * \return the unique id for this group |
94 | */ |
95 | uint groupId() const; |
96 | |
97 | /** |
98 | * @brief child metacontact |
99 | * This function is not very efficient - it searches through all the metacontacts in the contact list |
100 | * \return the members of this group |
101 | */ |
102 | QList<MetaContact *> members() const; |
103 | |
104 | /** |
105 | * \brief Set if the group is expanded. |
106 | */ |
107 | void setExpanded( bool expanded ); |
108 | |
109 | /** |
110 | * |
111 | * \return true if the group is expanded. |
112 | * \return false otherwise |
113 | */ |
114 | bool isExpanded() const; |
115 | |
116 | /** |
117 | * \return a Group pointer to the toplevel group |
118 | */ |
119 | static Group *topLevel(); |
120 | |
121 | /** |
122 | * \return a Group pointer to the temporary group |
123 | */ |
124 | static Group *temporary(); |
125 | |
126 | /** |
127 | * \return a Group pointer to the offline group |
128 | */ |
129 | static Group *offline(); |
130 | |
131 | /** |
132 | * @internal |
133 | */ |
134 | void setGroupId( uint groupId ); |
135 | |
136 | /** |
137 | * @internal |
138 | */ |
139 | uint uniqueGroupId() const; |
140 | /** |
141 | * @internal |
142 | */ |
143 | void setUniqueGroupId( uint uniqueGroupId ); |
144 | |
145 | public slots: |
146 | /** |
147 | * Send a message to all contacts in the group |
148 | */ |
149 | void sendMessage(); |
150 | |
151 | |
152 | signals: |
153 | /** |
154 | * \brief Emitted when the group has been renamed |
155 | */ |
156 | void displayNameChanged( Kopete::Group *group , const QString &oldName ); |
157 | |
158 | |
159 | private slots: |
160 | void sendMessage( Kopete::Message& ); |
161 | |
162 | private: |
163 | /** |
164 | * \brief Create a group of the specified type |
165 | */ |
166 | Group( const QString &displayName, GroupType type ); |
167 | |
168 | static Group *s_topLevel; |
169 | static Group *s_temporary; |
170 | static Group *s_offline; |
171 | |
172 | class Private; |
173 | Private * const d; |
174 | |
175 | /** |
176 | * @internal used to get reachabe contact to send message to thom. |
177 | */ |
178 | QList<MetaContact *> onlineMembers() const; |
179 | }; |
180 | |
181 | } //END namespace Kopete |
182 | |
183 | #endif |
184 | |
185 | |
186 | |