Show a cylinder widget in the dive planner

This is intended to allow the user to provide the gases / cylinders that
she will be diving with. With that information the planner can warn the
user about insufficient gases, but more importantly it can show relevant
gases in the gas select drop down.

Right now the add cylinder button doesn't add a cylinder - that's a
problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-11-10 07:06:26 +09:00
parent 44c9316f14
commit aa4931e8c6
6 changed files with 25 additions and 3 deletions

View file

@ -878,7 +878,9 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
ui.tableWidget->setTitle(tr("Dive Planner Points"));
ui.tableWidget->setModel(DivePlannerPointsModel::instance());
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
ui.cylinderTableWidget->setTitle(tr("Available Gases"));
ui.cylinderTableWidget->setModel(CylindersModel::instance());
// connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), CylindersModel::instance(), SLOT(add()));
connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
connect(ui.startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
connect(ui.ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
@ -1190,6 +1192,7 @@ void DivePlannerPointsModel::cancelPlan()
clear();
emit planCanceled();
setPlanMode(NOTHING);
CylindersModel::instance()->update();
}
DivePlannerPointsModel::Mode DivePlannerPointsModel::currentMode() const
@ -1283,4 +1286,5 @@ void DivePlannerPointsModel::createPlan()
clear();
planCreated();
setPlanMode(NOTHING);
CylindersModel::instance()->update();
}

View file

@ -116,7 +116,7 @@
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="TableView" name="tableWidget" native="true">
<widget class="TableView" name="cylinderTableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@ -126,6 +126,16 @@
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="TableView" name="tableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Save</set>

View file

@ -25,7 +25,7 @@
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
weightModel(new WeightModel()),
cylindersModel(new CylindersModel()),
cylindersModel(CylindersModel::instance()),
editMode(NONE)
{
ui.setupUi(this);

View file

@ -226,6 +226,7 @@ void MainWindow::on_actionDivePlanner_triggered()
disableDcShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
DivePlannerPointsModel::instance()->clear();
CylindersModel::instance()->clear();
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
}

View file

@ -62,6 +62,12 @@ CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << tr("O2%") << tr("HE"));
}
CylindersModel *CylindersModel::instance()
{
static CylindersModel *self = new CylindersModel();
return self;
}
static QVariant percent_string(fraction_t fraction)
{
int permille = fraction.permille;

View file

@ -82,6 +82,7 @@ public:
enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE};
explicit CylindersModel(QObject* parent = 0);
static CylindersModel *instance();
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const;