mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
cd1149e57f
commit
d72c69db7a
7 changed files with 28 additions and 6 deletions
1
dive.h
1
dive.h
|
@ -143,6 +143,7 @@ typedef struct {
|
||||||
cylinder_type_t type;
|
cylinder_type_t type;
|
||||||
struct gasmix gasmix;
|
struct gasmix gasmix;
|
||||||
pressure_t start, end, sample_start, sample_end;
|
pressure_t start, end, sample_start, sample_end;
|
||||||
|
depth_t depth;
|
||||||
} cylinder_t;
|
} cylinder_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -905,6 +905,11 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
|
||||||
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
|
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
|
||||||
ui.cylinderTableWidget->setTitle(tr("Available Gases"));
|
ui.cylinderTableWidget->setTitle(tr("Available Gases"));
|
||||||
ui.cylinderTableWidget->setModel(CylindersModel::instance());
|
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());
|
ui.cylinderTableWidget->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
||||||
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
|
connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
|
||||||
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
|
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
|
||||||
|
|
|
@ -83,7 +83,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
|
|
||||||
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
|
||||||
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
|
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.buddy = new QCompleter(BuddyCompletionModel::instance(), ui.buddy);
|
||||||
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster);
|
completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster);
|
||||||
completers.location = new QCompleter(LocationCompletionModel::instance(), ui.location);
|
completers.location = new QCompleter(LocationCompletionModel::instance(), ui.location);
|
||||||
|
|
|
@ -58,8 +58,8 @@ void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
|
||||||
|
|
||||||
CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
|
CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
|
||||||
{
|
{
|
||||||
// enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, 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"));
|
setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << tr("O2%") << tr("HE") << tr("Switch at"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CylindersModel *CylindersModel::instance()
|
CylindersModel *CylindersModel::instance()
|
||||||
|
@ -148,6 +148,12 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
case HE:
|
case HE:
|
||||||
ret = percent_string(cyl->gasmix.he);
|
ret = percent_string(cyl->gasmix.he);
|
||||||
break;
|
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;
|
break;
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
|
@ -279,6 +285,15 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
break;
|
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);
|
dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,7 +79,7 @@ private:
|
||||||
class CylindersModel : public CleanerTableModel {
|
class CylindersModel : public CleanerTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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);
|
explicit CylindersModel(QObject* parent = 0);
|
||||||
static CylindersModel *instance();
|
static CylindersModel *instance();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
TableView::TableView(QWidget *parent) : QWidget(parent)
|
TableView::TableView(QWidget *parent) : QTableView(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
QFile cssFile(":table-css");
|
QFile cssFile(":table-css");
|
||||||
|
|
|
@ -14,7 +14,7 @@ class QAbstractItemModel;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QTableView;
|
class QTableView;
|
||||||
|
|
||||||
class TableView : public QWidget {
|
class TableView : public QTableView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TableView(QWidget *parent = 0);
|
TableView(QWidget *parent = 0);
|
||||||
|
|
Loading…
Reference in a new issue