mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
97fd22b1be
commit
c94101dd4f
3 changed files with 19 additions and 22 deletions
|
@ -112,6 +112,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
depthLine->setColor(getColor(DEPTH_GRID));
|
depthLine->setColor(getColor(DEPTH_GRID));
|
||||||
depthLine->setTextColor(getColor(SAMPLE_DEEP));
|
depthLine->setTextColor(getColor(SAMPLE_DEEP));
|
||||||
depthLine->updateTicks();
|
depthLine->updateTicks();
|
||||||
|
depthLine->unitSystem = prefs.units.length;
|
||||||
scene()->addItem(depthLine);
|
scene()->addItem(depthLine);
|
||||||
|
|
||||||
timeString = new QGraphicsSimpleTextItem();
|
timeString = new QGraphicsSimpleTextItem();
|
||||||
|
@ -183,6 +184,16 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
setRenderHint(QPainter::Antialiasing);
|
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)
|
void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , int end)
|
||||||
{
|
{
|
||||||
DiveHandler *item = new DiveHandler ();
|
DiveHandler *item = new DiveHandler ();
|
||||||
|
@ -788,7 +799,7 @@ void Ruler::updateTicks()
|
||||||
|
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal) {
|
||||||
double stepSize = (m.x2() - m.x1()) / steps;
|
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 = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this);
|
||||||
item->setPen(pen());
|
item->setPen(pen());
|
||||||
ticks.push_back(item);
|
ticks.push_back(item);
|
||||||
|
@ -799,18 +810,9 @@ void Ruler::updateTicks()
|
||||||
label->setPos(pos - label->boundingRect().width()/2, m.y1() + tickSize + 5);
|
label->setPos(pos - label->boundingRect().width()/2, m.y1() + tickSize + 5);
|
||||||
labels.push_back(label);
|
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 {
|
} else {
|
||||||
double stepSize = (m.y2() - m.y1()) / steps;
|
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 = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this);
|
||||||
item->setPen(pen());
|
item->setPen(pen());
|
||||||
ticks.push_back(item);
|
ticks.push_back(item);
|
||||||
|
@ -821,15 +823,6 @@ void Ruler::updateTicks()
|
||||||
label->setPos(m.x2() - 80, pos);
|
label->setPos(m.x2() - 80, pos);
|
||||||
labels.push_back(label);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,9 @@ public slots:
|
||||||
void deleteTemporaryPlan();
|
void deleteTemporaryPlan();
|
||||||
void loadFromDive(dive* d);
|
void loadFromDive(dive* d);
|
||||||
void restoreBackupDive();
|
void restoreBackupDive();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void planCreated();
|
void planCreated();
|
||||||
void planCanceled();
|
void planCanceled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DivePlannerPointsModel(QObject* parent = 0);
|
explicit DivePlannerPointsModel(QObject* parent = 0);
|
||||||
bool addGas(int o2, int he);
|
bool addGas(int o2, int he);
|
||||||
|
@ -140,6 +138,8 @@ public:
|
||||||
qreal posAtValue(qreal value);
|
qreal posAtValue(qreal value);
|
||||||
void setColor(const QColor& color);
|
void setColor(const QColor& color);
|
||||||
void setTextColor(const QColor& color);
|
void setTextColor(const QColor& color);
|
||||||
|
int unitSystem;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
QList<QGraphicsLineItem*> ticks;
|
QList<QGraphicsLineItem*> ticks;
|
||||||
|
@ -166,6 +166,8 @@ protected:
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* event);
|
virtual void mouseReleaseEvent(QMouseEvent* event);
|
||||||
bool isPointOutOfBoundaries(const QPointF& point);
|
bool isPointOutOfBoundaries(const QPointF& point);
|
||||||
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
||||||
|
public slots:
|
||||||
|
void settingsChanged();
|
||||||
private slots:
|
private slots:
|
||||||
void keyEscAction();
|
void keyEscAction();
|
||||||
void keyDeleteAction();
|
void keyDeleteAction();
|
||||||
|
|
|
@ -54,6 +54,7 @@ MainWindow::MainWindow() : helpView(0)
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh()));
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo()));
|
||||||
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlanner, SLOT(settingsChanged()));
|
||||||
|
|
||||||
ui.mainErrorMessage->hide();
|
ui.mainErrorMessage->hide();
|
||||||
initialUiSetup();
|
initialUiSetup();
|
||||||
|
@ -64,6 +65,7 @@ MainWindow::MainWindow() : helpView(0)
|
||||||
ui.globe->reload();
|
ui.globe->reload();
|
||||||
ui.ListWidget->expand(ui.ListWidget->model()->index(0,0));
|
ui.ListWidget->expand(ui.ListWidget->model()->index(0,0));
|
||||||
ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter);
|
ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter);
|
||||||
|
ui.divePlanner->settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this gets called after we download dives from a divecomputer
|
// this gets called after we download dives from a divecomputer
|
||||||
|
|
Loading…
Add table
Reference in a new issue