Moved the model meta data for roles and columns into "model/metadata.h" to gather meta data like this in one central place.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "../metadata.h"
|
||||
#include "../tablemodel.h"
|
||||
|
||||
EditItemCommand::EditItemCommand(TableModel* model,
|
||||
@ -20,23 +21,23 @@ EditItemCommand::EditItemCommand(TableModel* model,
|
||||
const QVariant value = changedValues.first();
|
||||
QString roleName = model->roleNames().value(role);
|
||||
switch (role) {
|
||||
case TableModel::NameRole:
|
||||
case TableModel::DescriptionRole:
|
||||
case TableModel::InfoRole:
|
||||
case TableModel::AmountRole:
|
||||
case TableModel::FactorRole:
|
||||
case NameRole:
|
||||
case DescriptionRole:
|
||||
case InfoRole:
|
||||
case AmountRole:
|
||||
case FactorRole:
|
||||
commandText = QString("Setting '%1' of item '%2' to '%3'")
|
||||
.arg(roleName)
|
||||
.arg(index.data(TableModel::NameRole).toString())
|
||||
.arg(index.data(NameRole).toString())
|
||||
.arg(value.toString());
|
||||
break;
|
||||
default:
|
||||
commandText = QString("Edit item '%1'").arg(index.data(TableModel::NameRole).toString());
|
||||
commandText = QString("Edit item '%1'").arg(index.data(NameRole).toString());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "More than one value to change. Using a generic command text...";
|
||||
commandText = QString("Edit item '%1'").arg(index.data(TableModel::NameRole).toString());
|
||||
commandText = QString("Edit item '%1'").arg(index.data(NameRole).toString());
|
||||
}
|
||||
setText(commandText);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user