24#include <QDoubleSpinBox>
27#include "moc_qgsgeopdflayertreemodel.cpp"
29using namespace Qt::StringLiterals;
46 return Qt::ItemIsDropEnabled;
50 if ( vectorLayer( idx ) )
61 if ( !mapLayer( idx ) )
62 return Qt::ItemFlags();
64 return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
67QgsMapLayer *QgsGeospatialPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
72QgsVectorLayer *QgsGeospatialPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const
74 return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
79 if ( orientation == Qt::Horizontal )
81 if ( role == Qt::DisplayRole )
88 return tr(
"PDF Group" );
90 return tr(
"Initially Visible" );
92 return tr(
"Include Attributes" );
98 return QgsMapLayerModel::headerData( section, orientation, role );
103 switch ( idx.column() )
106 if ( role == Qt::CheckStateRole )
115 case Qt::DisplayRole:
120 return ml->customProperty( u
"geopdf/groupName"_s ).toString();
131 if ( role == Qt::CheckStateRole )
135 const QVariant v = ml->customProperty( u
"geopdf/initiallyVisible"_s );
138 return v.toBool() ? Qt::Checked : Qt::Unchecked;
153 if ( role == Qt::CheckStateRole )
157 const QVariant v = vl->customProperty( u
"geopdf/includeFeatures"_s );
160 return v.toBool() ? Qt::Checked : Qt::Unchecked;
178 switch (
index.column() )
182 if ( role == Qt::CheckStateRole )
186 vl->setCustomProperty( u
"geopdf/includeFeatures"_s, value.toInt() == Qt::Checked );
196 if ( role == Qt::EditRole )
200 ml->setCustomProperty( u
"geopdf/groupName"_s, value.toString() );
210 if ( role == Qt::CheckStateRole )
214 ml->setCustomProperty( u
"geopdf/initiallyVisible"_s, value.toInt() == Qt::Checked );
232 const QModelIndex childIndex =
index( row, column,
parent );
233 setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
241 : QSortFilterProxyModel( parent )
242 , mLayerTreeModel( sourceModel )
244 setSourceModel( sourceModel );
247bool QgsGeospatialPdfLayerFilteredTreeModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const
249 if (
QgsMapLayer *layer = mLayerTreeModel->layerFromIndex( sourceModel()->index( source_row, 0, source_parent ) ) )
252 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.