QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RPropertyEditor.h
Go to the documentation of this file.
1 
20 #ifndef RPROPERTYEDITOR_H
21 #define RPROPERTYEDITOR_H
22 
23 #include "core_global.h"
24 
25 #include <QCoreApplication>
26 #include <QList>
27 #include <QMap>
28 #include <QString>
29 #include <QStringList>
30 
31 #include "RDocument.h"
32 #include "RObject.h"
33 #include "RPropertyListener.h"
34 
35 
45 
46  Q_DECLARE_TR_FUNCTIONS(RPropertyEditor)
47 
48 public:
50  virtual ~RPropertyEditor();
51 
52  // from RPropertyListener interface:
53  virtual void updateFromDocument(RDocument* document, bool onlyChanges,
54  RS::EntityType entityTypeFilter = RS::EntityAll, bool manual = false);
55  virtual void updateFromObject(RObject* object, RDocument* document = NULL);
56  virtual void clearEditor();
57  void propertyChanged(RPropertyTypeId propertyTypeId, QVariant propertyValue,
58  RS::EntityType entityTypeFilter = RS::EntityAll,
59  QVariant::Type typeHint = QVariant::Invalid);
60  void listPropertyChanged(RPropertyTypeId propertyTypeId,
61  int index, QVariant propertyValue,
62  RS::EntityType entityTypeFilter = RS::EntityAll);
63 
64  QStringList getGroupTitles();
65  QStringList getPropertyTitles(const QString& group);
66  QVariant getPropertyValue(const RPropertyTypeId& propertyTypeId);
67  QVariant getPropertyValue(const QString& group, const QString& title);
68  RPropertyAttributes getPropertyAttributes(const RPropertyTypeId& propertyTypeId);
69  RPropertyAttributes getPropertyAttributes(const QString& group, const QString& title);
70  QList<RS::EntityType> getTypes();
71  int getTypeCount(RS::EntityType type);
72 
73  static bool checkType(RS::EntityType type, RS::EntityType filter);
74 
75 protected:
76  virtual void updateEditor(RObject& object, bool doUpdateGui,
77  RDocument* document = NULL);
78 
84  virtual void updateGui(
85  bool onlyChanges = false,
86  RS::EntityType entityTypeFilter = RS::EntityAll) {
87 
88  Q_UNUSED(onlyChanges)
89  Q_UNUSED(entityTypeFilter)
90  }
91 
92  void updateProperty(const RPropertyTypeId& propertyTypeId, RObject& object,
93  RDocument* document);
94  void removeAllButThese(const QMultiMap<QString, QString>& propertyTitles, bool customOnly=false);
95 
96 protected:
98  typedef QMap<QString, QPair<QVariant, RPropertyAttributes> > RPropertyMap;
100  typedef QMap<QString, RPropertyMap> RPropertyGroupMap;
101 
102  QStringList groupOrder;
103  QMap<QString, QStringList> propertyOrder;
105  QMap<RS::EntityType, int> combinedTypes;
108 };
109 
111 
112 #endif