[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfpobj.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfpobj.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfpobj.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 
25 #ifndef KLFPOBJ_H
26 #define KLFPOBJ_H
27 
28 #include <QDebug>
29 #include <QVariant>
30 #include <QByteArray>
31 #include <QDataStream>
32 #include <QTextStream>
33 #include <QVector>
34 #include <QList>
35 #include <QMap>
36 #include <QStringList>
37 
38 #include <klfdefs.h>
39 
86 class KLF_EXPORT KLFPropertizedObject
87 {
88 public:
92  explicit KLFPropertizedObject(const QString& propertyNameSpace);
93  virtual ~KLFPropertizedObject();
94 
103  virtual QVariant property(const QString& propName) const;
113  virtual QVariant property(int propId) const;
114 
123  QList<int> propertyIdList() const;
124 
131  QStringList propertyNameList() const;
132 
137  QMap<QString,QVariant> allProperties() const;
138 
145  void setAllProperties(const QMap<QString, QVariant>& propValues);
146 
147 
152  QByteArray allPropertiesToByteArray() const;
153 
158  void setAllPropertiesFromByteArray(const QByteArray& data);
159 
163  ToStringUseHtml = 0x0001,
164  ToStringUseHtmlDiv = 0x0002,
165  ToStringQuoteValues = 0x0004,
166  ToStringAllProperties = 0x0008
167  };
172  virtual QString toString(uint toStringFlags = 0) const;
173 
175 
177  int propertyMaxId() const;
179 
182  bool propertyIdRegistered(int propId) const;
184 
187  bool propertyNameRegistered(const QString& propertyName) const;
189 
192  int propertyIdForName(const QString& propertyName) const;
194 
197  QString propertyNameForId(int propId) const;
199 
202  QList<int> registeredPropertyIdList() const;
204 
207  QStringList registeredPropertyNameList() const;
209 
212  QMap<QString, int> registeredProperties() const;
213 
214 protected:
215 
225  virtual void propertyValueChanged(int propId, const QVariant& oldValue,
226  const QVariant& newValue);
227 
228 
231  virtual void setProperty(const QString& propname, const QVariant& value);
232 
235  virtual void setProperty(int propId, const QVariant& value);
236 
242  virtual int loadProperty(const QString& propname, const QVariant& value);
243 
247  void registerBuiltInProperty(int propId, const QString& propName) const;
248 
253  int registerProperty(const QString& propertyName) const;
254 
304  static void registerBuiltInProperty(const QString& propNameSpace, int propId,
305  const QString& name);
306 
320  static int registerProperty(const QString& propNameSpace, const QString& propertyName);
321 
329  static int propertyMaxId(const QString& propNameSpace);
330 
338  static bool propertyIdRegistered(const QString& propNameSpace, int propId);
339 
347  static bool propertyNameRegistered(const QString& propNameSpace, const QString& propertyName);
348 
361  static int propertyIdForName(const QString& propNameSpace, const QString& propertyName);
362 
370  static QString propertyNameForId(const QString& propNameSpace, int propId);
371 
378  static QList<int> registeredPropertyIdList(const QString& propNameSpace);
379 
386  static QStringList registeredPropertyNameList(const QString& propNameSpace);
387 
394  static QMap<QString, int> registeredProperties(const QString& propNameSpace);
395 
396  QString propertyNameSpace() const { return pPropNameSpace; }
397 
398  QVector<QVariant> propertyVector() const { return pProperties; }
399 
400 private:
403 
404  QString pPropNameSpace;
405 
406  QVector<QVariant> pProperties;
407 
411  static int internalRegisterProperty(const QString& propNameSpace, const QString& name,
412  int propId = -1);
413  static QMap<QString, QMap<QString, int> > pRegisteredProperties;
414  static QMap<QString, int> pRegisteredPropertiesMaxId;
415 
416  friend bool operator==(const KLFPropertizedObject& a, const KLFPropertizedObject& b);
417 };
418 
422 bool operator==(const KLFPropertizedObject& a, const KLFPropertizedObject& b);
423 
424 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFPropertizedObject& obj);
425 KLF_EXPORT QDataStream& operator>>(QDataStream& stream, KLFPropertizedObject& obj);
426 
427 KLF_EXPORT QTextStream& operator<<(QTextStream& stream, const KLFPropertizedObject& obj);
428 
429 KLF_EXPORT QDebug& operator<<(QDebug& stream, const KLFPropertizedObject& obj);
430 
431 
432 
433 
434 #endif
A class that holds properties.
Definition: klfpobj.h:86
ToStringFlag
Flags for tuning the toString() method.
Definition: klfpobj.h:162
QString propertyNameSpace() const
Definition: klfpobj.h:396
int propId
Definition: klfutil.cpp:251
KLF_EXPORT QDataStream & operator>>(QDataStream &stream, KLFPropertizedObject &obj)
Definition: klfpobj.cpp:479
bool operator==(const KLFPropertizedObject &a, const KLFPropertizedObject &b)
Definition: klfpobj.cpp:459
QVector< QVariant > propertyVector() const
Definition: klfpobj.h:398
KLF_EXPORT QDataStream & operator<<(QDataStream &stream, const KLFPropertizedObject &obj)
Definition: klfpobj.cpp:474

Generated by doxygen 1.8.6