src/model.h

changeset 1273
900f1dfae46b
parent 1272
bf0ac547b934
child 1277
821c30615069
equal deleted inserted replaced
1272:bf0ac547b934 1273:900f1dfae46b
87 Model(const Model& other) = delete; 87 Model(const Model& other) = delete;
88 ~Model(); 88 ~Model();
89 89
90 void insertCopy(int position, LDObject* object); 90 void insertCopy(int position, LDObject* object);
91 void insertFromArchive(int row, Serializer::Archive& archive); 91 void insertFromArchive(int row, Serializer::Archive& archive);
92 bool swapObjects(const QModelIndex& index_1, const QModelIndex& index_2);
93 bool setObjectAt(int idx, Serializer::Archive& archive); 92 bool setObjectAt(int idx, Serializer::Archive& archive);
94 template<typename T, typename... Args> T* emplace(Args&& ...args); 93 template<typename T, typename... Args> T* emplace(Args&& ...args);
95 template<typename T, typename... Args> T* emplaceAt(int position, Args&& ...args); 94 template<typename T, typename... Args> T* emplaceAt(int position, Args&& ...args);
96 void removeAt(int position); 95 void removeAt(int position);
97 void removeAt(const QModelIndex& index); 96 void removeAt(const QModelIndex& index);
114 LDObject* replaceWithFromString(LDObject* object, QString line); 113 LDObject* replaceWithFromString(LDObject* object, QString line);
115 IndexGenerator indices() const; 114 IndexGenerator indices() const;
116 LDObject* lookup(const QModelIndex& index) const; 115 LDObject* lookup(const QModelIndex& index) const;
117 QModelIndex indexFromId(qint32 id) const; 116 QModelIndex indexFromId(qint32 id) const;
118 117
118 bool moveRows(
119 const QModelIndex& sourceParent,
120 int sourceRow,
121 int count,
122 const QModelIndex& destinationParent,
123 int destinationChild
124 ) override;
125
119 int rowCount(const QModelIndex& parent) const override; 126 int rowCount(const QModelIndex& parent) const override;
120 QVariant data(const QModelIndex& index, int role) const override; 127 QVariant data(const QModelIndex& index, int role) const override;
121 128
122 signals: 129 signals:
123 void objectAdded(const QModelIndex& object); 130 void objectAdded(const QModelIndex& object);
124 void aboutToRemoveObject(const QModelIndex& index); 131 void aboutToRemoveObject(const QModelIndex& index);
125 void objectModified(LDObject* object); 132 void objectModified(LDObject* object);
126 void objectsSwapped(const QModelIndex& index_1, const QModelIndex& index_2);
127 133
128 protected: 134 protected:
129 template<typename T, typename... Args> T* constructObject(Args&& ...args); 135 template<typename T, typename... Args> T* constructObject(Args&& ...args);
130 136
131 QVector<LDObject*> _objects; 137 QVector<LDObject*> _objects;

mercurial