aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-11-26 18:07:08 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-26 12:28:16 -0800
commitc94101dd4fc6a92e0039aa4649f17db5f652c766 (patch)
tree7e125d0a67c1a7860b560a74570808be3f699d94
parent97fd22b1be8370ae2bebfaa8054fd7636ad829f6 (diff)
downloadsubsurface-c94101dd4fc6a92e0039aa4649f17db5f652c766.tar.gz
Changing the preferences should update the Add Dive interface
Since all internal units are in mm we needed to only update what's shown on the interface. Fixes #299 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/diveplanner.cpp33
-rw-r--r--qt-ui/diveplanner.h6
-rw-r--r--qt-ui/mainwindow.cpp2
3 files changed, 19 insertions, 22 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 0c17488e4..e9a19ffea 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -112,6 +112,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
depthLine->setColor(getColor(DEPTH_GRID));
depthLine->setTextColor(getColor(SAMPLE_DEEP));
depthLine->updateTicks();
+ depthLine->unitSystem = prefs.units.length;
scene()->addItem(depthLine);
timeString = new QGraphicsSimpleTextItem();
@@ -183,6 +184,16 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
setRenderHint(QPainter::Antialiasing);
}
+void DivePlannerGraphics::settingsChanged()
+{
+ if (depthLine->unitSystem == prefs.units.length)
+ return;
+
+ depthLine->setTickInterval(M_OR_FT(10,30));
+ depthLine->updateTicks();
+ depthLine->unitSystem = prefs.units.length;
+}
+
void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , int end)
{
DiveHandler *item = new DiveHandler ();
@@ -788,7 +799,7 @@ void Ruler::updateTicks()
if (orientation == Qt::Horizontal) {
double stepSize = (m.x2() - m.x1()) / steps;
- for (pos = m.x1(); pos < m.x2(); pos += stepSize, currValue += interval) {
+ for (pos = m.x1(); pos <= m.x2(); pos += stepSize, currValue += interval) {
item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this);
item->setPen(pen());
ticks.push_back(item);
@@ -799,18 +810,9 @@ void Ruler::updateTicks()
label->setPos(pos - label->boundingRect().width()/2, m.y1() + tickSize + 5);
labels.push_back(label);
}
- item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this);
- item->setPen(pen());
- ticks.push_back(item);
-
- label = new QGraphicsSimpleTextItem(QString::number(currValue), this);
- label->setBrush(QBrush(textColor));
- label->setFlag(ItemIgnoresTransformations);
- label->setPos(pos - label->boundingRect().width()/2, m.y1() + tickSize + 5);
- labels.push_back(label);
} else {
double stepSize = (m.y2() - m.y1()) / steps;
- for (pos = m.y1(); pos < m.y2(); pos += stepSize, currValue += interval) {
+ for (pos = m.y1(); pos <= m.y2(); pos += stepSize, currValue += interval) {
item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this);
item->setPen(pen());
ticks.push_back(item);
@@ -821,15 +823,6 @@ void Ruler::updateTicks()
label->setPos(m.x2() - 80, pos);
labels.push_back(label);
}
- item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this);
- item->setPen(pen());
- ticks.push_back(item);
-
- label = new QGraphicsSimpleTextItem(get_depth_string(currValue, false, false), this);
- label->setBrush(QBrush(textColor));
- label->setFlag(ItemIgnoresTransformations);
- label->setPos(m.x2() - 80, pos);
- labels.push_back(label);
}
}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index c7ebe4a3a..81e36b02c 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -62,11 +62,9 @@ public slots:
void deleteTemporaryPlan();
void loadFromDive(dive* d);
void restoreBackupDive();
-
signals:
void planCreated();
void planCanceled();
-
private:
explicit DivePlannerPointsModel(QObject* parent = 0);
bool addGas(int o2, int he);
@@ -140,6 +138,8 @@ public:
qreal posAtValue(qreal value);
void setColor(const QColor& color);
void setTextColor(const QColor& color);
+ int unitSystem;
+
private:
Qt::Orientation orientation;
QList<QGraphicsLineItem*> ticks;
@@ -166,6 +166,8 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent* event);
bool isPointOutOfBoundaries(const QPointF& point);
qreal fromPercent(qreal percent, Qt::Orientation orientation);
+public slots:
+ void settingsChanged();
private slots:
void keyEscAction();
void keyDeleteAction();
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 85047847b..67ec07e75 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -54,6 +54,7 @@ MainWindow::MainWindow() : helpView(0)
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo()));
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlanner, SLOT(settingsChanged()));
ui.mainErrorMessage->hide();
initialUiSetup();
@@ -64,6 +65,7 @@ MainWindow::MainWindow() : helpView(0)
ui.globe->reload();
ui.ListWidget->expand(ui.ListWidget->model()->index(0,0));
ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter);
+ ui.divePlanner->settingsChanged();
}
// this gets called after we download dives from a divecomputer