cleanup: use lambdas to transport DiveEventItem to actions

The removeEvent(), hideEvents() and editName() actions need
the DiveEventItem they are applied to. This was transported
via QAction's user-data, which means casting to void and
back.

By using lambdas instead, this can be made perfectly type-safe:
First we are 100% sure that we have a DiveEventItem because
we check the result of a dynamic_cast<>. Then we can pass
it to the even using its proper type.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-02 22:23:40 +01:00
parent 83d10ce89a
commit 76a41f45c7
2 changed files with 9 additions and 18 deletions

View file

@ -115,10 +115,7 @@ slots: // Necessary to call from QAction's signals.
void removePictures(const QVector<QString> &fileUrls);
void setPlanState();
void setAddState();
void hideEvents();
void unhideEvents();
void removeEvent();
void editName();
void makeFirstDC();
void deleteCurrentDC();
void splitCurrentDC();
@ -175,6 +172,9 @@ private:
void addBookmark(int seconds);
void splitDive(int seconds);
void addSetpointChange(int seconds);
void removeEvent(DiveEventItem *item);
void hideEvents(DiveEventItem *item);
void editName(DiveEventItem *item);
private:
DivePlotDataModel *dataModel;
int zoomLevel;