aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-26 14:54:07 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-26 14:54:07 -0300
commitde2f5d9e607efa4dadff63aa69553e6fb5571337 (patch)
treeb2f139b52d2afe1a44c309b9a89331dc27516615
parentbc71f9a9160cd704e6a01e5485cadba950d758e9 (diff)
downloadsubsurface-de2f5d9e607efa4dadff63aa69553e6fb5571337.tar.gz
Moving Handler on Graphics Updates the Model on the Planner
Moving the handler on the graphics updates the model on the planner Unfortunately, the graphics will move back to it's original position because of the legacy code used to calculate the dive plan. Next: fix the legacy code used to calculate the dive plan. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r--qt-ui/diveplanner.cpp40
-rw-r--r--qt-ui/diveplanner.h1
2 files changed, 15 insertions, 26 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 94b1c05f7..eb4d4e91f 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -367,31 +367,7 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
int minutes = rint(timeLine->valueAt(mappedPos));
int meters = rint(depthLine->valueAt(mappedPos));
-
-// Q_FOREACH(DiveHandler* handler, handles){
-// if (xpos == handler->pos().x()){
-// qDebug() << "There's already an point at that place.";
-// //TODO: Move this later to a KMessageWidget.
-// return;
-// }
-// }
-
DivePlannerPointsModel::instance()->addStop(meters, minutes, tr("Air"), 0);
-// DiveHandler *item = new DiveHandler ();
-// item->sec = minutes * 60;
-// item->mm = meters * 1000;
-// item->setPos(QPointF(xpos, ypos));
-// scene()->addItem(item);
-// handles << item;
-//
-// Button *gasChooseBtn = new Button();
-// gasChooseBtn ->setText(tr("Air"));
-// scene()->addItem(gasChooseBtn);
-// gasChooseBtn->setZValue(10);
-// connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(prepareSelectGas()));
-//
-// gases << gasChooseBtn;
-// createDecoStops();
}
void DivePlannerGraphics::prepareSelectGas()
@@ -633,8 +609,14 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
}
}
- activeDraggedHandler->sec = rint(timeLine->valueAt(mappedPos)) * 60;
- activeDraggedHandler->mm = rint(depthLine->valueAt(mappedPos)) * 1000;
+ int pos = handles.indexOf(activeDraggedHandler);
+ divedatapoint data = DivePlannerPointsModel::instance()->at(pos);
+
+ data.depth = rint(depthLine->valueAt(mappedPos));
+ data.time = rint(timeLine->valueAt(mappedPos));
+
+ DivePlannerPointsModel::instance()->editStop(pos, data);
+
activeDraggedHandler->setBrush(QBrush(Qt::white));
activeDraggedHandler->setPos(QPointF(xpos, ypos));
@@ -964,6 +946,12 @@ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas,
return row;
}
+void DivePlannerPointsModel::editStop(int row, divedatapoint newData)
+{
+ divepoints[row] = newData;
+ emit dataChanged(createIndex(row, 0), createIndex(row, COLUMNS-1));
+}
+
divedatapoint DivePlannerPointsModel::at(int row)
{
return divepoints.at(row);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index e8951b682..9174401fc 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -31,6 +31,7 @@ public:
* @return the row number.
*/
int addStop(int meters, int minutes,const QString& gas, int ccpoint );
+ void editStop(int row, divedatapoint newData );
divedatapoint at(int row);
public slots:
void setGFHigh(short gfhigh);