mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
6cf06fb61d
commit
3d8b0e6d3f
1 changed files with 15 additions and 17 deletions
|
@ -1004,6 +1004,13 @@ bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static void hideAll(T &container)
|
||||||
|
{
|
||||||
|
Q_FOREACH (auto *item, container)
|
||||||
|
item->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileWidget2::setEmptyState()
|
void ProfileWidget2::setEmptyState()
|
||||||
{
|
{
|
||||||
// Then starting Empty State, move the background up.
|
// Then starting Empty State, move the background up.
|
||||||
|
@ -1047,18 +1054,15 @@ void ProfileWidget2::setEmptyState()
|
||||||
heartBeatItem->setVisible(false);
|
heartBeatItem->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HIDE_ALL(TYPE, CONTAINER) \
|
|
||||||
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
HIDE_ALL(DiveCalculatedTissue, allTissues);
|
hideAll(allTissues);
|
||||||
HIDE_ALL(DivePercentageItem, allPercentages);
|
hideAll(allPercentages);
|
||||||
#endif
|
#endif
|
||||||
HIDE_ALL(DiveEventItem, eventItems);
|
hideAll(eventItems);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
HIDE_ALL(DiveHandler, handles);
|
hideAll(handles);
|
||||||
#endif
|
#endif
|
||||||
HIDE_ALL(QGraphicsSimpleTextItem, gases);
|
hideAll(gases);
|
||||||
#undef HIDE_ALL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::setProfileState()
|
void ProfileWidget2::setProfileState()
|
||||||
|
@ -1187,16 +1191,12 @@ void ProfileWidget2::setProfileState()
|
||||||
tankItem->setVisible(prefs.tankbar);
|
tankItem->setVisible(prefs.tankbar);
|
||||||
tankItem->setPos(itemPos.tankBar.on);
|
tankItem->setPos(itemPos.tankBar.on);
|
||||||
|
|
||||||
#define HIDE_ALL(TYPE, CONTAINER) \
|
|
||||||
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
|
|
||||||
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
HIDE_ALL(DiveHandler, handles);
|
hideAll(handles);
|
||||||
mouseFollowerHorizontal->setVisible(false);
|
mouseFollowerHorizontal->setVisible(false);
|
||||||
mouseFollowerVertical->setVisible(false);
|
mouseFollowerVertical->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
HIDE_ALL(QGraphicsSimpleTextItem, gases);
|
hideAll(gases);
|
||||||
#undef HIDE_ALL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
@ -1713,9 +1713,7 @@ void ProfileWidget2::pointsRemoved(const QModelIndex &, int start, int end)
|
||||||
void ProfileWidget2::repositionDiveHandlers()
|
void ProfileWidget2::repositionDiveHandlers()
|
||||||
{
|
{
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
#define HIDE_ALL(TYPE, CONTAINER) \
|
hideAll(gases);
|
||||||
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
|
|
||||||
HIDE_ALL(QGraphicsSimpleTextItem, gases);
|
|
||||||
// Re-position the user generated dive handlers
|
// Re-position the user generated dive handlers
|
||||||
for (int i = 0; i < plannerModel->rowCount(); i++) {
|
for (int i = 0; i < plannerModel->rowCount(); i++) {
|
||||||
struct divedatapoint datapoint = plannerModel->at(i);
|
struct divedatapoint datapoint = plannerModel->at(i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue