summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-30 13:27:15 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-30 13:27:15 -0300
commit2d0e877bb281733c94ac7f6d614914d7820c3af1 (patch)
treed9818ad2e748d300b4962380cde9e747bf263120
parent69903903d213e45fe16f3b5a6acb52278eee9291 (diff)
downloadsubsurface-2d0e877bb281733c94ac7f6d614914d7820c3af1.tar.gz
Added support for changing Depth and Time on the Table.
Added support for changing depth and time on the table. It now works both ways, one can edit the planner via the table for a fine tuning. :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r--qt-ui/diveplanner.cpp13
-rw-r--r--qt-ui/diveplanner.h4
2 files changed, 13 insertions, 4 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 63b8229ad..8629791bd 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -150,6 +150,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex)));
connect(DivePlannerPointsModel::instance(), SIGNAL(rowsInserted(const QModelIndex&,int,int)),
this, SLOT(pointInserted(const QModelIndex&, int, int)));
+ connect(DivePlannerPointsModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(createDecoStops()));
setRenderHint(QPainter::Antialiasing);
}
@@ -905,10 +906,10 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
if(role == Qt::DisplayRole){
divedatapoint p = divepoints.at(index.row());
switch(index.column()){
- case GAS: return tr("Air");
case CCSETPOINT: return 0;
case DEPTH: return p.depth / 1000;
case DURATION: return p.time / 60;
+ case GAS: return tr("Air");
}
}
if (role == Qt::DecorationRole){
@@ -921,6 +922,16 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
+ if(role == Qt::EditRole){
+ divedatapoint& p = divepoints[index.row()];
+ switch(index.column()){
+ case DEPTH: p.depth = value.toInt() * 1000; break;
+ case DURATION: p.time = value.toInt() * 60; break;
+ case CCSETPOINT: /* what do I do here? */
+ case GAS: break; /* what do I do here? */
+ }
+ editStop(index.row(), p);
+ }
return QAbstractItemModel::setData(index, value, role);
}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index afa9c0fca..ef5a8e50f 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -115,8 +115,6 @@ protected:
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
-
- void createDecoStops();
bool isPointOutOfBoundaries(const QPointF& point);
void deleteTemporaryDivePlan(struct divedatapoint* dp);
qreal fromPercent(qreal percent, Qt::Orientation orientation);
@@ -131,7 +129,7 @@ private slots:
void increaseDepth();
void decreaseTime();
void decreaseDepth();;
-
+ void createDecoStops();
void cancelPlan();
void prepareSelectGas();
void selectGas(const QModelIndex& index);