summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/kopetegroup.h
blob: e832e955e3d364f35e43729519bb450d86f6b454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
    kopetegroup.h - Kopete (Meta)Contact Group

    Copyright (c) 2002-2004 by Olivier Goffart       <ogoffart @ kde.org>
    Copyright (c) 2003      by Martijn Klingens      <klingens@kde.org>

    Kopete    (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef KOPETEGROUP_H
#define KOPETEGROUP_H

#include "kopetenotifydataobject.h"
#include "kopetecontactlistelement.h"

#include "kopete_export.h"

#include <tqptrlist.h>

class QDomElement;


namespace Kopete {


class MetaContact;
class Message;

/**
 * Class which represents the Group.
 *
 * A Group is a ConstacListElement which means plugin can save datas.
 *
 * some static group are availavle from this class:  topLevel and temporary
 *
 * @author Olivier Goffart
 */
class KOPETE_EXPORT Group : public ContactListElement, public NotifyDataObject
{
	Q_PROPERTY( TQString displayName READ displayName WRITE setDisplayName )
	Q_PROPERTY( uint groupId READ groupId )
	Q_PROPERTY( bool expanded READ isExpanded WRITE setExpanded )

	Q_OBJECT

public:
	/** Kinds of groups. */
	enum GroupType { Normal=0, Temporary, TopLevel };

	/**
	 * \brief Create an empty group
	 *
	 * Note that the constructor will not add the group automatically to the contact list.
	 * Use @ref ContactList::addGroup() to add it
	 */
	Group();

	/**
	 * \brief Create a group of the specified type
	 *
	 * Overloaded constructor to create a group with a display name of the specified type.
	 */
	Group( const TQString &displayName, GroupType type = Normal );
	
	~Group();

	/**
	 * \brief Return the group's display name
	 *
	 * \return the display name of the group
	 */
	TQString displayName() const;

	/**
	 * \brief Rename the group
	 */
	void setDisplayName( const TQString &newName );

	/**
	 * \return the group type
	 */
	GroupType type() const;

	/**
	 * \brief Set the group type
	 */
	void setType( GroupType newType );

	/**
	 * \return the unique id for this group
	 */
	uint groupId() const;

	/**
	 * @brief child metacontact
	 * This function is not very efficient - it searches through all the metacontacts in the contact list
	 * \return the members of this group
	 */
	TQPtrList<MetaContact> members() const;

	/**
	 * \brief Set if the group is expanded.
	 *
	 * This is saved to the xml contactlist file
	 */
	void setExpanded( bool expanded );

	/**
	 *
	 * \return true if the group is expanded.
	 * \return false otherwise
	 */
	bool isExpanded() const;

	/**
	 * \return a Group pointer to the toplevel group
	 */
	static Group *topLevel();

	/**
	 * \return a Group pointer to the temporary group
	 */
	static Group *temporary();
	

	
	/**
	 * @internal
	 * Outputs the group data in XML
	 */
	const TQDomElement toXML();

	
	/**
	 * @internal
	 * Loads the group data from XML
	 */
	 bool fromXML( const TQDomElement &data );

	 
	 
	 	
public slots:
	/**
	 * Send a message to all contacts in the group
	 */
	void sendMessage();


signals:
	/**
	 * \brief Emitted when the group has been renamed
	 */
	void displayNameChanged( Kopete::Group *group , const TQString &oldName );

	
private slots:
	void sendMessage( Kopete::Message& );

private:
	static Group *s_topLevel;
	static Group *s_temporary;

	class Private;
	Private *d;
	
	
	/**
	 * @internal  used to get reachabe contact to send message to thom.
	 */
	TQPtrList<MetaContact> onlineMembers() const;
};

} //END namespace Kopete 

#endif