[netinstall] Introduce constexpr names for columns and roles
This commit is contained in:
parent
3d68c74a19
commit
df86972ea7
@ -117,7 +117,7 @@ PackageModel::data( const QModelIndex& index, int role ) const
|
||||
}
|
||||
|
||||
PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() );
|
||||
if ( index.column() == 0 && role == Qt::CheckStateRole )
|
||||
if ( index.column() == NameColumn && role == Qt::CheckStateRole )
|
||||
{
|
||||
return item->isSelected();
|
||||
}
|
||||
@ -156,7 +156,7 @@ PackageModel::flags( const QModelIndex& index ) const
|
||||
{
|
||||
return Qt::ItemFlags();
|
||||
}
|
||||
if ( index.column() == 0 )
|
||||
if ( index.column() == NameColumn )
|
||||
{
|
||||
return Qt::ItemIsUserCheckable | QAbstractItemModel::flags( index );
|
||||
}
|
||||
@ -168,7 +168,7 @@ PackageModel::headerData( int section, Qt::Orientation orientation, int role ) c
|
||||
{
|
||||
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
|
||||
{
|
||||
return ( section == 0 ) ? tr( "Name" ) : tr( "Description" );
|
||||
return ( section == NameColumn ) ? tr( "Name" ) : tr( "Description" );
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -39,6 +39,16 @@ class PackageModel : public QAbstractItemModel
|
||||
public:
|
||||
using PackageItemDataList = QList< PackageTreeItem::ItemData >;
|
||||
|
||||
// Names for columns (unused in the code)
|
||||
static constexpr const int NameColumn = 0;
|
||||
static constexpr const int DescriptionColumn = 1;
|
||||
|
||||
/* The only interesting roles are DisplayRole (with text depending
|
||||
* on the column, and MetaExpandRole which tells if an index
|
||||
* should be initially expanded.
|
||||
*/
|
||||
static constexpr const int MetaExpandRole = Qt::UserRole + 1;
|
||||
|
||||
explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr );
|
||||
~PackageModel() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user