propertylist.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2004 by Alexander Dymo * 00003 * cloudtemple@mskat.net * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Library General Public License as * 00007 * published by the Free Software Foundation; either version 2 of the * 00008 * License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Library General Public * 00016 * License along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #ifndef PROPERTYLIST_H 00021 #define PROPERTYLIST_H 00022 00023 #include <qobject.h> 00024 #include <qmap.h> 00025 #include <qptrlist.h> 00026 #include <qvaluelist.h> 00027 #include <qpair.h> 00028 00029 namespace PropertyLib{ 00030 00031 class Property; 00032 class MultiProperty; 00033 00055 class PropertyList: public QObject 00056 { 00057 Q_OBJECT 00058 public: 00059 PropertyList(); 00060 virtual ~PropertyList(); 00061 00070 virtual MultiProperty *operator[](const QString &name); 00071 00073 virtual void addProperty(Property *property); 00075 virtual void addProperty(const QString &group, Property *property); 00077 virtual void removeProperty(Property *property); 00080 virtual void removeProperty(const QString &name); 00081 00083 virtual const QValueList<QPair<QString, QValueList<QString> > >& propertiesOfGroup() const; 00085 virtual const QMap<MultiProperty*, QString>& groupOfProperty() const; 00086 00088 virtual void clear(); 00090 virtual bool contains(const QString &name); 00091 00093 QPtrList<Property> properties(const QString &name); 00094 00095 signals: 00097 void propertyValueChanged(Property* property); 00099 void aboutToDeleteProperty(Property* property); 00100 00101 protected: 00103 PropertyList(bool propertyOwner); 00104 00106 void addToGroup(const QString &group, MultiProperty *property); 00108 void removeFromGroup(MultiProperty *property); 00109 00110 private: 00111 //sorted list of properties in form name: property 00112 QMap<QString, MultiProperty*> m_list; 00113 00114 //groups of properties: 00115 // list of group name: (list of property names) 00116 QValueList<QPair<QString, QValueList<QString> > > m_propertiesOfGroup; 00117 // map of property: group 00118 QMap<MultiProperty*, QString> m_groupOfProperty; 00119 00120 //indicates that this list will delete properties after removeProperty() 00121 //and also in destructor 00122 bool m_propertyOwner; 00123 00124 friend class MultiProperty; 00125 friend class PropertyBuffer; 00126 }; 00127 00128 00148 class PropertyBuffer: public PropertyList{ 00149 public: 00151 PropertyBuffer(PropertyList *list); 00153 PropertyBuffer(); 00154 00156 virtual void intersect(const PropertyList *list); 00157 }; 00158 00159 } 00160 00161 #endif