17#include <QDoubleSpinBox>
40 return Qt::ItemIsDropEnabled;
44 if ( vectorLayer( idx ) )
55 if ( !mapLayer( idx ) )
56 return Qt::ItemFlags();
58 return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
61QgsMapLayer *QgsGeoPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
66QgsVectorLayer *QgsGeoPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const
68 return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
73 if ( orientation == Qt::Horizontal )
75 if ( role == Qt::DisplayRole )
82 return tr(
"PDF Group" );
84 return tr(
"Initially Visible" );
86 return tr(
"Include Attributes" );
92 return QgsMapLayerModel::headerData( section, orientation, role );
97 switch ( idx.column() )
100 if ( role == Qt::CheckStateRole )
109 case Qt::DisplayRole:
114 return ml->customProperty( QStringLiteral(
"geopdf/groupName" ) ).toString();
125 if ( role == Qt::CheckStateRole )
129 const QVariant v = ml->customProperty( QStringLiteral(
"geopdf/initiallyVisible" ) );
132 return v.toBool() ? Qt::Checked : Qt::Unchecked;
147 if ( role == Qt::CheckStateRole )
151 const QVariant v = vl->customProperty( QStringLiteral(
"geopdf/includeFeatures" ) );
154 return v.toBool() ? Qt::Checked : Qt::Unchecked;
172 switch (
index.column() )
176 if ( role == Qt::CheckStateRole )
180 vl->setCustomProperty( QStringLiteral(
"geopdf/includeFeatures" ), value.toInt() == Qt::Checked );
190 if ( role == Qt::EditRole )
194 ml->setCustomProperty( QStringLiteral(
"geopdf/groupName" ), value.toString() );
204 if ( role == Qt::CheckStateRole )
208 ml->setCustomProperty( QStringLiteral(
"geopdf/initiallyVisible" ), value.toInt() == Qt::Checked );
226 const QModelIndex childIndex =
index( row, column,
parent );
227 setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
234QgsGeoPdfLayerFilteredTreeModel::QgsGeoPdfLayerFilteredTreeModel(
QgsGeoPdfLayerTreeModel *sourceModel, QObject *parent )
235 : QSortFilterProxyModel( parent )
236 , mLayerTreeModel( sourceModel )
238 setSourceModel( sourceModel );
241bool QgsGeoPdfLayerFilteredTreeModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const
243 if (
QgsMapLayer *layer = mLayerTreeModel->layerFromIndex( sourceModel()->index( source_row, 0, source_parent ) ) )
246 if ( !layer->isSpatial() )
Layer tree model for Geo-PDF layers.
@ InitiallyVisible
Initial visibility state.
@ IncludeVectorAttributes
Vector attribute.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
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.
Qt::ItemFlags flags(const QModelIndex &idx) const override
QgsGeoPdfLayerTreeModel(const QList< QgsMapLayer * > &layers, QObject *parent=nullptr)
constructor
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.