aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-10-11 11:04:27 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-10-11 11:04:27 -0300
commita4efa8c444da9de1dd68125dca777d5bc8cbc693 (patch)
treefa647229c970c403d10732c9eb206d6a6fb9f7d7 /qt-ui/models.cpp
parent26c87fafc2cd2c0329b780699ba90f21a5592031 (diff)
downloadsubsurface-a4efa8c444da9de1dd68125dca777d5bc8cbc693.tar.gz
Second model converted to be less boilerplated.
Second model converted to be less boilerplated, there are right now 7 models that will need to be ported. each model can remove around 30 to 40 LOC, so this is not such a bigger improvement, but it's an 'keeping an eye on the future'. Also fixed a bug where the returned value was dummy. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp36
1 files changed, 5 insertions, 31 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 492b0ac4c..df957ea7c 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -46,8 +46,9 @@ QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation,
ret = defaultModelFont();
break;
case Qt::DisplayRole:
- return headers.at(section);
+ ret = headers.at(section);
}
+ return ret;
}
void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
@@ -349,8 +350,10 @@ void CylindersModel::remove(const QModelIndex& index)
endRemoveRows();
}
-WeightModel::WeightModel(QObject* parent): QAbstractTableModel(parent), current(0), rows(0)
+WeightModel::WeightModel(QObject* parent): current(0), rows(0)
{
+ //enum Column {REMOVE, TYPE, WEIGHT};
+ setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));
}
weightsystem_t* WeightModel::weightSystemAt(const QModelIndex& index)
@@ -378,11 +381,6 @@ void WeightModel::clear()
}
}
-int WeightModel::columnCount(const QModelIndex& parent) const
-{
- return COLUMNS;
-}
-
QVariant WeightModel::data(const QModelIndex& index, int role) const
{
QVariant ret;
@@ -476,30 +474,6 @@ int WeightModel::rowCount(const QModelIndex& parent) const
return rows;
}
-QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- QVariant ret;
- if (orientation == Qt::Vertical)
- return ret;
-
- switch (role) {
- case Qt::FontRole:
- ret = defaultModelFont();
- break;
- case Qt::DisplayRole:
- switch(section) {
- case TYPE:
- ret = tr("Type");
- break;
- case WEIGHT:
- ret = tr("Weight");
- break;
- }
- break;
- }
- return ret;
-}
-
void WeightModel::add()
{
if (rows >= MAX_WEIGHTSYSTEMS)