profile: implement proper model/view semantics in ProfileWidget2

The ProfileWidget2 slots, which reacted to model changes were
broken. They did not add / remove items at the changed positions,
but arbitrarily at the end. Moreover, they assumed that only
a single item was added / removed and thus violated the model/view
API.

This worked because the handles are completely reset after each
operation and the model only ever touched single items.
Nevertheless, this has to be fixed if we ever want finer grained
undo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-24 23:29:28 +01:00 committed by Dirk Hohndel
parent 396758d489
commit 79ddb23edf
2 changed files with 43 additions and 6 deletions

View file

@ -112,8 +112,10 @@ slots: // Necessary to call from QAction's signals.
void picturesAdded(dive *d, QVector<PictureObj> pics);
void setPlanState();
void setAddState();
void pointsReset();
void pointInserted(const QModelIndex &parent, int start, int end);
void pointsRemoved(const QModelIndex &, int start, int end);
void pointsMoved(const QModelIndex &, int start, int end, const QModelIndex &destination, int row);
void updateThumbnail(QString filename, QImage thumbnail, duration_t duration);
void profileChanged(dive *d);
void pictureOffsetChanged(dive *d, QString filename, offset_t offset);
@ -256,6 +258,8 @@ private:
#ifndef SUBSURFACE_MOBILE
void repositionDiveHandlers();
int fixHandlerIndex(DiveHandler *activeHandler);
DiveHandler *createHandle();
QGraphicsSimpleTextItem *createGas();
#endif
friend class DiveHandler;
QHash<Qt::Key, QAction *> actionsForKeys;