mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cylinder: fix hidden-column logic in cylinder tab
The logic did not consider the WORKINGPRESS_INT and SIZE_INT
columns added in cb80ff746b
.
By some unknown magic this worked by routing everything
through the CylindersModelFiltered model.
Let's fix it and explicitly ignore these columns. Put
the test whether a column should be ignored in a function
to avoid inconsistencies should new columns be added.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9fd531dcc5
commit
c6f0fcbb0b
2 changed files with 14 additions and 6 deletions
|
@ -14,6 +14,12 @@
|
|||
#include <QSettings>
|
||||
#include <QCompleter>
|
||||
|
||||
static bool ignoreHiddenFlag(int i)
|
||||
{
|
||||
return i == CylindersModel::REMOVE || i == CylindersModel::TYPE ||
|
||||
i == CylindersModel::WORKINGPRESS_INT || i == CylindersModel::SIZE_INT;
|
||||
}
|
||||
|
||||
TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
|
||||
cylindersModel(new CylindersModelFiltered(this)),
|
||||
weightModel(new WeightModel(this))
|
||||
|
@ -48,6 +54,8 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
|
|||
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this));
|
||||
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this));
|
||||
ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true);
|
||||
ui.cylinders->view()->setColumnHidden(CylindersModel::WORKINGPRESS_INT, true);
|
||||
ui.cylinders->view()->setColumnHidden(CylindersModel::SIZE_INT, true);
|
||||
|
||||
ui.cylinders->setTitle(tr("Cylinders"));
|
||||
ui.cylinders->setBtnToolTip(tr("Add cylinder"));
|
||||
|
@ -71,7 +79,7 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
|
|||
QSettings s;
|
||||
s.beginGroup("cylinders_dialog");
|
||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
||||
if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
|
||||
if (ignoreHiddenFlag(i))
|
||||
continue;
|
||||
bool checked = s.value(QString("column%1_hidden").arg(i)).toBool();
|
||||
QAction *action = new QAction(cylindersModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(), ui.cylinders->view());
|
||||
|
@ -94,7 +102,7 @@ TabDiveEquipment::~TabDiveEquipment()
|
|||
QSettings s;
|
||||
s.beginGroup("cylinders_dialog");
|
||||
for (int i = 0; i < CylindersModel::COLUMNS; i++) {
|
||||
if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
|
||||
if (ignoreHiddenFlag(i))
|
||||
continue;
|
||||
s.setValue(QString("column%1_hidden").arg(i), ui.cylinders->view()->isColumnHidden(i));
|
||||
}
|
||||
|
@ -122,8 +130,9 @@ void TabDiveEquipment::toggleTriggeredColumn()
|
|||
view->showColumn(col);
|
||||
if (view->columnWidth(col) <= 15)
|
||||
view->setColumnWidth(col, 80);
|
||||
} else
|
||||
} else {
|
||||
view->hideColumn(col);
|
||||
}
|
||||
}
|
||||
|
||||
void TabDiveEquipment::updateData()
|
||||
|
@ -131,7 +140,6 @@ void TabDiveEquipment::updateData()
|
|||
cylindersModel->updateDive(current_dive);
|
||||
weightModel->updateDive(current_dive);
|
||||
|
||||
ui.cylinders->view()->hideColumn(CylindersModel::DEPTH);
|
||||
bool is_ccr = current_dive && get_dive_dc(current_dive, dc_number)->divemode == CCR;
|
||||
if (is_ccr)
|
||||
ui.cylinders->view()->showColumn(CylindersModel::USE);
|
||||
|
|
|
@ -17,9 +17,9 @@ CylindersModel::CylindersModel(bool planner, QObject *parent) : CleanerTableMode
|
|||
tempRow(-1),
|
||||
tempCyl(empty_cylinder)
|
||||
{
|
||||
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, MOD, MND, USE, IS_USED};
|
||||
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, MOD, MND, USE, IS_USED, WORKINGPRESS_INT, SIZE_INT};
|
||||
setHeaderDataStrings(QStringList() << "" << tr("Type") << tr("Size") << tr("Work press.") << tr("Start press.") << tr("End press.") << tr("O₂%") << tr("He%")
|
||||
<< tr("Deco switch at") <<tr("Bot. MOD") <<tr("MND") << tr("Use"));
|
||||
<< tr("Deco switch at") <<tr("Bot. MOD") <<tr("MND") << tr("Use") << "" << "");
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylindersReset, this, &CylindersModel::cylindersReset);
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &CylindersModel::cylinderAdded);
|
||||
|
|
Loading…
Add table
Reference in a new issue