QCAD
Open Source 2D CAD
REntityExportListener.h
Go to the documentation of this file.
1 
20 #ifndef RENTITYEXPORTLISTENER_H
21 #define RENTITYEXPORTLISTENER_H
22 
23 #include "core_global.h"
24 
25 #include <QSet>
26 #include <QString>
27 #include <QPair>
28 
29 #include "REntity.h"
30 
31 class RExporter;
32 
41 public:
43 
48  virtual void registerCustomProperty(const QString& title, const QString& regExp) {
49  registeredProperties.insert(QPair<QString, QString>(title, regExp));
50  }
51 
52  virtual bool checkCustomProperty(REntity* e) const {
53  QSet<QPair<QString, QString> >::const_iterator it;
54  for (it=registeredProperties.constBegin(); it!=registeredProperties.constEnd(); it++) {
55  if (e->hasCustomProperty((*it).first, QRegExp((*it).second))) {
56  return true;
57  }
58  }
59 
60  return false;
61  }
62 
71  virtual void exportEntity(RExporter* exporter, REntity* entity) = 0;
72 
73 private:
74  QSet<QPair<QString, QString> > registeredProperties;
75 };
76 
78 
79 #endif
REntity.h
RObject::hasCustomProperty
bool hasCustomProperty(const QString &title, const QString &key) const
Definition: RObject.cpp:457
REntityExportListener::~REntityExportListener
virtual ~REntityExportListener()
Definition: REntityExportListener.h:42
REntityExportListener::checkCustomProperty
virtual bool checkCustomProperty(REntity *e) const
Definition: REntityExportListener.h:52
REntityExportListener::registerCustomProperty
virtual void registerCustomProperty(const QString &title, const QString &regExp)
Registers the given custom property as trigger.
Definition: REntityExportListener.h:48
REntity
Base class for all entity classes.
Definition: REntity.h:65
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(RMath *)
REntityExportListener::registeredProperties
QSet< QPair< QString, QString > > registeredProperties
Definition: REntityExportListener.h:74
core_global.h
RExporter
Abstract base class for exporters.
Definition: RExporter.h:72
REntityExportListener::exportEntity
virtual void exportEntity(RExporter *exporter, REntity *entity)=0
Called by the document whenever an entity is exporter with one of the registered custom properties.
REntityExportListener
Abstract base class for classes that wish to be notified when an entity is exported.
Definition: REntityExportListener.h:40
QCADCORE_EXPORT
#define QCADCORE_EXPORT
Definition: core_global.h:10