KDevelop API Documentation

lib/widgets/propeditor/property.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Alexander Dymo <cloudtemple@mksat.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 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 //standard QVariant types 00035 String = QVariant::String, //string 00036 Integer = QVariant::Int, //integer 00037 Double = QVariant::Double, //double 00038 Boolean = QVariant::Bool, //boolean 00039 StringList = QVariant::StringList, //string list 00040 Color = QVariant::Color, //color 00041 List = QVariant::List, //QValueList<QVariant> 00042 Map = QVariant::Map, //QMap<QString, QVariant> 00043 00044 //predefined custom types 00045 ValueFromList = 2000, //string value from a list 00046 Symbol = 2001, //unicode symbol code 00047 FontName = 2002, //font name, e.g. "times new roman" 00048 FieldName = 2003, //field name, normally behaves like a String, but can be overridden 00049 LineStyle = 2004, //list of line styles 00050 00051 UserDefined = 3000 //plugin defined properties should start here 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
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:09 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003