UI restructure: plotDive should just take one dive

We don't have a concept of what to do when plotting multiple dives, so
let's not pretend and remove all the messing around with lists.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-07-02 12:03:40 -07:00
parent a221a6e9f5
commit 91086d08ad
4 changed files with 8 additions and 15 deletions

View file

@ -175,13 +175,7 @@ void MainWindow::current_dive_changed(int divenr)
select_dive(divenr); select_dive(divenr);
ui.globe->centerOnCurrentDive(); ui.globe->centerOnCurrentDive();
} }
ui.newProfile->plotDive(current_dive);
/* It looks like it's a bit too cumberstone to send *one* dive using a QList,
* but this is just futureproofness, it's the best way in the future to show more than
* a single profile plot on the canvas. I know that we are using only one right now,
* but let's keep like this so it's easy to change when we need? :)
*/
ui.newProfile->plotDives(QList<dive *>() << (current_dive));
ui.InfoWidget->updateDiveInfo(divenr); ui.InfoWidget->updateDiveInfo(divenr);
} }
@ -656,16 +650,16 @@ void MainWindow::on_actionPreviousDC_triggered()
{ {
unsigned nrdc = number_of_computers(current_dive); unsigned nrdc = number_of_computers(current_dive);
dc_number = (dc_number + nrdc - 1) % nrdc; dc_number = (dc_number + nrdc - 1) % nrdc;
ui.newProfile->plotDive(current_dive);
ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->updateDiveInfo(selected_dive);
ui.newProfile->plotDives(QList<struct dive *>() << (current_dive));
} }
void MainWindow::on_actionNextDC_triggered() void MainWindow::on_actionNextDC_triggered()
{ {
unsigned nrdc = number_of_computers(current_dive); unsigned nrdc = number_of_computers(current_dive);
dc_number = (dc_number + 1) % nrdc; dc_number = (dc_number + 1) % nrdc;
ui.newProfile->plotDive(current_dive);
ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->updateDiveInfo(selected_dive);
ui.newProfile->plotDives(QList<struct dive *>() << (current_dive));
} }
void MainWindow::on_actionFullScreen_triggered(bool checked) void MainWindow::on_actionFullScreen_triggered(bool checked)

View file

@ -183,7 +183,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
// draw a profile // draw a profile
painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetProfile); painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetProfile);
profile->plotDives(QList<struct dive *>() << dive); profile->plotDive(dive);
profile->render(&painter, QRect(0, 0, scaledW, scaledH - tableH - padPT)); profile->render(&painter, QRect(0, 0, scaledW, scaledH - tableH - padPT));
painter.setTransform(origTransform); painter.setTransform(origTransform);
@ -202,7 +202,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
profile->setFrameStyle(profileFrameStyle); profile->setFrameStyle(profileFrameStyle);
profile->setPrintMode(false); profile->setPrintMode(false);
profile->resize(originalSize); profile->resize(originalSize);
profile->plotDives(QList<struct dive *>() << current_dive); profile->plotDive(current_dive);
} }
/* we create a table that has a fixed height, but can stretch to fit certain width */ /* we create a table that has a fixed height, but can stretch to fit certain width */

View file

@ -255,7 +255,7 @@ void ProfileWidget2::replot()
{ {
int diveId = dataModel->id(); int diveId = dataModel->id();
dataModel->clear(); dataModel->clear();
plotDives(QList<dive *>() << get_dive_by_uniq_id(diveId)); plotDive(get_dive_by_uniq_id(diveId)); // why are we doing the get diveId here???
} }
void ProfileWidget2::setupItemSizes() void ProfileWidget2::setupItemSizes()
@ -354,7 +354,7 @@ void ProfileWidget2::setupSceneAndFlags()
} }
// Currently just one dive, but the plan is to enable All of the selected dives. // Currently just one dive, but the plan is to enable All of the selected dives.
void ProfileWidget2::plotDives(QList<dive *> dives) void ProfileWidget2::plotDive(struct dive *d)
{ {
static bool firstCall = true; static bool firstCall = true;
QTime measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later QTime measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later
@ -362,7 +362,6 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
// I Know that it's a list, but currently we are // I Know that it's a list, but currently we are
// using just the first. // using just the first.
struct dive *d = dives.first();
if (!d) if (!d)
return; return;

View file

@ -67,7 +67,7 @@ public:
}; };
ProfileWidget2(QWidget *parent = 0); ProfileWidget2(QWidget *parent = 0);
void plotDives(QList<dive *> dives); void plotDive(struct dive *d);
virtual bool eventFilter(QObject *, QEvent *); virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
void setPrintMode(bool mode, bool grayscale = false); void setPrintMode(bool mode, bool grayscale = false);