summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-11-14 17:39:35 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-15 09:19:14 +0900
commit96d5687ab89edd7163493faf212ddcb119e93d8c (patch)
tree6d3d148d776a134172d612fa13fe00223aaecdbc /qt-ui/diveplanner.cpp
parentb77d990ed6892081f7c1e0df62631b57aad3b59f (diff)
downloadsubsurface-96d5687ab89edd7163493faf212ddcb119e93d8c.tar.gz
Correctly handle changes on the CylinderModel to update the AirModel.
What happened before was that the AirTypes model was only being updated when the user requested to change the air by clicking directly on the Air, in the planner ( but not on the Air Table. ). This fixes it by calling 'repopulate' whenever the cylinder model changes ( by adding, removing and changing something.) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index b0f3e901e..9bbce05f4 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -32,13 +32,6 @@
#define M_OR_FT(_m,_f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : ((_f) * 304.8))
-QStringListModel *gasSelectionModel() {
- static QStringListModel *self = new QStringListModel(QStringList()
- << QObject::tr("AIR"));
- self->setStringList(DivePlannerPointsModel::instance()->getGasList());
- return self;
-}
-
QString gasToStr(const int o2Permille, const int hePermille) {
uint o2 = (o2Permille + 5) / 10, he = (hePermille + 5) / 10;
QString result = is_air(o2Permille, hePermille) ? QObject::tr("AIR")
@@ -175,7 +168,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
// Prepare the stuff for the gas-choices.
gasListView = new QListView();
gasListView->setWindowFlags(Qt::Popup);
- gasListView->setModel(gasSelectionModel());
+ gasListView->setModel(GasSelectionModel::instance());
gasListView->hide();
gasListView->installEventFilter(this);
@@ -490,7 +483,6 @@ void DivePlannerGraphics::prepareSelectGas()
currentGasChoice = static_cast<Button*>(sender());
QPoint c = QCursor::pos();
gasListView->setGeometry(c.x(), c.y(), 150, 100);
- model->setStringList(DivePlannerPointsModel::instance()->getGasList());
gasListView->show();
}
@@ -931,6 +923,14 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
+
+ connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ GasSelectionModel::instance(), SLOT(repopulate()));
+ connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex,int,int)),
+ GasSelectionModel::instance(), SLOT(repopulate()));
+ connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ GasSelectionModel::instance(), SLOT(repopulate()));
+
ui.tableWidget->setBtnToolTip(tr("add dive data point"));
connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime)));
connect(ui.ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));