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;
61 QgsMapLayer *QgsGeoPdfLayerTreeModel::mapLayer(
const QModelIndex &idx )
const
66 QgsVectorLayer *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 );
234 QgsGeoPdfLayerFilteredTreeModel::QgsGeoPdfLayerFilteredTreeModel(
QgsGeoPdfLayerTreeModel *sourceModel, QObject *parent )
235 : QSortFilterProxyModel( parent )
236 , mLayerTreeModel( sourceModel )
238 setSourceModel( sourceModel );
241 bool 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() )