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
|
/* This file is part of the KDE project
Copyright (C) 2004 Cedric Pasteur <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KPROPERTY_CUSTOMPROPERTY_H
#define KPROPERTY_CUSTOMPROPERTY_H
#include "koproperty_global.h"
class TQVariant;
namespace KoProperty {
class Property;
//! \brief Base class for custom properties
/*! You will need to subclass CustomProperty to override the behaviour of a property type.\n
In the constructor, you should create the child properties (if needed).
Then, you need to implement the functions concerning values.\n
Examples of custom properties implementation can be found in customproperty.cpp.
\author Cedric Pasteur <[email protected]>
*/
class KOPROPERTY_EXPORT CustomProperty
{
public:
CustomProperty(Property *parent);
virtual ~CustomProperty();
/*! This function is called by \ref Property::setValue() when
a custom property is set.
You don't have to modify the property value, it is done by Property class.
You just have to update child or parent properties value (m_property->parent()->setValue()).
Note that, when calling Property::setValue, you <b>need</b> to set
useCustomProperty (3rd parameter) to false, or there will be infinite recursion. */
virtual void setValue(const TQVariant &value, bool rememberOldValue) = 0;
/*! This function is called by \ref Property::value() when
a custom property is set and \ref handleValue() is true.
You should return property's value, taken from parent's value.*/
virtual TQVariant value() const = 0;
/*! Tells whether CustomProperty should be used to get the property's value.
CustomProperty::setValue() will always be called. But if hadleValue() == true,
then the value stored in the Property won't be changed.
You should return true for child properties, and false for others. */
virtual bool handleValue() const { return false; }
protected:
Property *m_property;
/*! This method emits the \a Set::propertyChanged() signal for all
sets our parent-property is registered in. */
void emitPropertyChanged();
};
//! \brief Custom property implementation for TQSize type
class KOPROPERTY_EXPORT SizeCustomProperty : public CustomProperty
{
public:
SizeCustomProperty(Property *parent);
~SizeCustomProperty();
void setValue(const TQVariant &value, bool rememberOldValue);
TQVariant value() const;
bool handleValue() const;
};
//! \brief Custom property implementation for TQPoint type
class KOPROPERTY_EXPORT PointCustomProperty : public CustomProperty
{
public:
PointCustomProperty(Property *parent);
~PointCustomProperty();
void setValue(const TQVariant &value, bool rememberOldValue);
TQVariant value() const;
bool handleValue() const;
};
//! \brief Custom property implementation for TQRect type
class KOPROPERTY_EXPORT RectCustomProperty : public CustomProperty
{
public:
RectCustomProperty(Property *parent);
~RectCustomProperty();
void setValue(const TQVariant &value, bool rememberOldValue);
TQVariant value() const;
bool handleValue() const;
};
//! \brief Custom property implementation for TQSizePolicy type
class KOPROPERTY_EXPORT SizePolicyCustomProperty : public CustomProperty
{
public:
SizePolicyCustomProperty(Property *parent);
~SizePolicyCustomProperty();
void setValue(const TQVariant &value, bool rememberOldValue);
TQVariant value() const;
bool handleValue() const;
};
}
#endif
|