diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-08-30 16:08:55 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-08-30 16:08:55 -0300 |
commit | 72807017aeb4fb9db36e5c160ef6d6f89200590e (patch) | |
tree | 9b8592c91efc2daf2b7431b91e43ca80bcecea3e /qt-ui/diveplanner.cpp | |
parent | d37213a413d8b460aba0363879a162af8bf0a47e (diff) | |
download | subsurface-72807017aeb4fb9db36e5c160ef6d6f89200590e.tar.gz |
Make planned points deletion works on the Table too.
Now the planner deletes points by clicking on the
trash icon on the table. The dive planner is almost
finished. <3
next: add a point from the table.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 1dce675c1..9ff47792c 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -284,12 +284,6 @@ void DivePlannerGraphics::keyDeleteAction() { int selCount = scene()->selectedItems().count(); if(selCount){ - - while(selCount--){ - Button *btn = gases.takeLast(); - delete btn; - } - QVector<int> selectedIndexes; Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ @@ -307,8 +301,11 @@ void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end) for(int i = num; i != 0; i--){ delete handles.back(); handles.pop_back(); + delete gases.back(); + gases.pop_back(); } scene()->clearSelection(); + createDecoStops(); } bool intLessThan(int a, int b){ @@ -853,6 +850,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge ui->setupUi(this); ui->tablePoints->setModel(DivePlannerPointsModel::instance()); ui->tablePoints->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this)); + + connect(ui->tablePoints, SIGNAL(clicked(QModelIndex)), plannerModel, SLOT(removePoint(const QModelIndex))); connect(ui->startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime))); connect(ui->ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString))); connect(ui->bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString))); @@ -1095,3 +1094,13 @@ divedatapoint DivePlannerPointsModel::at(int row) { return divepoints.at(row); } + +void DivePlannerPointsModel::removePoint(const QModelIndex& index) +{ + if (index.column() != REMOVE) + return; + + beginRemoveRows(QModelIndex(), index.row(), index.row()); + divepoints.remove(index.row()); + endRemoveRows(); +} |