From de2f5d9e607efa4dadff63aa69553e6fb5571337 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 26 Aug 2013 14:54:07 -0300 Subject: 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 --- qt-ui/diveplanner.cpp | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'qt-ui/diveplanner.cpp') 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); -- cgit v1.2.3-70-g09d2