QCAD
Open Source 2D CAD
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 "RDocumentInterface.h"
33 #include "RLayerListener.h"
34 #include "RObject.h"
35 #include "RPropertyListener.h"
36 
37 
47 
48  Q_DECLARE_TR_FUNCTIONS(RPropertyEditor)
49 
50 public:
52  virtual ~RPropertyEditor();
53 
54  // from RPropertyListener interface:
55  virtual void updateFromDocument(RDocument* document, bool onlyChanges, RS::EntityType filter = RS::EntityUnknown, bool manual = false);
56  virtual void updateFromObject(RObject* object, RDocument* document = NULL);
57  virtual void clearEditor();
58 
59  virtual void updateLayers(RDocumentInterface* documentInterface);
60  virtual void setCurrentLayer(RDocumentInterface* documentInterface);
61  virtual void clearLayers();
62 
63  void propertyChanged(RPropertyTypeId propertyTypeId, QVariant propertyValue,
64  QVariant::Type typeHint = QVariant::Invalid);
65  void listPropertyChanged(RPropertyTypeId propertyTypeId,
66  int index, QVariant propertyValue);
67 
68  QStringList getGroupTitles();
69  QStringList getPropertyTitles(const QString& group);
70  QVariant getPropertyValue(const RPropertyTypeId& propertyTypeId);
71  QVariant getPropertyValue(const QString& group, const QString& title);
72  RPropertyAttributes getPropertyAttributes(const RPropertyTypeId& propertyTypeId);
73  RPropertyAttributes getPropertyAttributes(const QString& group, const QString& title);
74  QList<RS::EntityType> getTypes();
75  int getTypeCount(RS::EntityType type);
76 
78  entityTypeFilter = type;
79  }
80 
82  return entityTypeFilter;
83  }
84 
85  static bool checkType(RS::EntityType type, RS::EntityType filter);
86 
87 protected:
88  virtual void updateEditor(RObject& object, bool doUpdateGui, RDocument* document = NULL);
89 
95  virtual void updateGui(bool onlyChanges = false) {
96  Q_UNUSED(onlyChanges)
97  }
98 
99  void updateProperty(const RPropertyTypeId& propertyTypeId, RObject& object, RDocument* document);
100  void removeAllButThese(const QMultiMap<QString, QString>& propertyTitles, bool customOnly=false);
101 
102 protected:
104  typedef QMap<QString, QPair<QVariant, RPropertyAttributes> > RPropertyMap;
106  typedef QMap<QString, RPropertyMap> RPropertyGroupMap;
107 
108  QStringList groupOrder;
109  QMap<QString, QStringList> propertyOrder;
110  RPropertyGroupMap combinedProperties;
111  QMap<RS::EntityType, int> combinedTypes;
114 
116 };
117 
119 
120 #endif
virtual void updateLayers(RDocumentInterface *documentInterface)=0
This method is called whenever at least one layer in the given document has changed.
Unknown entity.
Definition: RS.h:87
virtual void setCurrentLayer(RDocumentInterface *documentInterface)=0
This method is called when a different layer becomes the new current layer.
virtual void clearLayers()=0
This method is called to signal that no document is currently active.
void setEntityTypeFilter(RS::EntityType type)
Definition: RPropertyEditor.h:77
QMap< QString, QStringList > propertyOrder
Definition: RPropertyEditor.h:109
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
QMap< QString, RPropertyMap > RPropertyGroupMap
group key / key,value,attributes
Definition: RPropertyEditor.h:106
Abstract base class for all objects.
Definition: RObject.h:48
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
RS::EntityType entityTypeFilter
Definition: RPropertyEditor.h:115
#define QCADCORE_EXPORT
Definition: core_global.h:10
RS::EntityType getEntityTypeFilter() const
Definition: RPropertyEditor.h:81
RPropertyGroupMap combinedProperties
Definition: RPropertyEditor.h:110
Abstract base class for classes that are interested in being notified whenever a layer has been added...
Definition: RLayerListener.h:37
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyEditor.h:46
virtual void updateFromObject(RObject *object, RDocument *document=NULL)=0
This method is called if only the properties of the given property owner are currently relevant...
virtual void clearEditor()=0
This method is called to signal that no properties are currently relevant.
Abstract base class for classes that are interested in properties of the current selection or the cur...
Definition: RPropertyListener.h:43
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
QStringList groupOrder
Definition: RPropertyEditor.h:108
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyAttributes.h:47
virtual void updateFromDocument(RDocument *document, bool onlyChanges, RS::EntityType entityTypeFilter=RS::EntityAll, bool manual=false)=0
This method is called whenever the relevant combined properties of the objects in document have chang...
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
QMap< QString, QPair< QVariant, RPropertyAttributes > > RPropertyMap
key / value / attributes
Definition: RPropertyEditor.h:104
bool updatesDisabled
Definition: RPropertyEditor.h:113
bool guiUpToDate
Definition: RPropertyEditor.h:112
QMap< RS::EntityType, int > combinedTypes
Definition: RPropertyEditor.h:111
virtual void updateGui(bool onlyChanges=false)
Updates the user interface of this property editor.
Definition: RPropertyEditor.h:95