lib

set.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
00004    Copyright (C) 2004-2006 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KPROPERTY_SET_H
00023 #define KPROPERTY_SET_H
00024 
00025 #include "koproperty_global.h"
00026 #include <qobject.h>
00027 #include <qasciidict.h>
00028 
00029 namespace KoProperty {
00030 
00031 class Property;
00032 class SetPrivate;
00033 
00034 typedef QMap<QCString, QValueList<QCString> > StringListMap ;
00035 typedef QMapIterator<QCString, QStringList> StringListMapIterator;
00036 
00043 class KOPROPERTY_EXPORT Set : public QObject
00044 {
00045     Q_OBJECT
00046 
00047     public:
00055         class KOPROPERTY_EXPORT Iterator {
00056             public:
00057                 Iterator(const Set &set);
00058                 ~Iterator();
00059 
00060                 void operator ++();
00061                 Property*  operator *();
00062 
00063                 QCString  currentKey();
00064                 Property*  current();
00065 
00066             private:
00067                 QAsciiDictIterator<Property> *iterator;
00068                 friend class Set;
00069         };
00070 
00071         Set(QObject *parent=0, const QString &typeName=QString::null);
00072 
00075         Set(const Set& set);
00076 
00077         ~Set();
00078 
00081         void addProperty(Property *property, QCString group = "common");
00082 
00084         void removeProperty(Property *property);
00085 
00088         void removeProperty(const QCString &name);
00089 
00091         virtual void clear();
00092 
00094         uint count() const;
00095 
00097         bool isEmpty() const;
00098 
00106         bool isReadOnly() const;
00107 
00110         void setReadOnly(bool readOnly);
00111 
00113         bool contains(const QCString &name);
00114 
00117         Property&  property( const QCString &name);
00118 
00133         Property&  operator[](const QCString &name);
00134 
00136         const Set& operator= (const Set &set);
00137 
00140         void changeProperty(const QCString &property, const QVariant &value);
00141 
00143         void setGroupDescription(const QCString &group, const QString desc);
00144 
00145         QString groupDescription(const QCString &group);
00146 
00147         const StringListMap& groups();
00148 
00150         QCString prevSelection() const;
00151 
00152         void setPrevSelection(const QCString& prevSelection);
00153 
00160         QString typeName() const;
00161 
00162         void debug();
00163 
00164     protected:
00166         Set(bool propertyOwner);
00167 
00169         void addToGroup(const QCString &group, Property *property);
00170 
00172         void removeFromGroup(Property *property);
00173 
00178         void addPropertyInternal(Property *property, QCString group, bool updateSortingKey);
00179 
00180     signals:
00182         void propertyChanged(KoProperty::Set& set, KoProperty::Property& property);
00183 
00185         void propertyReset(KoProperty::Set& set, KoProperty::Property& property);
00186 
00188         void aboutToDeleteProperty(KoProperty::Set& set, KoProperty::Property& property);
00189 
00192         void aboutToBeCleared();
00193 
00195         void aboutToBeDeleted();
00196 
00197     protected:
00198         SetPrivate *d;
00199 
00200     friend class Iterator;
00201     friend class Property;
00202     friend class Buffer;
00203 };
00204 
00211 class KOPROPERTY_EXPORT Buffer : public Set
00212 {
00213     Q_OBJECT
00214 
00215     public:
00216         Buffer();
00217         Buffer(const Set *set);
00218 
00220         virtual void intersect(const Set *set);
00221 
00222     protected slots:
00223         void intersectedChanged(KoProperty::Set& set, KoProperty::Property& prop);
00224         void intersectedReset(KoProperty::Set& set, KoProperty::Property& prop);
00225 
00226     private:
00227         void initialSet(const Set *set);
00228 };
00229 
00230 }
00231 
00232 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys