lib/widgets/propeditor/property.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef PROPERTY_H
00021
#define PROPERTY_H
00022
00023
#include <qvariant.h>
00024
00025
#include <qmap.h>
00026
00027
class QWidget;
00028
class QString;
00029
class PropertyEditor;
00030
class CanvasBox;
00031
00033 enum PropertyType {
00034
00035
String = QVariant::String,
00036
Integer = QVariant::Int,
00037
Double = QVariant::Double,
00038
Boolean = QVariant::Bool,
00039
StringList = QVariant::StringList,
00040
Color = QVariant::Color,
00041
List = QVariant::List,
00042
Map = QVariant::Map,
00043
00044
00045
ValueFromList = 2000,
00046
Symbol = 2001,
00047
FontName = 2002,
00048
FieldName = 2003,
00049
LineStyle = 2004,
00050
00051
UserDefined = 3000
00052 };
00053
00067 class Property {
00068
public:
00069 Property() {}
00070
Property(
int type,
QString name,
QString description=
"",
QVariant value=
QVariant(),
bool save=
true);
00071
Property(
QString name,
QMap<QString, QString> v_correspList,
00072
QString description=
"",
QVariant value=
QVariant(),
bool save=
true);
00073
virtual ~Property();
00074
00075
bool operator<(
const Property &prop)
const;
00076
00077
QString name() const;
00078
void setName(
QString name);
00079
int type() const;
00080
void setType(
int type);
00081
QVariant value() const;
00082
void setValue(
QVariant value);
00083
QString description() const;
00084
void setDescription(
QString description);
00085
00086
void setCorrespList(
QMap<
QString, QString> list);
00087 QMap<QString, QString> correspList;
00088
00090 virtual
QWidget *editorOfType(
PropertyEditor *editor);
00091
00095
bool allowSaving();
00096 protected:
00097 int m_type;
00098 QString m_name;
00099 QString m_description;
00100 QVariant m_value;
00101 bool m_save;
00102 };
00103
00105 template<class P>
00106 class
MPropPtr{
00107
public:
00108 MPropPtr()
00109 {
00110 m_prop =
new P();
00111 }
00112
00113 MPropPtr(P *prop): m_prop(prop) {}
00114
00115 MPropPtr(
const MPropPtr<P>& pp): m_prop(new P(*(pp.m_prop))) {}
00116
00117 MPropPtr<P>& operator=(
const MPropPtr<P>& pp)
00118 {
00119
if (
this != &pp)
00120 {
00121
delete m_prop;
00122 m_prop =
new P(*(pp.
m_prop));
00123 }
00124
return *
this;
00125 }
00126
00127 ~MPropPtr()
00128 {
00129
delete m_prop;
00130 }
00131
00132 P *operator->()
00133 {
00134
if (m_prop != 0)
00135
return m_prop;
00136
else
00137
return new P();
00138 }
00139
00140 P *operator->()
const
00141
{
00142
if (m_prop != 0)
00143
return m_prop;
00144
else
00145
return new P();
00146 }
00147
00148 bool operator<(const MPropPtr<P>& p)
const
00149 {
00150
if ((prop()->type() < p.prop()->type()) && (prop()->name() < p.prop()->name()))
00151
return true;
00152
else
00153
return false;
00154 }
00155
00156 P *prop()
const
00157
{
00158
if (m_prop != 0)
00159
return m_prop;
00160
else
00161
return new P();
00162 }
00163
private:
00164 P *m_prop;
00165 };
00166
00167 typedef MPropPtr<Property> PropPtr;
00168
00169
#endif
This file is part of the documentation for KDevelop Version 3.0.4.