summaryrefslogtreecommitdiffstats
path: root/lib/widgets/propeditor/multiproperty.h
blob: 61c04e7d06fd842ce0460ceff042a6af234333ad (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
/***************************************************************************
 *   Copyright (C) 2004 by Alexander Dymo  <cloudtemple@mskat.net>         *
 *                                                                         *
 *   This program 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 program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
#ifndef MULTIPROPERTY_H
#define MULTIPROPERTY_H

#include <tqptrlist.h>
#include <tqmap.h>
#include <tqvariant.h>

#include "property.h"
#include "childproperty.h"

namespace PropertyLib{

class PropertyList;

/** @file multiproperty.h
@short Contains @ref PropertyLib::MultiProperty class.
*/

/**
@short Holds a list of properties with the same name and type.

It is used by @ref PropertyLib::PropertyList to store properties. Generally, @ref PropertyLib::PropertyList
stores a list of multiproperties instead of properties. This allows working
with many properties of the same name and type at the same type.

MultiProperty is also responsible for storing detailed %property editors (instances
of @ref ChildProperty class. It's too much overhead to store child properties
with their parent properties. MultiProperty provides a way to store child properties
only once for all properties with the same name and same type.
*/
class MultiProperty
{
public:
    /**Constructs multiproperty with one property which is not connected to a property list.*/
    MultiProperty(Property *prop);
    /**Constructs empty multiproperty.*/
    MultiProperty(PropertyList *propertyList);
    /**Constructs multiproperty with one Property in the list.*/
    MultiProperty(PropertyList *propertyList, Property *prop);
    ~MultiProperty();

    /**Compares two multiproperties.*/    
    bool operator ==(const MultiProperty &prop) const;
    /**Compares %multiproperty with %property.*/    
    bool operator ==(const Property &prop) const;

    /**Adds %property to the list.*/
    void addProperty(Property *prop);
    /**Removes %property from the list.*/
    void removeProperty(Property *prop);
    /**Adds all properties from the %multiproperty prop.*/
    void addProperty(MultiProperty *prop);
    /**Removes all properties that exists in the %multiproperty prop.*/
    void removeProperty(MultiProperty *prop);
        
    /**Returns the name of a %property.*/
    TQString name() const;
    /**Returns the type of a %property.*/
    int type() const;
    /**Returns the value of a %property.*/
    TQVariant value() const;
    /**Returns the description of a %property.*/
    TQString description() const;
    /**Returns the readonly attribute of a %property.*/
    bool readOnly() const;
    /**Returns the visibility attribute of a %property.*/
    bool visible() const;
    /**The string-to-value correspondence list of the %property.*/
    TQStringVariantMap valueList() const;
    
    /**Sets the value of a %property.*/
    void setValue(const TQVariant& value);
    /**Sets the value of a %property.
    @param value new value of thus %multiproperty 
    @param emitChange if set to true then %property list which owns this %multiproperty 
    emits propertyValueChanged signal.*/
    void setValue(const TQVariant& value, bool emitChange);
    /**Sets the description of a %property.*/
    void setDescription(const TQString &description);
    /**Sets the list of possible values of a %property.*/
    void setValueList(const TQMap< TQString, TQVariant >& valueList);
    
    /**Finds string description for a value.*/
    TQVariant findValueDescription() const;
    /**Finds string description for a value.*/
    TQVariant findValueDescription(TQVariant val) const;
    
    /**Returns true if the %multiproperty has no properties in the list (i.e. it's invalid).*/
    bool valid() const;
    
    /**Reverts the property value to previous setting.*/
    void undo();
    
    /**The list of child properties.*/
    TQValueList<ChildProperty> details;

private:
    TQPtrList<Property> list;

    PropertyList *m_propertyList;
    
friend class PropertyList;
friend class PropertyBuffer;
};

}

#endif