summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-29 10:31:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-29 10:31:34 -0700
commitccaff3a06da9c638cd1088329e10944320e1f66e (patch)
tree99b2be63f037add694d95b2a8e0bda16996e9ac2 /qt-ui
parenta4608f7c91138401e9987ff0478bbe42408a37a7 (diff)
downloadsubsurface-ccaff3a06da9c638cd1088329e10944320e1f66e.tar.gz
Make gradient factor text an independent item on the profile
Having it as part of the DiveCalculatedCeiling class caused us to manage this text 17 times (and plotting it 17 times) which is rather silly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp14
-rw-r--r--qt-ui/profile/diveprofileitem.h1
-rw-r--r--qt-ui/profile/profilewidget2.cpp17
-rw-r--r--qt-ui/profile/profilewidget2.h1
4 files changed, 18 insertions, 15 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 5ae46003c..986a0eac0 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -788,11 +788,8 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
painter->restore();
}
-DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientFactor(new DiveTextItem(this))
+DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false)
{
- gradientFactor->setY(0);
- gradientFactor->setBrush(getColor(PRESSURE_TEXT));
- gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
settingsChanged();
}
@@ -821,15 +818,6 @@ void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const Q
pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
setPen(QPen(QBrush(Qt::NoBrush), 0));
setBrush(pat);
-
- gradientFactor->setX(poly.boundingRect().width() / 2 + poly.boundingRect().x());
- DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
- if (plannerModel->isPlanner()) {
- struct diveplan &diveplan = plannerModel->getDiveplan();
- gradientFactor->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
- } else {
- gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
- }
}
void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 81e5bf4c8..2160782f7 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -187,7 +187,6 @@ slots:
private:
bool is3mIncrement;
- DiveTextItem *gradientFactor;
};
class DiveReportedCeiling : public AbstractProfilePolygonItem {
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index d422f93f5..76fcd48e0 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -87,6 +87,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
gasPressureItem(new DiveGasPressureItem()),
diveComputerText(new DiveTextItem()),
diveCeiling(new DiveCalculatedCeiling()),
+ gradientFactor(new DiveTextItem()),
reportedCeiling(new DiveReportedCeiling()),
pn2GasItem(new PartialPressureGasItem()),
pheGasItem(new PartialPressureGasItem()),
@@ -200,6 +201,7 @@ void ProfileWidget2::addItemsToScene()
diveComputerText->setData(SUBSURFACE_OBJ_DATA, SUBSURFACE_OBJ_DC_TEXT);
scene()->addItem(diveComputerText);
scene()->addItem(diveCeiling);
+ scene()->addItem(gradientFactor);
scene()->addItem(reportedCeiling);
scene()->addItem(pn2GasItem);
scene()->addItem(pheGasItem);
@@ -283,6 +285,12 @@ void ProfileWidget2::setupItemOnScene()
rulerItem->setAxis(timeAxis, profileYAxis);
tankItem->setHorizontalAxis(timeAxis);
+ // show the gradient factor at the top in the center
+ gradientFactor->setY(0);
+ gradientFactor->setX(50);
+ gradientFactor->setBrush(getColor(PRESSURE_TEXT));
+ gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
+
setupItem(reportedCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
setupItem(diveCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
for (int i = 0; i < 16; i++) {
@@ -489,13 +497,16 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
// this copies the dive and makes copies of all the relevant additional data
copy_dive(d, &displayed_dive);
+ gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
} else {
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
plannerModel->createTemporaryPlan();
- if (!plannerModel->getDiveplan().dp) {
+ struct diveplan &diveplan = plannerModel->getDiveplan();
+ if (!diveplan.dp) {
plannerModel->deleteTemporaryPlan();
return;
}
+ gradientFactor->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
}
// special handling for the first time we display things
@@ -894,6 +905,7 @@ void ProfileWidget2::setEmptyState()
toolTipItem->setVisible(false);
diveComputerText->setVisible(false);
diveCeiling->setVisible(false);
+ gradientFactor->setVisible(false);
reportedCeiling->setVisible(false);
rulerItem->setVisible(false);
tankItem->setVisible(false);
@@ -1020,6 +1032,7 @@ void ProfileWidget2::setProfileState()
diveComputerText->setPos(itemPos.dcLabel.on);
diveCeiling->setVisible(prefs.calcceiling);
+ gradientFactor->setVisible(prefs.calcceiling);
reportedCeiling->setVisible(prefs.dcceiling);
if (prefs.calcalltissues) {
@@ -1097,6 +1110,7 @@ void ProfileWidget2::setAddState()
/* show the same stuff that the profile shows. */
currentState = ADD; /* enable the add state. */
diveCeiling->setVisible(true);
+ gradientFactor->setVisible(true);
setBackgroundBrush(QColor("#A7DCFF"));
}
@@ -1130,6 +1144,7 @@ void ProfileWidget2::setPlanState()
/* show the same stuff that the profile shows. */
currentState = PLAN; /* enable the add state. */
diveCeiling->setVisible(true);
+ gradientFactor->setVisible(true);
setBackgroundBrush(QColor("#D7E3EF"));
}
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index a25780c7e..75d072dac 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -167,6 +167,7 @@ private:
QList<DiveEventItem *> eventItems;
DiveTextItem *diveComputerText;
DiveCalculatedCeiling *diveCeiling;
+ DiveTextItem *gradientFactor;
QList<DiveCalculatedTissue *> allTissues;
DiveReportedCeiling *reportedCeiling;
PartialPressureGasItem *pn2GasItem;