diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-01-10 16:36:45 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-01-10 21:25:02 +0100 |
commit | 3d8b0e6d3f7fb9f0efbb257889ec9d654a50bfc0 (patch) | |
tree | d0bae38fd7a1df0855baf54ec1b771aa300c2ea9 /profile-widget | |
parent | 6cf06fb61d468339ef2091d3846840c7b00e41c7 (diff) | |
download | subsurface-3d8b0e6d3f7fb9f0efbb257889ec9d654a50bfc0.tar.gz |
Replace HIDE_ALL macro by template function in profilewidget2.cpp
This is easier to read and debug.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index e1e35ef84..2d3b72dac 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1004,6 +1004,13 @@ bool ProfileWidget2::eventFilter(QObject *object, QEvent *event) } #endif +template <typename T> +static void hideAll(T &container) +{ + Q_FOREACH (auto *item, container) + item->setVisible(false); +} + void ProfileWidget2::setEmptyState() { // Then starting Empty State, move the background up. @@ -1047,18 +1054,15 @@ void ProfileWidget2::setEmptyState() heartBeatItem->setVisible(false); #endif -#define HIDE_ALL(TYPE, CONTAINER) \ - Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); #ifndef SUBSURFACE_MOBILE - HIDE_ALL(DiveCalculatedTissue, allTissues); - HIDE_ALL(DivePercentageItem, allPercentages); + hideAll(allTissues); + hideAll(allPercentages); #endif - HIDE_ALL(DiveEventItem, eventItems); + hideAll(eventItems); #ifndef SUBSURFACE_MOBILE - HIDE_ALL(DiveHandler, handles); + hideAll(handles); #endif - HIDE_ALL(QGraphicsSimpleTextItem, gases); -#undef HIDE_ALL + hideAll(gases); } void ProfileWidget2::setProfileState() @@ -1187,16 +1191,12 @@ void ProfileWidget2::setProfileState() tankItem->setVisible(prefs.tankbar); tankItem->setPos(itemPos.tankBar.on); -#define HIDE_ALL(TYPE, CONTAINER) \ - Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); - #ifndef SUBSURFACE_MOBILE - HIDE_ALL(DiveHandler, handles); + hideAll(handles); mouseFollowerHorizontal->setVisible(false); mouseFollowerVertical->setVisible(false); #endif - HIDE_ALL(QGraphicsSimpleTextItem, gases); -#undef HIDE_ALL + hideAll(gases); } #ifndef SUBSURFACE_MOBILE @@ -1713,9 +1713,7 @@ void ProfileWidget2::pointsRemoved(const QModelIndex &, int start, int end) void ProfileWidget2::repositionDiveHandlers() { DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); - #define HIDE_ALL(TYPE, CONTAINER) \ - Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); - HIDE_ALL(QGraphicsSimpleTextItem, gases); + hideAll(gases); // Re-position the user generated dive handlers for (int i = 0; i < plannerModel->rowCount(); i++) { struct divedatapoint datapoint = plannerModel->at(i); |