Proper header names for the columns.
This commit is contained in:
@ -10,6 +10,10 @@ enum UserRoles {
|
|||||||
FactorRole,
|
FactorRole,
|
||||||
FactoredAmountRole
|
FactoredAmountRole
|
||||||
};
|
};
|
||||||
|
static const QHash<int, QByteArray> ROLE_NAMES = {
|
||||||
|
{NameRole, "Name"}, {DescriptionRole, "Description"},
|
||||||
|
{InfoRole, "Info"}, {AmountRole, "Amount"},
|
||||||
|
{FactorRole, "Factor"}, {FactoredAmountRole, "FactoredAmount"}};
|
||||||
|
|
||||||
TableModel::TableModel(QObject* parent)
|
TableModel::TableModel(QObject* parent)
|
||||||
: QAbstractTableModel{parent} {
|
: QAbstractTableModel{parent} {
|
||||||
@ -61,7 +65,9 @@ QVariant TableModel::data(const QModelIndex& index, int role) const {
|
|||||||
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal) {
|
||||||
return QString("Section %1").arg(section);
|
const int columnRole = getRoleForColumn(section);
|
||||||
|
const QString headerName = ROLE_NAMES.value(columnRole);
|
||||||
|
return QString("%1").arg(headerName);
|
||||||
} else {
|
} else {
|
||||||
return QString("%1").arg(section);
|
return QString("%1").arg(section);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user