mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
fix displaying enabled/disable mesh dataset group
This commit is contained in:
parent
feedc1ede5
commit
761831e6ec
@ -883,9 +883,18 @@ Returns the count of children
|
||||
|
||||
int totalChildCount() const;
|
||||
%Docstring
|
||||
Returns the total count of children, that is included deeper children
|
||||
Returns the total count of children, that is included deeper children and disabled items
|
||||
|
||||
:return:
|
||||
:return: the total children's count
|
||||
%End
|
||||
|
||||
QList<int> enabledDatasetGroupIndexes() const;
|
||||
%Docstring
|
||||
Returns a list of enabled dataset group indexes, included deeper children
|
||||
|
||||
:return: the list of dataset group indexes
|
||||
|
||||
.. versionadded:: 3.16.3
|
||||
%End
|
||||
|
||||
QgsMeshDatasetGroupTreeItem *parentItem() const;
|
||||
|
||||
@ -271,6 +271,18 @@ Returns the list of indexes of dataset groups handled by the layer
|
||||
In the layer scope, those indexes can be different from the data provider indexes.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QList<int> enabledDatasetGroupsIndexes() const;
|
||||
%Docstring
|
||||
Returns the list of indexes of enables dataset groups handled by the layer
|
||||
|
||||
.. note::
|
||||
|
||||
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,...)
|
||||
In the layer scope, those indexes can be different from the data provider indexes.
|
||||
|
||||
.. versionadded:: 3.16.3
|
||||
%End
|
||||
|
||||
QgsMeshDatasetGroupMetadata datasetGroupMetadata( const QgsMeshDatasetIndex &index ) const;
|
||||
|
||||
@ -590,6 +590,20 @@ int QgsMeshDatasetGroupTreeItem::totalChildCount() const
|
||||
return count;
|
||||
}
|
||||
|
||||
QList<int> QgsMeshDatasetGroupTreeItem::enabledDatasetGroupIndexes() const
|
||||
{
|
||||
QList<int> indexesList;
|
||||
|
||||
for ( int i = 0; i < mChildren.count(); ++i )
|
||||
{
|
||||
if ( mChildren.at( i )->isEnabled() )
|
||||
indexesList.append( mChildren.at( i )->datasetGroupIndex() );
|
||||
indexesList.append( mChildren.at( i )->enabledDatasetGroupIndexes() );
|
||||
}
|
||||
|
||||
return indexesList;
|
||||
}
|
||||
|
||||
QgsMeshDatasetGroupTreeItem *QgsMeshDatasetGroupTreeItem::parentItem() const
|
||||
{
|
||||
return mParent;
|
||||
|
||||
@ -866,11 +866,19 @@ class CORE_EXPORT QgsMeshDatasetGroupTreeItem
|
||||
int childCount() const;
|
||||
|
||||
/**
|
||||
* Returns the total count of children, that is included deeper children
|
||||
* \return
|
||||
*/
|
||||
* Returns the total count of children, that is included deeper children and disabled items
|
||||
* \return the total children's count
|
||||
*/
|
||||
int totalChildCount() const;
|
||||
|
||||
/**
|
||||
* Returns a list of enabled dataset group indexes, included deeper children
|
||||
* \return the list of dataset group indexes
|
||||
*
|
||||
* \since QGIS 3.16.3
|
||||
*/
|
||||
QList<int> enabledDatasetGroupIndexes() const;
|
||||
|
||||
/**
|
||||
* Returns the parent item, nullptr if it is root item
|
||||
* \return the parent item
|
||||
|
||||
@ -27,6 +27,11 @@ QList<int> QgsMeshDatasetGroupStore::datasetGroupIndexes() const
|
||||
return mRegistery.keys();
|
||||
}
|
||||
|
||||
QList<int> QgsMeshDatasetGroupStore::enabledDatasetGroupIndexes() const
|
||||
{
|
||||
return mDatasetGroupTreeRootItem->enabledDatasetGroupIndexes();
|
||||
}
|
||||
|
||||
int QgsMeshDatasetGroupStore::datasetGroupCount() const
|
||||
{
|
||||
return mRegistery.count();
|
||||
|
||||
@ -156,6 +156,13 @@ class QgsMeshDatasetGroupStore: public QObject
|
||||
//! Returns a list of all group indexes
|
||||
QList<int> datasetGroupIndexes() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all group indexes that are enabled
|
||||
*
|
||||
* \since QGIS 3.16.3
|
||||
*/
|
||||
QList<int> enabledDatasetGroupIndexes() const;
|
||||
|
||||
//! Returns the count of dataset groups
|
||||
int datasetGroupCount() const;
|
||||
|
||||
|
||||
@ -359,6 +359,11 @@ QList<int> QgsMeshLayer::datasetGroupsIndexes() const
|
||||
return mDatasetGroupStore->datasetGroupIndexes();
|
||||
}
|
||||
|
||||
QList<int> QgsMeshLayer::enabledDatasetGroupsIndexes() const
|
||||
{
|
||||
return mDatasetGroupStore->enabledDatasetGroupIndexes();
|
||||
}
|
||||
|
||||
QgsMeshDatasetGroupMetadata QgsMeshLayer::datasetGroupMetadata( const QgsMeshDatasetIndex &index ) const
|
||||
{
|
||||
return mDatasetGroupStore->datasetGroupMetadata( index );
|
||||
|
||||
@ -344,6 +344,16 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
|
||||
*/
|
||||
QList<int> datasetGroupsIndexes() const;
|
||||
|
||||
/**
|
||||
* Returns the list of indexes of enables dataset groups handled by the layer
|
||||
*
|
||||
* \note indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,...)
|
||||
* In the layer scope, those indexes can be different from the data provider indexes.
|
||||
*
|
||||
* \since QGIS 3.16.3
|
||||
*/
|
||||
QList<int> enabledDatasetGroupsIndexes() const;
|
||||
|
||||
/**
|
||||
* Returns the dataset groups metadata
|
||||
*
|
||||
|
||||
@ -494,17 +494,22 @@ void QgsMeshActiveDatasetGroupTreeView::setActiveGroup()
|
||||
setActiveVectorGroup( vectorGroup );
|
||||
}
|
||||
|
||||
QgsMeshDatasetGroupListModel::QgsMeshDatasetGroupListModel( QObject *parent ): QAbstractListModel( parent )
|
||||
{}
|
||||
|
||||
void QgsMeshDatasetGroupListModel::syncToLayer( QgsMeshLayer *layer )
|
||||
{
|
||||
beginResetModel();
|
||||
if ( layer )
|
||||
mRootItem = layer->datasetGroupTreeRootItem();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int QgsMeshDatasetGroupListModel::rowCount( const QModelIndex &parent ) const
|
||||
{
|
||||
Q_UNUSED( parent );
|
||||
if ( mRootItem )
|
||||
return mRootItem->totalChildCount();
|
||||
return mRootItem->enabledDatasetGroupIndexes().count();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -517,7 +522,12 @@ QVariant QgsMeshDatasetGroupListModel::data( const QModelIndex &index, int role
|
||||
if ( index.row() >= rowCount( QModelIndex() ) )
|
||||
return QVariant();
|
||||
|
||||
QgsMeshDatasetGroupTreeItem *item = mRootItem->childFromDatasetGroupIndex( index.row() );
|
||||
const QList<int> list = mRootItem->enabledDatasetGroupIndexes();
|
||||
if ( index.row() >= list.count() )
|
||||
return QVariant();
|
||||
|
||||
QgsMeshDatasetGroupTreeItem *item = mRootItem->childFromDatasetGroupIndex( list.at( index.row() ) );
|
||||
|
||||
if ( !item )
|
||||
return QVariant();
|
||||
|
||||
|
||||
@ -274,8 +274,7 @@ class GUI_EXPORT QgsMeshActiveDatasetGroupTreeView : public QTreeView
|
||||
class GUI_EXPORT QgsMeshDatasetGroupListModel: public QAbstractListModel
|
||||
{
|
||||
public:
|
||||
explicit QgsMeshDatasetGroupListModel( QObject *parent ): QAbstractListModel( parent )
|
||||
{}
|
||||
explicit QgsMeshDatasetGroupListModel( QObject *parent );
|
||||
|
||||
//! Add groups to the model from mesh layer
|
||||
void syncToLayer( QgsMeshLayer *layer );
|
||||
|
||||
@ -259,6 +259,7 @@ bool QgsMapToolIdentify::identifyMeshLayer( QList<QgsMapToolIdentify::IdentifyRe
|
||||
int activeScalarGroup = layer->rendererSettings().activeScalarDatasetGroup();
|
||||
int activeVectorGroup = layer->rendererSettings().activeVectorDatasetGroup();
|
||||
|
||||
const QList<int> allGroup = layer->enabledDatasetGroupsIndexes();
|
||||
if ( isTemporal ) //non active dataset group value are only accesible if temporal is active
|
||||
{
|
||||
const QgsDateTimeRange &time = identifyContext.temporalRange();
|
||||
@ -267,7 +268,6 @@ bool QgsMapToolIdentify::identifyMeshLayer( QList<QgsMapToolIdentify::IdentifyRe
|
||||
if ( activeVectorGroup >= 0 && activeVectorGroup != activeScalarGroup )
|
||||
datasetIndexList.append( layer->activeVectorDatasetAtTime( time ) );
|
||||
|
||||
const QList<int> allGroup = layer->datasetGroupsIndexes();
|
||||
for ( int groupIndex : allGroup )
|
||||
{
|
||||
if ( groupIndex != activeScalarGroup && groupIndex != activeVectorGroup )
|
||||
@ -276,10 +276,21 @@ bool QgsMapToolIdentify::identifyMeshLayer( QList<QgsMapToolIdentify::IdentifyRe
|
||||
}
|
||||
else
|
||||
{
|
||||
// only active dataset group
|
||||
if ( activeScalarGroup >= 0 )
|
||||
datasetIndexList.append( layer->staticScalarDatasetIndex() );
|
||||
if ( activeVectorGroup >= 0 && activeVectorGroup != activeScalarGroup )
|
||||
datasetIndexList.append( layer->staticVectorDatasetIndex() );
|
||||
|
||||
// ...and static dataset group
|
||||
for ( int groupIndex : allGroup )
|
||||
{
|
||||
if ( groupIndex != activeScalarGroup && groupIndex != activeVectorGroup )
|
||||
{
|
||||
if ( !layer->datasetGroupMetadata( groupIndex ).isTemporal() )
|
||||
datasetIndexList.append( groupIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create results
|
||||
|
||||
@ -1301,9 +1301,18 @@ void TestQgsMeshLayer::test_dataset_group_item_tree_item()
|
||||
QCOMPARE( rootItem->childFromDatasetGroupIndex( i )->name(), names.at( i ) );
|
||||
|
||||
// Disable some items
|
||||
QList<int> enabledList = rootItem->enabledDatasetGroupIndexes();
|
||||
QCOMPARE( enabledList.count(), 22 );
|
||||
QList<int> newList = enabledList;
|
||||
newList.removeOne( 7 );
|
||||
rootItem->childFromDatasetGroupIndex( 7 )->setIsEnabled( false );
|
||||
QCOMPARE( newList, rootItem->enabledDatasetGroupIndexes() );
|
||||
newList.removeOne( 10 );
|
||||
rootItem->childFromDatasetGroupIndex( 10 )->setIsEnabled( false );
|
||||
QCOMPARE( newList, rootItem->enabledDatasetGroupIndexes() );
|
||||
newList.removeOne( 15 );
|
||||
rootItem->childFromDatasetGroupIndex( 15 )->setIsEnabled( false );
|
||||
QCOMPARE( newList, rootItem->enabledDatasetGroupIndexes() );
|
||||
|
||||
QDomDocument doc;
|
||||
QgsReadWriteContext context;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user