F:/KPlato/koffice/libs/koproperty/property.h

Aller à la documentation de ce fichier.
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_PROPERTY_H
00023 #define KPROPERTY_PROPERTY_H
00024 
00025 #include <QVariant>
00026 #include <QStringList>
00027 #include <QByteArray>
00028 #include "koproperty_global.h"
00029 
00030 template<class U> class Q3AsciiDict;
00031 template<class U> class Q3AsciiDictIterator;
00032 
00054 namespace KoProperty {
00055 
00056 class PropertyPrivate;
00057 class CustomProperty;
00058 class Set;
00059 
00061 //KOPROPERTY_EXPORT QMap<QString, QVariant> createValueListFromStringLists(
00062 //      const QStringList &keys, const QStringList &values);
00063 
00067 enum PropertyType {
00068         //standard supported QVariant types
00069         Auto = QVariant::Invalid - 1,
00070         Invalid = QVariant::Invalid   ,
00071         Map = QVariant::Map           ,
00072         List = QVariant::List         ,
00073         String = QVariant::String     ,
00074         StringList = QVariant::StringList  ,
00075         Font = QVariant::Font         ,
00076         Pixmap = QVariant::Pixmap     ,
00078         Rect = QVariant::Rect         ,
00079         Size = QVariant::Size         ,
00080         Color = QVariant::Color       ,
00084         Point = QVariant::Point       ,
00086         Integer = QVariant::Int       ,
00088         Boolean = QVariant::Bool      ,
00089         Double = QVariant::Double     ,
00090         CString = QVariant::CString   ,
00094         Cursor = QVariant::Cursor     ,
00095         SizePolicy = QVariant::SizePolicy  ,
00096         Date = QVariant::Date         ,
00097         Time = QVariant::Time         ,
00098         DateTime = QVariant::DateTime ,
00102 
00103         //predefined custom types
00104         ValueFromList = 2000          ,
00105         Symbol = 2001                 ,
00106         FontName                      ,
00107         FileURL                       ,
00108         PictureFileURL                ,
00109         DirectoryURL                  ,
00110         LineStyle                     ,
00111 
00112         // Child property types
00113         Size_Height = 3001,
00114         Size_Width,
00115         Point_X,
00116         Point_Y,
00117         Rect_X,
00118         Rect_Y,
00119         Rect_Width,
00120         Rect_Height,
00121         SizePolicy_HorData,
00122         SizePolicy_VerData,
00123         SizePolicy_HorStretch,
00124         SizePolicy_VerStretch,
00125 
00126         UserDefined = 4000            
00127 };
00128 
00174 class KOPROPERTY_EXPORT Property
00175 {
00176         public:
00178                 QT_STATIC_CONST Property null;
00179 
00180                 typedef Q3AsciiDict<Property> Dict;
00181                 typedef Q3AsciiDictIterator<Property> DictIterator;
00182 
00184                 class KOPROPERTY_EXPORT ListData
00185                 {
00186                 public:
00189                         ListData(const QStringList& keys_, const QStringList& names_);
00190                         ListData(const QList<QVariant> keys_, const QStringList& names_);
00191                         ListData();
00192                         ~ListData();
00193 
00194                         void setKeysAsStringList(const QStringList& list);
00195                         QStringList keysAsStringList() const;
00196 
00201                         QList<QVariant> keys;
00202 //                      QStringList keys;
00203 
00205 
00207                         QStringList names;
00208 
00209 //unused for now                        /*! True (the default), if the list has fixed number of possible
00210 //unused for now                         items (keys). If this is false, user can add or enter own values. */
00211 //unused for now                        bool fixed : 1;
00212                 };
00213 
00215                 Property();
00216 
00221                 Property(const QByteArray &name, const QVariant &value = QVariant(),
00222                         const QString &caption = QString::null, const QString &description = QString::null,
00223                         int type = Auto, Property* parent = 0);
00224 
00226                 Property(const QByteArray &name, const QStringList &keys, const QStringList &strings, 
00227                         const QVariant &value = QVariant(),
00228                         const QString &caption = QString::null, const QString &description = QString::null,
00229                         int type = ValueFromList, Property* parent = 0);
00230 
00233                 Property(const QByteArray &name, ListData* listData,
00234                         const QVariant &value = QVariant(),
00235                         const QString &caption = QString::null, const QString &description = QString::null,
00236                         int type = ValueFromList, Property* parent = 0);
00237 
00239                 Property(const Property &prop);
00240 
00241                 ~Property();
00242 
00244                 QByteArray name() const;
00245 
00247                 void setName(const QByteArray &name);
00248 
00250                 QString caption() const;
00251 
00255                 QString captionForDisplaying() const;
00256 
00260                 void setCaption(const QString &caption);
00261 
00263                 QString description() const;
00264 
00266                 void setDescription(const QString &description);
00267 
00269                 int type() const;
00270 
00272                 void setType(int type);
00273 
00275                 QVariant value() const;
00276 
00278                 QVariant oldValue() const;
00279 
00281                 void setValue(const QVariant &value, bool rememberOldValue = true, bool useCustomProperty=true);
00282 
00285                 void resetValue();
00286 
00289                 ListData* listData() const;
00290 
00293                 void setListData(ListData* list);
00294 
00298                 void setListData(const QStringList &keys, const QStringList &names);
00299 
00302                 void setIcon(const QString &icon);
00303 
00305                 QString icon() const;
00306 
00309                 const QList<Property*>*  children() const;
00310 
00312                 Property* child(const QByteArray &name);
00313 
00315                 Property* parent() const;
00316 
00319                 CustomProperty* customProperty() const;
00320 
00323                 void setCustomProperty(CustomProperty *prop);
00324 
00326                 bool isNull() const;
00327 
00329                 operator bool () const;
00330 
00332                 bool isModified() const;
00333 
00335                 void clearModifiedFlag();
00336 
00342                 bool isReadOnly() const;
00343 
00346                 void setReadOnly(bool readOnly);
00347 
00349                 bool isVisible() const;
00350 
00352                 void setVisible(bool visible);
00353 
00357                 bool isStorable() const;
00358 
00360                 void setStorable(bool storable);
00361 
00368                 int autoSync() const;
00369 
00376                 void setAutoSync(int sync);
00377 
00383                 void setOption(const char* name, const QVariant& val);
00384 
00386                 QVariant option(const char* name) const;
00387 
00389                 bool hasOptions() const;
00390 
00392                 const Property& operator= (const QVariant& val);
00393 
00395                 const Property& operator= (const Property &property);
00396 
00398                 bool operator ==(const Property &prop) const;
00399 
00404                 int sortingKey() const;
00405 
00406         protected:
00409                 void addChild(Property *prop);
00410 
00412                 void addSet(Set *set);
00413 
00415                 void setSortingKey(int key);
00416 
00418                 const QList<Property*>* related() const;
00419 
00421                 void addRelatedProperty(Property *property);
00422 
00426                 void emitPropertyChanged();
00427 
00429                 void debug();
00430 
00432                 PropertyPrivate *d;
00433 
00434         friend class Set;
00435         friend class Buffer;
00436         friend class CustomProperty;
00437 };
00438 
00439 }
00440 
00441 #endif

Généré le Wed Nov 22 23:41:07 2006 pour KPlato par  doxygen 1.5.1-p1