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 #include "kopeteproperty.h"
24 #include "kopeteglobal.h"
29 class PropertyTmpl::Private
35 PropertyOptions options
;
36 unsigned int refCount
;
39 PropertyTmpl
PropertyTmpl::null
;
42 PropertyTmpl::PropertyTmpl()
46 d
->options
= NoProperty
;
47 // Don't register empty template
50 PropertyTmpl::PropertyTmpl(const QString
&key
,
51 const QString
&label
, const QString
&icon
, PropertyOptions options
)
53 PropertyTmpl other
= Kopete::Global::Properties::self()->tmpl(key
);
56 // kDebug(14000) << "Creating new template for key = '" << key << "'";
64 Kopete::Global::Properties::self()->registerTemplate(key
, (*this));
68 // kDebug(14000) << "Using existing template for key = '" << key << "'";
74 PropertyTmpl::PropertyTmpl(const PropertyTmpl
&other
)
80 PropertyTmpl
&PropertyTmpl::operator=(
81 const PropertyTmpl
&other
)
85 // kDebug(14000) << "trying to assign this to itself!";
90 // kDebug(14000) << "trying to assign d to itself!";
96 if (!d
->key
.isEmpty()) // null property
97 Kopete::Global::Properties::self()->unregisterTemplate(d
->key
);
107 PropertyTmpl::~PropertyTmpl()
112 if (!d
->key
.isEmpty()) // null property
113 Kopete::Global::Properties::self()->unregisterTemplate(d
->key
);
118 bool PropertyTmpl::operator==(const PropertyTmpl
&other
) const
120 return (d
&& other
.d
&&
121 d
->key
== other
.d
->key
&&
122 d
->label
== other
.d
->label
&&
123 d
->icon
== other
.d
->key
&&
124 d
->options
== other
.d
->options
);
127 bool PropertyTmpl::operator!=(const PropertyTmpl
&other
) const
129 return (!d
|| !other
.d
||
130 d
->key
!= other
.d
->key
||
131 d
->label
!= other
.d
->label
||
132 d
->icon
!= other
.d
->key
||
133 d
->options
!= other
.d
->options
);
137 const QString
&PropertyTmpl::key() const
142 const QString
&PropertyTmpl::label() const
147 const QString
&PropertyTmpl::icon() const
152 PropertyTmpl::PropertyOptions
PropertyTmpl::options() const
157 bool PropertyTmpl::persistent() const
159 return d
->options
& PersistentProperty
;
162 bool PropertyTmpl::isRichText() const
164 return d
->options
& RichTextProperty
;
167 bool PropertyTmpl::isPrivate() const
169 return d
->options
& PrivateProperty
;
172 bool PropertyTmpl::isNull() const
174 return (!d
|| d
->key
.isNull());
178 // -----------------------------------------------------------------------------
181 Property
Property::null
;
183 class Property::Private
187 PropertyTmpl propertyTemplate
;
195 Property::Property(const PropertyTmpl
&tmpl
,
199 d
->propertyTemplate
= tmpl
;
203 Property::Property(const Property
& other
)
206 d
->propertyTemplate
= other
.d
->propertyTemplate
;
207 d
->value
= other
.d
->value
;
210 Property::~Property()
215 Property
& Property::operator=(const Property
& other
)
219 // kDebug(14000) << "trying to assign this to itself!";
223 d
->propertyTemplate
= other
.d
->propertyTemplate
;
224 d
->value
= other
.d
->value
;
229 const QVariant
&Property::value() const
234 const PropertyTmpl
&Property::tmpl() const
236 return d
->propertyTemplate
;
239 bool Property::isNull() const
241 return d
->value
.isNull();
244 bool Property::isRichText() const
246 return d
->propertyTemplate
.isRichText();
249 } // END namespace Kopete