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, bool showOnRequest = 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  RPropertyAttributes getCustomPropertyAttributes(const QString& group, const QString& title);
75  QList<RS::EntityType> getTypes();
76  int getTypeCount(RS::EntityType type);
77 
79  entityTypeFilter = type;
80  }
81 
83  return entityTypeFilter;
84  }
85 
86  static bool checkType(RS::EntityType type, RS::EntityType filter);
87 
88 protected:
89  virtual void updateEditor(RObject& object, bool doUpdateGui, RDocument* document = NULL, bool showOnRequest = false);
90 
96  virtual void updateGui(bool onlyChanges = false) {
97  Q_UNUSED(onlyChanges)
98  }
99 
100  void updateProperty(const RPropertyTypeId& propertyTypeId, RObject& object, RDocument* document, bool showOnRequest = false);
101  void removeAllButThese(const QMultiMap<QString, QString>& propertyTitles, bool customOnly=false);
102 
103 protected:
105  typedef QMap<QString, QPair<QVariant, RPropertyAttributes> > RPropertyMap;
107  typedef QMap<QString, RPropertyMap> RPropertyGroupMap;
108 
109  QStringList groupOrder;
110  QMap<QString, QStringList> propertyOrder;
111  RPropertyGroupMap combinedProperties;
112  QMap<RS::EntityType, int> combinedTypes;
115 
117 };
118 
120 
121 #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:89
virtual void updateFromDocument(RDocument *document, bool onlyChanges, RS::EntityType entityTypeFilter=RS::EntityAll, bool manual=false, bool showOnRequest=false)=0
This method is called whenever the relevant combined properties of the objects in document have chang...
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:78
QMap< QString, QStringList > propertyOrder
Definition: RPropertyEditor.h:110
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
QMap< QString, RPropertyMap > RPropertyGroupMap
group key / key,value,attributes
Definition: RPropertyEditor.h:107
Abstract base class for all objects.
Definition: RObject.h:61
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
RS::EntityType entityTypeFilter
Definition: RPropertyEditor.h:116
#define QCADCORE_EXPORT
Definition: core_global.h:10
RS::EntityType getEntityTypeFilter() const
Definition: RPropertyEditor.h:82
RPropertyGroupMap combinedProperties
Definition: RPropertyEditor.h:111
Abstract base class for classes that are interested in being notified whenever a layer has been added...
Definition: RLayerListener.h:37
Copyright (c) 2011-2018 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:109
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyAttributes.h:47
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:84
QMap< QString, QPair< QVariant, RPropertyAttributes > > RPropertyMap
key / value / attributes
Definition: RPropertyEditor.h:105
bool updatesDisabled
Definition: RPropertyEditor.h:114
bool guiUpToDate
Definition: RPropertyEditor.h:113
QMap< RS::EntityType, int > combinedTypes
Definition: RPropertyEditor.h:112
virtual void updateGui(bool onlyChanges=false)
Updates the user interface of this property editor.
Definition: RPropertyEditor.h:96