Commit c76325df authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

Give columns an enum for readability (eg. HostName rather than 0)

parent 9887f590
......@@ -125,19 +125,19 @@ QVariant SensorModel::data( const QModelIndex &index, int role ) const
if ( role == Qt::DisplayRole ) {
switch ( index.column() ) {
case 0:
case HostName:
return sensor.hostName();
case 1:
case SensorName:
return sensor.sensorName();
case 2:
case Unit:
return sensor.unit();
case 3:
case Status:
return sensor.status();
case 4:
case Label:
return sensor.label();
}
} else if ( role == Qt::DecorationRole ) {
if ( index.column() == 1 ) {
if ( index.column() == SensorName ) {
if ( sensor.color().isValid() ) {
QPixmap pm( 12, 12 );
pm.fill( sensor.color() );
......@@ -157,15 +157,15 @@ QVariant SensorModel::headerData( int section, Qt::Orientation orientation, int
if ( role == Qt::DisplayRole ) {
switch ( section ) {
case 0:
case HostName:
return i18n( "Host" );
case 1:
case SensorName:
return i18n( "Sensor" );
case 2:
case Unit:
return i18n( "Unit" );
case 3:
case Status:
return i18n( "Status" );
case 4:
case Label:
return i18n( "Label" );
default:
return QVariant();
......
......@@ -66,6 +66,13 @@ class SensorModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Columns {
HostName=0,
SensorName=1,
Unit=2,
Status=3,
Label=4
};
explicit SensorModel( QObject *parent = nullptr );
void setSensors( const SensorModelEntry::List &sensors );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment