mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
models: pass header descriptions in CleanerTableModel constructor
For the "CleanerHeaderModel" to work, the deriving class has to set the header descriptions. Failing to do so led to bug #4294. To avoid that in the future force the deriving class to pass the headers in the constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7106c4d5f0
commit
c0e8ea5188
8 changed files with 19 additions and 29 deletions
|
@ -20,7 +20,8 @@ const QPixmap &editIcon()
|
|||
return edit;
|
||||
}
|
||||
|
||||
CleanerTableModel::CleanerTableModel(QObject *parent) : QAbstractTableModel(parent)
|
||||
CleanerTableModel::CleanerTableModel(QStringList headers, QObject *parent) : QAbstractTableModel(parent),
|
||||
headers(headers)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -42,8 +43,3 @@ QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation,
|
|||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void CleanerTableModel::setHeaderDataStrings(const QStringList &newHeaders)
|
||||
{
|
||||
headers = newHeaders;
|
||||
}
|
||||
|
|
|
@ -20,15 +20,12 @@ const QPixmap &editIcon();
|
|||
class CleanerTableModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CleanerTableModel(QObject *parent = 0);
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
explicit CleanerTableModel(QStringList headers, QObject *parent = 0);
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
protected:
|
||||
void setHeaderDataStrings(const QStringList &headers);
|
||||
|
||||
private:
|
||||
QStringList headers;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,18 +13,17 @@
|
|||
#include "core/subsurface-string.h"
|
||||
#include <string>
|
||||
|
||||
CylindersModel::CylindersModel(bool planner, QObject *parent) : CleanerTableModel(parent),
|
||||
CylindersModel::CylindersModel(bool planner, QObject *parent) :
|
||||
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, MOD, MND, USE, WORKINGPRESS_INT, SIZE_INT, SENSORS};
|
||||
CleanerTableModel(QStringList { QString(), 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"), QString(),
|
||||
QString(), tr("Sensors") }, parent),
|
||||
d(nullptr),
|
||||
dcNr(-1),
|
||||
inPlanner(planner),
|
||||
numRows(0),
|
||||
tempRow(-1)
|
||||
{
|
||||
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, MOD, MND, USE, WORKINGPRESS_INT, SIZE_INT, SENSORS};
|
||||
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("Sensors"));
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylindersReset, this, &CylindersModel::cylindersReset);
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &CylindersModel::cylinderAdded);
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &CylindersModel::cylinderRemoved);
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
#include "core/divecomputer.h"
|
||||
#include "core/metrics.h"
|
||||
|
||||
ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent)
|
||||
ExtraDataModel::ExtraDataModel(QObject *parent) :
|
||||
CleanerTableModel(QStringList { tr("Key"), tr("Value") }, parent)
|
||||
{
|
||||
//enum Column {KEY, VALUE};
|
||||
setHeaderDataStrings(QStringList() << tr("Key") << tr("Value"));
|
||||
}
|
||||
|
||||
void ExtraDataModel::clear()
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "core/qthelper.h"
|
||||
#include "core/subsurface-qt/divelistnotifier.h"
|
||||
|
||||
FilterPresetModel::FilterPresetModel()
|
||||
FilterPresetModel::FilterPresetModel() :
|
||||
CleanerTableModel(QStringList { QString(), tr("Name") })
|
||||
{
|
||||
setHeaderDataStrings(QStringList{ "", tr("Name") });
|
||||
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &FilterPresetModel::reset);
|
||||
connect(&diveListNotifier, &DiveListNotifier::filterPresetAdded, this, &FilterPresetModel::filterPresetAdded);
|
||||
connect(&diveListNotifier, &DiveListNotifier::filterPresetRemoved, this, &FilterPresetModel::filterPresetRemoved);
|
||||
|
|
|
@ -32,7 +32,7 @@ int TankInfoModel::rowCount(const QModelIndex&) const
|
|||
return (int)tank_info_table.size();
|
||||
}
|
||||
|
||||
TankInfoModel::TankInfoModel(QObject *parent) : CleanerTableModel(parent)
|
||||
TankInfoModel::TankInfoModel(QObject *parent) :
|
||||
CleanerTableModel(QStringList{ tr("Description"), tr("ml"), tr("bar") }, parent)
|
||||
{
|
||||
setHeaderDataStrings(QStringList() << tr("Description") << tr("ml") << tr("bar"));
|
||||
}
|
||||
|
|
|
@ -10,12 +10,11 @@
|
|||
#include "commands/command.h"
|
||||
#endif
|
||||
|
||||
WeightModel::WeightModel(QObject *parent) : CleanerTableModel(parent),
|
||||
WeightModel::WeightModel(QObject *parent) :
|
||||
CleanerTableModel(QStringList { QString(), tr("Type"), tr("Weight") }, parent),
|
||||
d(nullptr),
|
||||
tempRow(-1)
|
||||
{
|
||||
//enum Column {REMOVE, TYPE, WEIGHT};
|
||||
setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));
|
||||
connect(&diveListNotifier, &DiveListNotifier::weightsystemsReset, this, &WeightModel::weightsystemsReset);
|
||||
connect(&diveListNotifier, &DiveListNotifier::weightAdded, this, &WeightModel::weightAdded);
|
||||
connect(&diveListNotifier, &DiveListNotifier::weightRemoved, this, &WeightModel::weightRemoved);
|
||||
|
|
|
@ -32,7 +32,7 @@ int WSInfoModel::rowCount(const QModelIndex&) const
|
|||
return static_cast<int>(ws_info_table.size());
|
||||
}
|
||||
|
||||
WSInfoModel::WSInfoModel(QObject *parent) : CleanerTableModel(parent)
|
||||
WSInfoModel::WSInfoModel(QObject *parent) :
|
||||
CleanerTableModel(QStringList { tr("Description"), tr("kg") }, parent)
|
||||
{
|
||||
setHeaderDataStrings(QStringList() << tr("Description") << tr("kg"));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue