Redesign UI, part I
This commit is contained in:
@@ -90,7 +90,33 @@ QVariant BCDataModel::headerData(int section, Qt::Orientation orientation, int r
|
||||
|
||||
QVariant BCDataModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
/*
|
||||
|
||||
if (!index.isValid() || index.row() >= static_cast<int>(m_items.size()))
|
||||
return QVariant();
|
||||
|
||||
const auto& item = m_items.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case 0: return item.id;
|
||||
case 1: return item.name;
|
||||
case 2: {
|
||||
// Hier nutzen wir QLocale für das Komma!
|
||||
return QLocale(QLocale::German).toString(item.value, 'f', 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bonus: Rechtsbündig für Zahlen
|
||||
if (role == Qt::TextAlignmentRole && (index.column() == 0 || index.column() == 2)) {
|
||||
return Qt::AlignRight | Qt::AlignVCenter;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
*/
|
||||
int row = index.row();
|
||||
int col = index.column();
|
||||
if (!index.isValid() || row >= _valueList.size())
|
||||
return QVariant();
|
||||
|
||||
@@ -98,7 +124,12 @@ QVariant BCDataModel::data(const QModelIndex& index, int role) const
|
||||
entry.rowInModel = row;
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
return entry.visibleValue;
|
||||
{
|
||||
if( col == 0 )
|
||||
return entry.label;
|
||||
else if( col == 1 )
|
||||
return entry.visibleValue;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user