mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Finish clearing up the TableModels
There are other models ( Tree Models and Model Items ) that are not affected by this commits, this is already a good cleanup but it can be extended to also fix those two other possibilities. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
fac316865c
commit
beb40ae494
2 changed files with 7 additions and 61 deletions
|
@ -674,11 +674,6 @@ void TankInfoModel::clear()
|
|||
{
|
||||
}
|
||||
|
||||
int TankInfoModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
QVariant TankInfoModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
QVariant ret;
|
||||
|
@ -711,41 +706,14 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
QVariant TankInfoModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant ret;
|
||||
|
||||
if (orientation != Qt::Horizontal)
|
||||
return ret;
|
||||
|
||||
switch(role){
|
||||
case Qt::FontRole:
|
||||
ret = defaultModelFont();
|
||||
break;
|
||||
case Qt::DisplayRole:
|
||||
switch(section) {
|
||||
case BAR:
|
||||
ret = tr("Bar");
|
||||
break;
|
||||
case ML:
|
||||
ret = tr("Ml");
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
ret = tr("Description");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TankInfoModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return rows+1;
|
||||
}
|
||||
|
||||
TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
|
||||
TankInfoModel::TankInfoModel() : rows(-1)
|
||||
{
|
||||
setHeaderDataStrings( QStringList() << tr("Description") << tr("Ml") << tr("Bar"));
|
||||
struct tank_info_t *info = tank_info;
|
||||
for (info = tank_info; info->name; info++, rows++){
|
||||
QString infoName(info->name);
|
||||
|
@ -1163,31 +1131,13 @@ void DiveTripModel::setLayout(DiveTripModel::Layout layout)
|
|||
*####################################################################
|
||||
*/
|
||||
|
||||
DiveComputerModel::DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject* parent): QAbstractTableModel(parent)
|
||||
DiveComputerModel::DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject* parent): CleanerTableModel()
|
||||
{
|
||||
setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
|
||||
dcWorkingMap = dcMap;
|
||||
numRows = 0;
|
||||
}
|
||||
|
||||
int DiveComputerModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
QVariant DiveComputerModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant ret;
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal){
|
||||
return ret;
|
||||
}
|
||||
switch(section){
|
||||
case ID: ret = tr("Device ID"); break;
|
||||
case MODEL: ret = tr("Model"); break;
|
||||
case NICKNAME: ret = tr("Nickname"); break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVariant DiveComputerModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
QList<DiveComputerNode> values = dcWorkingMap.values();
|
||||
|
|
|
@ -32,7 +32,7 @@ private:
|
|||
|
||||
/* Encapsulates the tank_info global variable
|
||||
* to show on Qt's Model View System.*/
|
||||
class TankInfoModel : public QAbstractTableModel {
|
||||
class TankInfoModel : public CleanerTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static TankInfoModel* instance();
|
||||
|
@ -40,8 +40,6 @@ public:
|
|||
enum Column {DESCRIPTION, ML, BAR};
|
||||
TankInfoModel();
|
||||
|
||||
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
/*reimp*/ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
|
||||
|
@ -207,14 +205,12 @@ private:
|
|||
Layout currentLayout;
|
||||
};
|
||||
|
||||
class DiveComputerModel : public QAbstractTableModel
|
||||
class DiveComputerModel : public CleanerTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {REMOVE, MODEL, ID, NICKNAME, COLUMNS};
|
||||
enum {REMOVE, MODEL, ID, NICKNAME};
|
||||
DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject *parent = 0);
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue