diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-04-06 17:58:16 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-04-09 07:50:21 -0700 |
commit | f1830cd44e75ac552e09dfd79f6ec9e0d90f8808 (patch) | |
tree | 54798135ab086854b6837902260e4df1eed2715a /profile-widget/profilewidget2.h | |
parent | f633cb81ae095ea128a406e69b5eecab23be92a9 (diff) | |
download | subsurface-f1830cd44e75ac552e09dfd79f6ec9e0d90f8808.tar.gz |
Profile: On dataChanged() only update pictures that actually changed
Only update those pictures of the DivePictureModel that actually changed.
This will be useful once pictures are loaded incrementally.
To do so, replace the pictures array by an array with stable ids. Before
this commit, not-shown pictures are left out of the pictures array, which
makes the mapping from DivePictureModel-ids to the picture array index
non-trivial.
Replace the QList<DivePictureItem *> by a std::vector<std::unique_ptr<DivePictureItem>>
to ease memory management. Sadly, owing to COW semantics, QVector is incompatible
with QScopedPointer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/profilewidget2.h')
-rw-r--r-- | profile-widget/profilewidget2.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 575680f68..7766c4eef 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -3,6 +3,8 @@ #define PROFILEWIDGET2_H #include <QGraphicsView> +#include <vector> +#include <memory> // /* The idea of this widget is to display and edit the profile. // * It has: @@ -121,6 +123,7 @@ slots: // Necessary to call from QAction's signals. void deleteCurrentDC(); void pointInserted(const QModelIndex &parent, int start, int end); void pointsRemoved(const QModelIndex &, int start, int end); + void updatePictures(const QModelIndex &from, const QModelIndex &to); /* this is called for every move on the handlers. maybe we can speed up this a bit? */ void recreatePlannedDive(); @@ -164,6 +167,7 @@ private: /*methods*/ void addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)()); void createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, double *thresholdSettingsMin, double *thresholdSettingsMax); + void clearPictures(); private: DivePlotDataModel *dataModel; int zoomLevel; @@ -217,7 +221,9 @@ private: bool printMode; QList<QGraphicsSimpleTextItem *> gases; - QList<DivePictureItem *> pictures; + + // Use std::vector<> and std::unique_ptr<>, because QVector<QScopedPointer<...>> is unsupported. + std::vector<std::unique_ptr<DivePictureItem>> pictures; //specifics for ADD and PLAN #ifndef SUBSURFACE_MOBILE |