mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
cleanup: unify the ProfileWidget2::shouldCalculateMax* variables
The shouldCalcluateMaxTime and shouldCalculateMaxDepth member variables of ProfileWidget2 are set to false during drag-mode to avoid strange shrinking of the graph. They always adopt the same value. Therefore, replace by a single shouldCalculateMax boolean. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
15c524804a
commit
f16a7c262e
2 changed files with 11 additions and 13 deletions
|
@ -138,8 +138,7 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, QWidget *
|
|||
rulerItem(new RulerItem2()),
|
||||
#endif
|
||||
tankItem(new TankItem(*timeAxis)),
|
||||
shouldCalculateMaxTime(true),
|
||||
shouldCalculateMaxDepth(true),
|
||||
shouldCalculateMax(true),
|
||||
fontPrintScale(1.0)
|
||||
{
|
||||
init_plot_info(&plotInfo);
|
||||
|
@ -568,12 +567,12 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
|||
#ifndef SUBSURFACE_MOBILE
|
||||
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
||||
struct deco_state *planner_ds = currentState == PLAN && plannerModel ? &plannerModel->final_deco_state : nullptr;
|
||||
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !shouldCalculateMaxDepth, planner_ds);
|
||||
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !shouldCalculateMax, planner_ds);
|
||||
#else
|
||||
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !shouldCalculateMaxDepth, nullptr);
|
||||
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !shouldCalculateMax, nullptr);
|
||||
#endif
|
||||
int newMaxtime = get_maxtime(&plotInfo);
|
||||
if (shouldCalculateMaxTime || newMaxtime > maxtime)
|
||||
if (shouldCalculateMax || newMaxtime > maxtime)
|
||||
maxtime = newMaxtime;
|
||||
|
||||
/* Only update the max. depth if it's bigger than the current ones
|
||||
|
@ -581,7 +580,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
|||
* otherwhise, update normally.
|
||||
*/
|
||||
int newMaxDepth = get_maxdepth(&plotInfo);
|
||||
if (!shouldCalculateMaxDepth) {
|
||||
if (!shouldCalculateMax) {
|
||||
if (maxdepth < newMaxDepth) {
|
||||
maxdepth = newMaxDepth;
|
||||
}
|
||||
|
@ -626,7 +625,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
|||
percentageAxis->setVisible(false);
|
||||
percentageAxis->updateTicks(HR_AXIS);
|
||||
#endif
|
||||
if (shouldCalculateMaxTime)
|
||||
if (shouldCalculateMax)
|
||||
timeAxis->setMaximum(maxtime);
|
||||
int i, incr;
|
||||
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
|
||||
|
@ -866,21 +865,21 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event)
|
|||
return;
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
if (currentState == PLAN || currentState == EDIT)
|
||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = false;
|
||||
shouldCalculateMax = false;
|
||||
}
|
||||
|
||||
void ProfileWidget2::divePlannerHandlerClicked()
|
||||
{
|
||||
if (zoomLevel)
|
||||
return;
|
||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = false;
|
||||
shouldCalculateMax = false;
|
||||
}
|
||||
|
||||
void ProfileWidget2::divePlannerHandlerReleased()
|
||||
{
|
||||
if (zoomLevel)
|
||||
return;
|
||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = true;
|
||||
shouldCalculateMax = true;
|
||||
replot();
|
||||
}
|
||||
|
||||
|
@ -890,7 +889,7 @@ void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
|
|||
return;
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
if (currentState == PLAN || currentState == EDIT) {
|
||||
shouldCalculateMaxTime = shouldCalculateMaxDepth = true;
|
||||
shouldCalculateMax = true;
|
||||
replot();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -253,8 +253,7 @@ private:
|
|||
#endif
|
||||
friend class DiveHandler;
|
||||
QHash<Qt::Key, QAction *> actionsForKeys;
|
||||
bool shouldCalculateMaxTime;
|
||||
bool shouldCalculateMaxDepth;
|
||||
bool shouldCalculateMax; // Calculate maximum time and depth (default). False when dragging handles.
|
||||
int maxtime;
|
||||
int maxdepth;
|
||||
double fontPrintScale;
|
||||
|
|
Loading…
Reference in a new issue