diff -r 241d3e452b32 -r 265b2e95a8e8 src/model.h --- a/src/model.h Fri Dec 28 00:03:47 2018 +0200 +++ b/src/model.h Thu Jun 20 08:54:35 2019 +0300 @@ -73,7 +73,7 @@ /* * This class represents a LDraw model, consisting of a vector of objects. It manages LDObject ownership. */ -class Model : public QAbstractListModel +class Model : public QObject { Q_OBJECT @@ -104,26 +104,16 @@ bool isEmpty() const; class DocumentManager* documentManager() const; IndexGenerator indices() const; - LDObject* lookup(const QModelIndex& index) const; - QColor pickingColorForObject(const QModelIndex& objectIndex) const; + LDObject* lookup(const Uuid& index) const; + QColor pickingColorForObject(const Uuid& id) const; QModelIndex objectByPickingColor(const QColor& color) const; Winding winding() const; void setWinding(Winding winding); - - bool moveRows( - const QModelIndex& sourceParent, - int sourceRow, - int count, - const QModelIndex& destinationParent, - int destinationChild - ) override; - - int rowCount(const QModelIndex& parent) const override; - QVariant data(const QModelIndex& index, int role) const override; + int rowOf(const Uuid& id); signals: - void objectAdded(const QModelIndex& object); - void aboutToRemoveObject(const QModelIndex& index); + void objectAdded(const Uuid& object); + void aboutToRemoveObject(const Uuid& index, const LDObject* object); void objectModified(LDObject* object); void windingChanged(Winding newWinding); void modelChanged(); @@ -132,6 +122,7 @@ template T* constructObject(Args&& ...args); QVector _objects; + QMap _objectsById; QMap pickingColors; QRgb pickingColorCursor = 0x000001; class DocumentManager* _manager;