17 #include <QDoubleSpinBox> 39 if ( idx.column() == LayerColumn )
47 return Qt::NoItemFlags;
51 const QModelIndex layerIndex = sibling( idx.row(), LayerColumn, idx );
52 if (
data( layerIndex, Qt::CheckStateRole ) == Qt::Checked )
54 return Qt::ItemIsEnabled | Qt::ItemIsEditable;
57 return Qt::NoItemFlags;
60 QgsVectorLayer *QgsGeoPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const 71 if ( orientation == Qt::Horizontal )
73 if ( role == Qt::DisplayRole )
80 return tr(
"PDF Group" );
86 return QgsLayerTreeModel::headerData( section, orientation, role );
91 switch ( idx.column() )
95 if ( role == Qt::CheckStateRole )
101 const QVariant v = vl->
customProperty( QStringLiteral(
"geopdf/includeFeatures" ) );
104 return v.toBool() ? Qt::Checked : Qt::Unchecked;
120 case Qt::DisplayRole:
125 return vl->customProperty( QStringLiteral(
"geopdf/groupName" ) ).toString();
140 switch ( index.column() )
144 if ( role == Qt::CheckStateRole )
148 vl->setCustomProperty( QStringLiteral(
"geopdf/includeFeatures" ), value.toInt() == Qt::Checked );
149 emit dataChanged( index, index );
158 if ( role == Qt::EditRole )
162 vl->setCustomProperty( QStringLiteral(
"geopdf/groupName" ), value.toString() );
163 emit dataChanged( index, index );
QModelIndex parent(const QModelIndex &child) const override
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
bool itemVisibilityChecked() const
Returns whether a node is checked (independently of its ancestors or children)
QVariant data(const QModelIndex &index, int role) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
void setFlags(QgsLayerTreeModel::Flags f)
Sets OR-ed combination of model flags.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Namespace with helper functions for layer tree operations.
QgsGeoPdfLayerTreeModel(QgsLayerTree *rootNode, QObject *parent=nullptr)
constructor
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
This class is a base class for nodes in a layer tree.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
QgsLayerTreeNode * index2node(const QModelIndex &index) const
Returns layer tree node for given index.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int columnCount(const QModelIndex &parent) const override
Flags flags() const
Returns OR-ed combination of model flags.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Represents a vector layer which manages a vector based data sets.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override