mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
cd65c8512d
commit
2a55e55868
4 changed files with 27 additions and 24 deletions
|
@ -175,7 +175,7 @@ void MainWindow::current_dive_changed(int divenr)
|
|||
select_dive(divenr);
|
||||
ui.globe->centerOnCurrentDive();
|
||||
}
|
||||
ui.newProfile->plotDive(current_dive);
|
||||
ui.newProfile->plotDive();
|
||||
ui.InfoWidget->updateDiveInfo(divenr);
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ void MainWindow::on_actionPreviousDC_triggered()
|
|||
{
|
||||
unsigned nrdc = number_of_computers(current_dive);
|
||||
dc_number = (dc_number + nrdc - 1) % nrdc;
|
||||
ui.newProfile->plotDive(current_dive);
|
||||
ui.newProfile->plotDive();
|
||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ void MainWindow::on_actionNextDC_triggered()
|
|||
{
|
||||
unsigned nrdc = number_of_computers(current_dive);
|
||||
dc_number = (dc_number + 1) % nrdc;
|
||||
ui.newProfile->plotDive(current_dive);
|
||||
ui.newProfile->plotDive();
|
||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
|||
profile->setFrameStyle(profileFrameStyle);
|
||||
profile->setPrintMode(false);
|
||||
profile->resize(originalSize);
|
||||
profile->plotDive(current_dive);
|
||||
profile->plotDive();
|
||||
}
|
||||
|
||||
/* we create a table that has a fixed height, but can stretch to fit certain width */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue