New profile: fix event hiding logic

Turns out we unconditionally set all events as visible when redrawing the
dive - even with a comment that this should take into account if the event
is visible. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-03-16 15:10:03 -07:00
parent 0f7dfcee26
commit 33b1b0ed9d
3 changed files with 14 additions and 9 deletions

View file

@ -109,9 +109,17 @@ void DiveEventItem::eventVisibilityChanged(const QString &eventName, bool visibl
{ {
} }
bool DiveEventItem::shouldBeHidden()
{
for (int i = 0; i < evn_used; i++) {
if (!strcmp(internalEvent->name, ev_namelist[i].ev_name) && ev_namelist[i].plot_ev == false)
return true;
}
return false;
}
void DiveEventItem::recalculatePos(bool instant) void DiveEventItem::recalculatePos(bool instant)
{ {
bool hidden = false;
if (!vAxis || !hAxis || !internalEvent || !dataModel) if (!vAxis || !hAxis || !internalEvent || !dataModel)
return; return;
@ -121,11 +129,7 @@ void DiveEventItem::recalculatePos(bool instant)
hide(); hide();
return; return;
} }
for (int i = 0; i < evn_used; i++) { if (!isVisible() && !shouldBeHidden())
if (!strcmp(internalEvent->name, ev_namelist[i].ev_name) && ev_namelist[i].plot_ev == false)
hidden = true;
}
if (!isVisible() && !hidden)
show(); show();
int depth = dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt(); int depth = dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
qreal x = hAxis->posAtValue(internalEvent->time.seconds); qreal x = hAxis->posAtValue(internalEvent->time.seconds);
@ -134,6 +138,6 @@ void DiveEventItem::recalculatePos(bool instant)
Animations::moveTo(this, x, y); Animations::moveTo(this, x, y);
else else
setPos(x, y); setPos(x, y);
if (isVisible() && hidden) if (isVisible() && shouldBeHidden())
hide(); hide();
} }

View file

@ -17,6 +17,7 @@ public:
void setVerticalAxis(DiveCartesianAxis *axis); void setVerticalAxis(DiveCartesianAxis *axis);
void setHorizontalAxis(DiveCartesianAxis *axis); void setHorizontalAxis(DiveCartesianAxis *axis);
void setModel(DivePlotDataModel *model); void setModel(DivePlotDataModel *model);
bool shouldBeHidden();
public public
slots: slots:
void recalculatePos(bool instant = false); void recalculatePos(bool instant = false);

View file

@ -441,8 +441,8 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
} }
// Only set visible the ones that should be visible, but how? // Only set visible the ones that should be visible, but how?
Q_FOREACH(DiveEventItem * event, eventItems) { Q_FOREACH(DiveEventItem * event, eventItems) {
event->setVisible(true); event->setVisible(!event->shouldBeHidden());
// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds; // qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds << "is hidden:" << event->isHidden();
} }
diveComputerText->setText(currentdc->model); diveComputerText->setText(currentdc->model);
if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1){ if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1){