mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
7106c4d5f0
In 1af00703b3
the constructor of
WSInfoModel was removed, not realizing that it contains a crucial
call to setHeaderDataStrings().
Fixes #4294
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
38 lines
971 B
C++
38 lines
971 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "qt-models/weightsysteminfomodel.h"
|
|
#include "core/equipment.h"
|
|
#include "core/metrics.h"
|
|
#include "core/gettextfromc.h"
|
|
|
|
QVariant WSInfoModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (index.row() < 0 || index.row() >= static_cast<int>(ws_info_table.size()))
|
|
return QVariant();
|
|
const ws_info &info = ws_info_table[index.row()];
|
|
|
|
switch (role) {
|
|
case Qt::FontRole:
|
|
return defaultModelFont();
|
|
case Qt::DisplayRole:
|
|
case Qt::EditRole:
|
|
switch (index.column()) {
|
|
case GR:
|
|
return info.weight.grams;
|
|
case DESCRIPTION:
|
|
// TODO: don't translate user supplied names
|
|
return gettextFromC::tr(info.name.c_str());
|
|
}
|
|
break;
|
|
}
|
|
return QVariant();
|
|
}
|
|
|
|
int WSInfoModel::rowCount(const QModelIndex&) const
|
|
{
|
|
return static_cast<int>(ws_info_table.size());
|
|
}
|
|
|
|
WSInfoModel::WSInfoModel(QObject *parent) : CleanerTableModel(parent)
|
|
{
|
|
setHeaderDataStrings(QStringList() << tr("Description") << tr("kg"));
|
|
}
|