aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-12 11:12:43 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-12 11:17:40 +0900
commitd72c69db7a49fc20ea7618deaac4b125614afb12 (patch)
tree3b6688950e02dc7e72e83c613666a2952d3488d6
parentcd1149e57fb077c2f3dbf0fce7a1a9478feb6743 (diff)
downloadsubsurface-d72c69db7a49f.tar.gz
Add depth colum to cylinder model
To make the planner work this adds a new column to the Cylinder widget (depth - for the depth at which we want to change to a certain gas during deco). This also tries to hide that column in the equipment view and hide the start/end pressure columns in the planner view. Oddly that fails :-( Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.h1
-rw-r--r--qt-ui/diveplanner.cpp5
-rw-r--r--qt-ui/maintab.cpp3
-rw-r--r--qt-ui/models.cpp19
-rw-r--r--qt-ui/models.h2
-rw-r--r--qt-ui/tableview.cpp2
-rw-r--r--qt-ui/tableview.h2
7 files changed, 28 insertions, 6 deletions
diff --git a/dive.h b/dive.h
index b97ecefc3..aef6ba366 100644
--- a/dive.h
+++ b/dive.h
@@ -143,6 +143,7 @@ typedef struct {
cylinder_type_t type;
struct gasmix gasmix;
pressure_t start, end, sample_start, sample_end;
+ depth_t depth;
} cylinder_t;
typedef struct {
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 14118c519..1a20e4f9b 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -905,6 +905,11 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
ui.cylinderTableWidget->setTitle(tr("Available Gases"));
ui.cylinderTableWidget->setModel(CylindersModel::instance());
+ // the setColumnHidden calls don't seem to work????
+ ui.cylinderTableWidget->setColumnHidden(CylindersModel::START, true);
+ ui.cylinderTableWidget->setColumnHidden(CylindersModel::END, true);
+ ui.cylinderTableWidget->setColumnHidden(CylindersModel::DEPTH, false);
+
ui.cylinderTableWidget->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 0c0d99a35..aa9dc6295 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -83,7 +83,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
-
+ // this does not appear to work???
+ ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true);
completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui.buddy);
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster);
completers.location = new QCompleter(LocationCompletionModel::instance(), ui.location);
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 22e422273..7a80521a2 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -58,8 +58,8 @@ void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
{
- // enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE,};
- setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << tr("O2%") << tr("HE"));
+ // enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
+ setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << tr("O2%") << tr("HE") << tr("Switch at"));
}
CylindersModel *CylindersModel::instance()
@@ -148,6 +148,12 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
case HE:
ret = percent_string(cyl->gasmix.he);
break;
+ case DEPTH:
+ if (prefs.units.length == prefs.units.FEET)
+ ret = mm_to_feet(cyl->depth.mm);
+ else
+ ret = cyl->depth.mm / 1000;
+ break;
}
break;
case Qt::DecorationRole:
@@ -279,6 +285,15 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
changed = true;
}
break;
+ case DEPTH:
+ if (CHANGED(toDouble, "ft", "m")) {
+ if (value.toInt() != 0) {
+ if (prefs.units.length == prefs.units.FEET)
+ cyl->depth.mm = feet_to_mm(value.toString().remove("ft").remove("m").toInt());
+ else
+ cyl->depth.mm = value.toString().remove("ft").remove("m").toInt() * 1000;
+ }
+ }
}
dataChanged(index, index);
return true;
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 78313c963..8302acefa 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -79,7 +79,7 @@ private:
class CylindersModel : public CleanerTableModel {
Q_OBJECT
public:
- enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE};
+ enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
explicit CylindersModel(QObject* parent = 0);
static CylindersModel *instance();
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp
index d9731b477..c3aed1f18 100644
--- a/qt-ui/tableview.cpp
+++ b/qt-ui/tableview.cpp
@@ -7,7 +7,7 @@
#include <QTextStream>
#include <QSettings>
-TableView::TableView(QWidget *parent) : QWidget(parent)
+TableView::TableView(QWidget *parent) : QTableView(parent)
{
ui.setupUi(this);
QFile cssFile(":table-css");
diff --git a/qt-ui/tableview.h b/qt-ui/tableview.h
index fc22425d3..af410c6e0 100644
--- a/qt-ui/tableview.h
+++ b/qt-ui/tableview.h
@@ -14,7 +14,7 @@ class QAbstractItemModel;
class QModelIndex;
class QTableView;
-class TableView : public QWidget {
+class TableView : public QTableView {
Q_OBJECT
public:
TableView(QWidget *parent = 0);