mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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()),
|
rulerItem(new RulerItem2()),
|
||||||
#endif
|
#endif
|
||||||
tankItem(new TankItem(*timeAxis)),
|
tankItem(new TankItem(*timeAxis)),
|
||||||
shouldCalculateMaxTime(true),
|
shouldCalculateMax(true),
|
||||||
shouldCalculateMaxDepth(true),
|
|
||||||
fontPrintScale(1.0)
|
fontPrintScale(1.0)
|
||||||
{
|
{
|
||||||
init_plot_info(&plotInfo);
|
init_plot_info(&plotInfo);
|
||||||
|
@ -568,12 +567,12 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
// 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;
|
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
|
#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
|
#endif
|
||||||
int newMaxtime = get_maxtime(&plotInfo);
|
int newMaxtime = get_maxtime(&plotInfo);
|
||||||
if (shouldCalculateMaxTime || newMaxtime > maxtime)
|
if (shouldCalculateMax || newMaxtime > maxtime)
|
||||||
maxtime = newMaxtime;
|
maxtime = newMaxtime;
|
||||||
|
|
||||||
/* Only update the max. depth if it's bigger than the current ones
|
/* 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.
|
* otherwhise, update normally.
|
||||||
*/
|
*/
|
||||||
int newMaxDepth = get_maxdepth(&plotInfo);
|
int newMaxDepth = get_maxdepth(&plotInfo);
|
||||||
if (!shouldCalculateMaxDepth) {
|
if (!shouldCalculateMax) {
|
||||||
if (maxdepth < newMaxDepth) {
|
if (maxdepth < newMaxDepth) {
|
||||||
maxdepth = newMaxDepth;
|
maxdepth = newMaxDepth;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +625,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
||||||
percentageAxis->setVisible(false);
|
percentageAxis->setVisible(false);
|
||||||
percentageAxis->updateTicks(HR_AXIS);
|
percentageAxis->updateTicks(HR_AXIS);
|
||||||
#endif
|
#endif
|
||||||
if (shouldCalculateMaxTime)
|
if (shouldCalculateMax)
|
||||||
timeAxis->setMaximum(maxtime);
|
timeAxis->setMaximum(maxtime);
|
||||||
int i, incr;
|
int i, incr;
|
||||||
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
|
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;
|
return;
|
||||||
QGraphicsView::mousePressEvent(event);
|
QGraphicsView::mousePressEvent(event);
|
||||||
if (currentState == PLAN || currentState == EDIT)
|
if (currentState == PLAN || currentState == EDIT)
|
||||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = false;
|
shouldCalculateMax = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::divePlannerHandlerClicked()
|
void ProfileWidget2::divePlannerHandlerClicked()
|
||||||
{
|
{
|
||||||
if (zoomLevel)
|
if (zoomLevel)
|
||||||
return;
|
return;
|
||||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = false;
|
shouldCalculateMax = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::divePlannerHandlerReleased()
|
void ProfileWidget2::divePlannerHandlerReleased()
|
||||||
{
|
{
|
||||||
if (zoomLevel)
|
if (zoomLevel)
|
||||||
return;
|
return;
|
||||||
shouldCalculateMaxDepth = shouldCalculateMaxTime = true;
|
shouldCalculateMax = true;
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,7 +889,7 @@ void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
QGraphicsView::mouseReleaseEvent(event);
|
QGraphicsView::mouseReleaseEvent(event);
|
||||||
if (currentState == PLAN || currentState == EDIT) {
|
if (currentState == PLAN || currentState == EDIT) {
|
||||||
shouldCalculateMaxTime = shouldCalculateMaxDepth = true;
|
shouldCalculateMax = true;
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,8 +253,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
friend class DiveHandler;
|
friend class DiveHandler;
|
||||||
QHash<Qt::Key, QAction *> actionsForKeys;
|
QHash<Qt::Key, QAction *> actionsForKeys;
|
||||||
bool shouldCalculateMaxTime;
|
bool shouldCalculateMax; // Calculate maximum time and depth (default). False when dragging handles.
|
||||||
bool shouldCalculateMaxDepth;
|
|
||||||
int maxtime;
|
int maxtime;
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
double fontPrintScale;
|
double fontPrintScale;
|
||||||
|
|
Loading…
Add table
Reference in a new issue