"gray-out" slots beyond the last active slot
This commit is contained in:
parent
e538cc74d3
commit
b3db8ecd47
|
@ -1,5 +1,6 @@
|
|||
#include "universemodel.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
#include <QChar>
|
||||
#include <QMetaEnum>
|
||||
|
@ -57,10 +58,10 @@ int UniverseModel::rowCount(const QModelIndex &parent) const
|
|||
*/
|
||||
int UniverseModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return 10;
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,34 +81,36 @@ QVariant UniverseModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
int slot = (index.row() * 10) + (index.column() + 1);
|
||||
if (slot == 0)
|
||||
{
|
||||
int slot = (index.row() * 10) + (index.column() + 1);
|
||||
if (slot == 0)
|
||||
return QVariant();
|
||||
if (slot > 512)
|
||||
if (slot > 512)
|
||||
return QVariant();
|
||||
switch (data_mode_) {
|
||||
case Decimal:
|
||||
return universe_->slot(slot);
|
||||
break;
|
||||
case Hex:
|
||||
return QString("%1")
|
||||
.arg(universe_->slot(slot), 2, 16, QChar('0'))
|
||||
.toUpper();
|
||||
break;
|
||||
case Percent:
|
||||
return QString("%1%").arg((universe_->slot(slot) / 255.0F) * 100,
|
||||
0, 'f', 0, '0');
|
||||
break;
|
||||
switch (data_mode_) {
|
||||
case Decimal:
|
||||
return universe_->slot(slot);
|
||||
case Hex:
|
||||
return QString("%1")
|
||||
.arg(universe_->slot(slot), 2, 16, QChar('0'))
|
||||
.toUpper();
|
||||
case Percent:
|
||||
return QString("%1%").arg((universe_->slot(slot) / 255.0F) * 100,
|
||||
0, 'f', 0, '0');
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::FontRole:
|
||||
return QFont("monospace");
|
||||
break;
|
||||
case Qt::TextAlignmentRole:
|
||||
return int(Qt::AlignCenter | Qt::AlignVCenter);
|
||||
break;
|
||||
case Qt::ForegroundRole:
|
||||
{
|
||||
int slot = (index.row() * 10) + (index.column() + 1);
|
||||
if (slot > universe_->activeSlots() - 1)
|
||||
return QBrush(Qt::gray);
|
||||
return QVariant();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue