6 Copyright (c) 2007 by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
7 Copyright (c) 2004 by Stefan Gehn <metz AT gehn.net>
8 Copyright (c) 2006 by Michaël Larouche <larouche@kde.org>
10 Kopete (c) 2004-2007 by the Kopete developers <kopete-devel@kde.org>
12 *************************************************************************
14 * This library is free software; you can redistribute it and/or *
15 * modify it under the terms of the GNU Lesser General Public *
16 * License as published by the Free Software Foundation; either *
17 * version 2 of the License, or (at your option) any later version. *
19 *************************************************************************
22 #ifndef _KOPETEPROPERTY_H_
23 #define _KOPETEPROPERTY_H_
25 #include <QtCore/QVariant>
26 #include <QtCore/QFlags>
28 #include "kopete_export.h"
34 * @author Stefan Gehn <metz AT gehn.net>
35 * @author Michaël Larouche <larouche@kde.org>
37 * The template class for registering properties in Kopete
38 * You need to use this if you want to set properties for a
41 class KOPETE_EXPORT PropertyTmpl
47 PersistentProperty
= 0x1,
48 RichTextProperty
= 0x2,
51 Q_DECLARE_FLAGS(PropertyOptions
, PropertyOption
)
54 * Constructor only used for empty PropertyTmpl objects
56 * Note: Only useful for the null object
62 * @param key internal unique key for this template
63 * @param label a label to show for properties based on this template
64 * @param icon name of the icon to show for properties based on this template
65 * @param options set the options for that property. See PropertyOption enum.
67 PropertyTmpl( const QString
&key
,
69 const QString
&icon
= QString(),
70 PropertyOptions options
= NoProperty
);
75 PropertyTmpl(const PropertyTmpl
&other
);
80 PropertyTmpl
&operator=(const PropertyTmpl
&other
);
82 bool operator==(const PropertyTmpl
&other
) const;
83 bool operator!=(const PropertyTmpl
&other
) const;
86 * Getter for the unique key. Properties based on this template will be
87 * stored with this key
89 const QString
&key() const;
92 * Getter for i18ned label
94 const QString
&label() const;
97 * Getter for icon to show aside or instead of @p label()
99 const QString
&icon() const;
102 * Return the options for that property.
104 PropertyOptions
options() const;
107 * Returns true if properties based on this template should
108 * be saved across Kopete sessions, false otherwise.
110 bool persistent() const;
113 * Returns true if properties based on this template are HTML formatted
115 bool isRichText() const;
118 * Returns true if properties based on this template are invisible to the user
120 bool isPrivate() const;
123 * An empty template, check for it using isNull()
125 static PropertyTmpl null
;
128 * Returns true if this object is an empty template
133 * A Map of QString and PropertyTmpl objects, based on QMap
135 typedef QMap
<QString
, PropertyTmpl
> Map
;
142 Q_DECLARE_OPERATORS_FOR_FLAGS(PropertyTmpl::PropertyOptions
)
145 * @author Stefan Gehn <metz AT gehn.net>
147 * A data container for whatever information Kopete or any of its
148 * plugins want to store for a Kopete::Contact
150 class KOPETE_EXPORT Property
154 * Constructor only used for empty Property objects
156 * Note: you cannot set a label or value later on!
161 * @param tmpl The contact property template this property is based on
162 * @param value The value this Property holds
164 Property(const PropertyTmpl
&tmpl
, const QVariant
&value
);
169 Property(const Property
&other
);
174 Property
&operator=(const Property
&other
);
177 * Getter for this properties template
179 const PropertyTmpl
&tmpl() const;
182 * Getter for this properties value
184 const QVariant
&value() const;
187 * The null, i.e. empty, Property
189 static Property null
;
192 * Returns true if this object is an empty Property (i.e. it holds no
193 * value), false otherwise.
198 * Returns true if this property is HTML formatted
200 bool isRichText() const;
203 * A map of key,Property items
205 typedef QMap
<QString
, Property
> Map
;
212 } // END namespace Kopete
214 #endif //_KOPETEPROPERTY_H_