Hi,
so here is my attempt at these two problems. Please test! Best Robert |
From 5bc09aa1b21a129904547df78eebcf472f05925a Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Thu, 14 May 2015 23:33:48 +0200 Subject: [PATCH 1/2] Allow "oxygen" as a gas name
...as this what comes in when the user selects this gas in the add dive/dive planner contet menu. Signed-off-by: Robert C. Helling <[email protected]> --- planner.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/planner.c b/planner.c index ed7687e..92ddc84 100644 --- a/planner.c +++ b/planner.c @@ -1179,6 +1179,10 @@ int validate_gas(const char *text, struct gasmix *gas) o2 = O2_IN_AIR; he = 0; text += strlen(translate("gettextFromC", "air")); + } else if (!strcasecmp(text, translate("gettextFromC", "oxygen"))) { + o2 = 1000; + he = 0; + text += strlen(translate("gettextFromC", "oxygen")); } else if (!strncasecmp(text, translate("gettextFromC", "ean"), 3)) { o2 = get_permille(text + 3, &text); he = 0; -- 1.9.5 (Apple Git-50.3)
From 1b6ef1e0705272962784e9ed9e662ffef2aef194 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Thu, 14 May 2015 23:42:09 +0200 Subject: [PATCH 2/2] Make gaschange from contex menu act as a gaschange so it affect no longer the previous leg but all the following ones with the same gas (i.e. until the next gaschange). This makes the add dive/planner behaviour more consistent with the rest of the program regarding gas changes. Signed-off-by: Robert C. Helling <[email protected]> --- qt-ui/diveplanner.cpp | 14 +++++++++++++- qt-ui/diveplanner.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index a5fc512..c82bc04 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -241,7 +241,7 @@ void DiveHandler::changeGas() { QAction *action = qobject_cast<QAction *>(sender()); QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS); - plannerModel->setData(index, action->text()); + plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->text()); } void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) @@ -741,6 +741,18 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v return QAbstractItemModel::setData(index, value, role); } +void DivePlannerPointsModel::gaschange(const QModelIndex &index, QString newgas) +{ + int i = index.row(); + gasmix oldgas = divepoints[i].gasmix; + gasmix gas = { 0 }; + if (!validate_gas(newgas.toUtf8().data(), &gas)) + return; + while (i < plannerModel->rowCount() && gasmix_distance(&oldgas, &divepoints[i].gasmix) == 0) + divepoints[i++].gasmix = gas; + emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); +} + QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 988c908..42e0dc4 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -35,6 +35,7 @@ public: virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); virtual Qt::ItemFlags flags(const QModelIndex &index) const; + void gaschange(const QModelIndex &index, QString newgas); void removeSelectedPoints(const QVector<int> &rows); void setPlanMode(Mode mode); bool isPlanner(); -- 1.9.5 (Apple Git-50.3)
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
