17 #include <QDoubleSpinBox>
40 return Qt::ItemIsDropEnabled;
44 if ( vectorLayer( idx ) )
55 if ( !mapLayer( idx ) )
61 return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
63 return Qt::NoItemFlags;
66 QgsMapLayer *QgsGeoPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
71 QgsVectorLayer *QgsGeoPdfLayerTreeModel::vectorLayer(
const QModelIndex &idx )
const
73 return qobject_cast<QgsVectorLayer *>( mapLayer( idx ) );
78 if ( orientation == Qt::Horizontal )
80 if ( role == Qt::DisplayRole )
87 return tr(
"PDF Group" );
89 return tr(
"Initially Visible" );
91 return tr(
"Include Attributes" );
97 return QgsMapLayerModel::headerData( section, orientation, role );
102 switch ( idx.column() )
105 if ( role == Qt::CheckStateRole )
114 case Qt::DisplayRole:
119 return ml->customProperty( QStringLiteral(
"geopdf/groupName" ) ).toString();
130 if ( role == Qt::CheckStateRole )
134 const QVariant v = ml->customProperty( QStringLiteral(
"geopdf/initiallyVisible" ) );
137 return v.toBool() ? Qt::Checked : Qt::Unchecked;
152 if ( role == Qt::CheckStateRole )
156 const QVariant v = vl->customProperty( QStringLiteral(
"geopdf/includeFeatures" ) );
159 return v.toBool() ? Qt::Checked : Qt::Unchecked;
177 switch (
index.column() )
181 if ( role == Qt::CheckStateRole )
185 vl->setCustomProperty( QStringLiteral(
"geopdf/includeFeatures" ), value.toInt() == Qt::Checked );
195 if ( role == Qt::EditRole )
199 ml->setCustomProperty( QStringLiteral(
"geopdf/groupName" ), value.toString() );
209 if ( role == Qt::CheckStateRole )
213 ml->setCustomProperty( QStringLiteral(
"geopdf/initiallyVisible" ), value.toInt() == Qt::Checked );
231 const QModelIndex childIndex =
index( row, column,
parent );
232 setData( childIndex, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
239 QgsGeoPdfLayerFilteredTreeModel::QgsGeoPdfLayerFilteredTreeModel(
QgsGeoPdfLayerTreeModel *sourceModel, QObject *parent )
240 : QSortFilterProxyModel( parent )
241 , mLayerTreeModel( sourceModel )
243 setSourceModel( sourceModel );
246 bool QgsGeoPdfLayerFilteredTreeModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const
248 if (
QgsMapLayer *layer = mLayerTreeModel->layerFromIndex( sourceModel()->index( source_row, 0, source_parent ) ) )
251 if ( !layer->isSpatial() )