summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-02 20:00:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-03 09:37:54 -0700
commit2a55e55868870731258fe2230321ed23bc0cbaed (patch)
tree052a56c9fa7c90ee6ec8174c01d162242ee31743 /qt-ui/profile
parentcd65c8512d2eda8177a44324ec1afd771f733236 (diff)
downloadsubsurface-2a55e55868870731258fe2230321ed23bc0cbaed.tar.gz
UI restructure: plotDive: plot current dive by default & use displayed_dive
No longer use the dive structure that is passed in but instead always use the displayed_dive to display things. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/profilewidget2.cpp41
-rw-r--r--qt-ui/profile/profilewidget2.h2
2 files changed, 23 insertions, 20 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index b4e9c6997..f9f019542 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -255,7 +255,7 @@ void ProfileWidget2::replot()
{
int diveId = dataModel->id();
dataModel->clear();
- plotDive(get_dive_by_uniq_id(diveId)); // why are we doing the get diveId here???
+ plotDive(); // simply plot the displayed_dive again
}
void ProfileWidget2::setupItemSizes()
@@ -360,11 +360,24 @@ void ProfileWidget2::plotDive(struct dive *d)
QTime measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later
measureDuration.start();
- // I Know that it's a list, but currently we are
- // using just the first.
- if (!d)
+ if (!d) {
+ if (selected_dive == -1)
+ return;
+ d = current_dive; // display the current dive
+ }
+
+ // No need to do this again if we are already showing the same dive
+ // computer of the same dive, so we check the unique id of the dive
+ // and the selected dive computer number against the ones we are
+ // showing (can't compare the dive pointers as those might change).
+ if (d->id == dataModel->id() && dc_number == dataModel->dcShown() && !forceReplot)
return;
+ forceReplot = false;
+
+ // this copies the dive and makes copies of all the relevant additional data
+ copy_dive(d, &displayed_dive);
+
//TODO: This is a temporary hack to help me understand the Planner.
// It seems that each time the 'createTemporaryPlan' runs, a new
// dive is created, and thus, we can plot that. hm...
@@ -378,6 +391,7 @@ void ProfileWidget2::plotDive(struct dive *d)
}
//END
+ // special handling for the first time we display things
int animSpeedBackup = -1;
if (firstCall && MainWindow::instance()->filesFromCommandLine()) {
animSpeedBackup = prefs.animation;
@@ -396,24 +410,13 @@ void ProfileWidget2::plotDive(struct dive *d)
toolTipItem->setVisible(!printMode);
rulerItem->setVisible(prefs.rulergraph && !printMode);
- // No need to do this again if we are already showing the same dive
- // computer of the same dive, so we check the unique id of the dive
- // and the selected dive computer number against the ones we are
- // showing (can't compare the dive pointers as those might change).
- // I'm unclear what the semantics are supposed to be if we actually
- // use more than one 'dives' as argument - so ignoring that right now :-)
- if (d->id == dataModel->id() && dc_number == dataModel->dcShown() &&
- !forceReplot)
- return;
-
- forceReplot = false;
if (currentState == EMPTY)
setProfileState();
// next get the dive computer structure - if there are no samples
// let's create a fake profile that's somewhat reasonable for the
// data that we have
- struct divecomputer *currentdc = select_dc(d);
+ struct divecomputer *currentdc = select_dc(&displayed_dive);
Q_ASSERT(currentdc);
if (!currentdc || !currentdc->samples) {
currentdc = fake_dc(currentdc);
@@ -426,8 +429,8 @@ void ProfileWidget2::plotDive(struct dive *d)
* so I'll *not* calculate everything if something is not being
* shown.
*/
- struct plot_info pInfo = calculate_max_limits_new(d, currentdc);
- create_plot_info_new(d, currentdc, &pInfo);
+ struct plot_info pInfo = calculate_max_limits_new(&displayed_dive, currentdc);
+ create_plot_info_new(&displayed_dive, currentdc, &pInfo);
if(shouldCalculateMaxTime)
maxtime = get_maxtime(&pInfo);
@@ -444,7 +447,7 @@ void ProfileWidget2::plotDive(struct dive *d)
maxdepth = newMaxDepth;
}
- dataModel->setDive(d, pInfo);
+ dataModel->setDive(&displayed_dive, pInfo);
toolTipItem->setPlotInfo(pInfo);
// It seems that I'll have a lot of boilerplate setting the model / axis for
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index e2e63cb40..6ed132b38 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -67,7 +67,7 @@ public:
};
ProfileWidget2(QWidget *parent = 0);
- void plotDive(struct dive *d);
+ void plotDive(struct dive *d = 0);
virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
void setPrintMode(bool mode, bool grayscale = false);