17#include <QDoubleSpinBox>
20#include "moc_qgsgeopdflayertreemodel.cpp"
41 return Qt::ItemIsDropEnabled;
45 if ( vectorLayer( idx ) )
56 if ( !mapLayer( idx ) )
57 return Qt::ItemFlags();
59 return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
62QgsMapLayer *QgsGeospatialPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
67QgsVectorLayer *QgsGeospatialPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const
69 return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
74 if ( orientation == Qt::Horizontal )
76 if ( role == Qt::DisplayRole )
83 return tr(
"PDF Group" );
85 return tr(
"Initially Visible" );
87 return tr(
"Include Attributes" );
93 return QgsMapLayerModel::headerData( section, orientation, role );
98 switch ( idx.column() )
101 if ( role == Qt::CheckStateRole )
110 case Qt::DisplayRole:
115 return ml->customProperty( QStringLiteral(
"geopdf/groupName" ) ).toString();
126 if ( role == Qt::CheckStateRole )
130 const QVariant v = ml->customProperty( QStringLiteral(
"geopdf/initiallyVisible" ) );
133 return v.toBool() ? Qt::Checked : Qt::Unchecked;
148 if ( role == Qt::CheckStateRole )
152 const QVariant v = vl->customProperty( QStringLiteral(
"geopdf/includeFeatures" ) );
155 return v.toBool() ? Qt::Checked : Qt::Unchecked;
173 switch (
index.column() )
177 if ( role == Qt::CheckStateRole )
181 vl->setCustomProperty( QStringLiteral(
"geopdf/includeFeatures" ), value.toInt() == Qt::Checked );
191 if ( role == Qt::EditRole )
195 ml->setCustomProperty( QStringLiteral(
"geopdf/groupName" ), value.toString() );
205 if ( role == Qt::CheckStateRole )
209 ml->setCustomProperty( QStringLiteral(
"geopdf/initiallyVisible" ), value.toInt() == Qt::Checked );
227 const QModelIndex childIndex =
index( row, column,
parent );
228 setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
236 : QSortFilterProxyModel( parent )
237 , mLayerTreeModel( sourceModel )
239 setSourceModel( sourceModel );
242bool QgsGeospatialPdfLayerFilteredTreeModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const
244 if (
QgsMapLayer *layer = mLayerTreeModel->layerFromIndex( sourceModel()->index( source_row, 0, source_parent ) ) )
247 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
The QgsMapLayerModel class is a model to display layers in widgets.
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.
Base class for all map layer types.
Represents a vector layer which manages a vector based data sets.