Using "model/metadata.h" for file and JSON object naming as well. Using all upper case for naming static meta data constants and functions.
This commit is contained in:
@ -6,15 +6,25 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
/// model data
|
||||
enum UserRoles { NameRole = Qt::UserRole + 1, DescriptionRole, InfoRole, AmountRole, FactorRole };
|
||||
static QHash<int, QByteArray> ROLE_NAMES = {{NameRole, "Name"},
|
||||
{DescriptionRole, "Description"},
|
||||
{InfoRole, "Info"},
|
||||
{AmountRole, "Amount"},
|
||||
{FactorRole, "Factor"}};
|
||||
static QList<QString> intColumns = {"Amount", "Factor"};
|
||||
// TODO ? use a data structure containing the type information of each column
|
||||
// ([QString, QString, QString, int, double], {{NameRole, QString},...})
|
||||
// instead of INT_COLUMNS,...
|
||||
static QList<QString> INT_COLUMNS = {"Amount", "Factor"};
|
||||
|
||||
static int getRoleForColumn(const int column) {
|
||||
/// JSON keys
|
||||
static const QString ITEM_KEY_STRING = "items";
|
||||
|
||||
/// file naming
|
||||
static const QString ITEM_FILE_NAME = ITEM_KEY_STRING + ".json";
|
||||
|
||||
static int GET_ROLE_FOR_COLUMN(const int column) {
|
||||
switch (column) {
|
||||
case 0:
|
||||
return NameRole;
|
||||
|
||||
Reference in New Issue
Block a user