24#include <QDoubleSpinBox>
26#include "moc_qgsgeopdflayertreemodel.cpp"
43 return Qt::ItemIsDropEnabled;
47 if ( vectorLayer( idx ) )
58 if ( !mapLayer( idx ) )
59 return Qt::ItemFlags();
61 return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
64QgsMapLayer *QgsGeospatialPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
69QgsVectorLayer *QgsGeospatialPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const
71 return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
76 if ( orientation == Qt::Horizontal )
78 if ( role == Qt::DisplayRole )
85 return tr(
"PDF Group" );
87 return tr(
"Initially Visible" );
89 return tr(
"Include Attributes" );
95 return QgsMapLayerModel::headerData( section, orientation, role );
100 switch ( idx.column() )
103 if ( role == Qt::CheckStateRole )
112 case Qt::DisplayRole:
117 return ml->customProperty( QStringLiteral(
"geopdf/groupName" ) ).toString();
128 if ( role == Qt::CheckStateRole )
132 const QVariant v = ml->customProperty( QStringLiteral(
"geopdf/initiallyVisible" ) );
135 return v.toBool() ? Qt::Checked : Qt::Unchecked;
150 if ( role == Qt::CheckStateRole )
154 const QVariant v = vl->customProperty( QStringLiteral(
"geopdf/includeFeatures" ) );
157 return v.toBool() ? Qt::Checked : Qt::Unchecked;
175 switch (
index.column() )
179 if ( role == Qt::CheckStateRole )
183 vl->setCustomProperty( QStringLiteral(
"geopdf/includeFeatures" ), value.toInt() == Qt::Checked );
193 if ( role == Qt::EditRole )
197 ml->setCustomProperty( QStringLiteral(
"geopdf/groupName" ), value.toString() );
207 if ( role == Qt::CheckStateRole )
211 ml->setCustomProperty( QStringLiteral(
"geopdf/initiallyVisible" ), value.toInt() == Qt::Checked );
229 const QModelIndex childIndex =
index( row, column,
parent );
230 setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
238 : QSortFilterProxyModel( parent )
239 , mLayerTreeModel( sourceModel )
241 setSourceModel( sourceModel );
244bool QgsGeospatialPdfLayerFilteredTreeModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const
246 if (
QgsMapLayer *layer = mLayerTreeModel->layerFromIndex( sourceModel()->index( source_row, 0, source_parent ) ) )
249 if ( !layer->isSpatial() )
Layer tree model for Geo-PDF layers.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
@ InitiallyVisible
Initial visibility state.
@ IncludeVectorAttributes
Vector attribute.
QVariant data(const QModelIndex &index, int role) const override
void checkAll(bool checked, const QModelIndex &parent=QModelIndex(), int column=IncludeVectorAttributes)
Checks (or unchecks) all rows and children from the specified parent index.
QgsGeospatialPdfLayerTreeModel(const QList< QgsMapLayer * > &layers, QObject *parent=nullptr)
constructor
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Qt::ItemFlags flags(const QModelIndex &idx) const override
int columnCount(const QModelIndex &parent) const override
void setItemsCanBeReordered(bool allow)
Sets whether items in the model can be reordered via drag and drop.
Qt::ItemFlags flags(const QModelIndex &index) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex parent(const QModelIndex &child) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QgsMapLayer * layerFromIndex(const QModelIndex &index) const
Returns the map layer corresponding to the specified index.
QgsMapLayerModel(QObject *parent=nullptr, QgsProject *project=nullptr)
QgsMapLayerModel creates a model to display layers in widgets.
Base class for all map layer types.
Represents a vector layer which manages a vector based dataset.