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 
00074         Set(const Set& set);
00075 
00076         ~Set();
00077 
00080         void addProperty(Property *property, QCString group = "common");
00081 
00083         void removeProperty(Property *property);
00084 
00087         void removeProperty(const QCString &name);
00088 
00090         virtual void clear();
00091 
00093         uint count() const;
00094 
00096         bool isEmpty() const;
00097 
00105         bool isReadOnly() const;
00106 
00109         void setReadOnly(bool readOnly);
00110 
00112         bool contains(const QCString &name);
00113 
00116         Property&  property( const QCString &name);
00117 
00132         Property&  operator[](const QCString &name);
00133 
00135         const Set& operator= (const Set &set);
00136 
00139         void changeProperty(const QCString &property, const QVariant &value);
00140 
00142         void setGroupDescription(const QCString &group, const QString desc);
00143 
00144         QString groupDescription(const QCString &group);
00145 
00146         const StringListMap& groups();
00147 
00149         QCString prevSelection() const;
00150 
00151         void setPrevSelection(const QCString& prevSelection);
00152 
00159         QString typeName() const;
00160 
00161         void debug();
00162 
00163     protected:
00165         Set(bool propertyOwner);
00166 
00168         void addToGroup(const QCString &group, Property *property);
00169 
00171         void removeFromGroup(Property *property);
00172 
00173     signals:
00175         void propertyChanged(KoProperty::Set& set, KoProperty::Property& property);
00176 
00178         void propertyChanged(KoProperty::Set& set, KoProperty::Property& property, 
00179             const QVariant& previousValue);
00180 
00182         void propertyChanged();
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