#pragma once #include "QmlObjectListModel.h" #include #include template class ContainerType = QVector> class WimaPolygonArray { public: WimaPolygonArray() {} WimaPolygonArray(const WimaPolygonArray &other) : _polygons(other._polygons), _dirty(true) {} ~WimaPolygonArray(){ _objs.clearAndDeleteContents(); } class QmlObjectListModel *QmlObjectListModel(){ if (_dirty) _updateObjects(); _dirty = false; return &_objs; } const ContainerType &polygons() const { return _polygons; } ContainerType &polygons(){ _dirty = true; return _polygons; } private: void _updateObjects(void){ _objs.clearAndDeleteContents(); for (long i=0; i<_polygons.size(); ++i){ _objs.append(new PolygonType(_polygons[i])); } } ContainerType _polygons; class QmlObjectListModel _objs; bool _dirty; };