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 
00040 class KOPROPERTY_EXPORT Set : public QObject
00041 {
00042     Q_OBJECT
00043 
00044     public:
00051         class KOPROPERTY_EXPORT Iterator {
00052             public:
00053                 Iterator(const Set &set);
00054                 ~Iterator();
00055 
00056                 void operator ++();
00057                 Property*  operator *() const;
00058 
00059                 QCString  currentKey() const;
00060                 Property*  current() const;
00061 
00062             private:
00063                 QAsciiDictIterator<Property> *iterator;
00064                 friend class Set;
00065         };
00066 
00067         explicit Set(QObject *parent=0, const QString &typeName=QString::null);
00068 
00071         explicit Set(const Set& set);
00072 
00073         virtual ~Set();
00074 
00077         void addProperty(Property *property, QCString group = "common");
00078 
00080         void removeProperty(Property *property);
00081 
00084         void removeProperty(const QCString &name);
00085 
00087         virtual void clear();
00088 
00090         uint count() const;
00091 
00093         bool isEmpty() const;
00094 
00102         bool isReadOnly() const;
00103 
00106         void setReadOnly(bool readOnly);
00107 
00109         bool contains(const QCString &name) const;
00110 
00113         Property& property( const QCString &name) const;
00114 
00129         Property& operator[](const QCString &name) const;
00130 
00132         const Set& operator= (const Set &set);
00133 
00136         void changeProperty(const QCString &property, const QVariant &value);
00137 
00140         void setGroupDescription(const QCString &group, const QString& desc);
00141 
00145         QString groupDescription(const QCString &group) const;
00146 
00148         void setGroupIcon(const QCString &group, const QString& icon);
00149 
00151         QString groupIcon(const QCString &group) const;
00152 
00155         const QValueList<QCString>& groupNames() const;
00156 
00159         const QValueList<QCString>& propertyNamesForGroup(const QCString &group) const;
00160 
00163         QCString prevSelection() const;
00164 
00165         void setPrevSelection(const QCString& prevSelection);
00166 
00173         QString typeName() const;
00174 
00176         void debug();
00177 
00178     protected:
00180         Set(bool propertyOwner);
00181 
00183         void addToGroup(const QCString &group, Property *property);
00184 
00186         void removeFromGroup(Property *property);
00187 
00192         void addPropertyInternal(Property *property, QCString group, bool updateSortingKey);
00193 
00196         void informAboutClearing(bool& cleared);
00197 
00198     signals:
00200         void propertyChanged(KoProperty::Set& set, KoProperty::Property& property);
00201 
00204         void propertyChangedInternal(KoProperty::Set& set, KoProperty::Property& property);
00205 
00207         void propertyReset(KoProperty::Set& set, KoProperty::Property& property);
00208 
00210         void aboutToDeleteProperty(KoProperty::Set& set, KoProperty::Property& property);
00211 
00214         void aboutToBeCleared();
00215 
00217         void aboutToBeDeleted();
00218 
00219     protected:
00220         SetPrivate *d;
00221 
00222     friend class Iterator;
00223     friend class Property;
00224     friend class Buffer;
00225 };
00226 
00233 class KOPROPERTY_EXPORT Buffer : public Set
00234 {
00235     Q_OBJECT
00236 
00237     public:
00238         Buffer();
00239         Buffer(const Set *set);
00240 
00242         virtual void intersect(const Set *set);
00243 
00244     protected slots:
00245         void intersectedChanged(KoProperty::Set& set, KoProperty::Property& prop);
00246         void intersectedReset(KoProperty::Set& set, KoProperty::Property& prop);
00247 
00248     private:
00249         void initialSet(const Set *set);
00250 };
00251 
00252 }
00253 
00254 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys