Skip to content

Commit

Permalink
Fix style manager export "select by tag" only selects some style
Browse files Browse the repository at this point in the history
entity types
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Nov 18, 2021
1 parent ded9c31 commit 0735975
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/gui/symbology/qgsstyleexportimportdialog.cpp
Expand Up @@ -263,14 +263,27 @@ void QgsStyleExportImportDialog::clearSelection()

void QgsStyleExportImportDialog::selectFavorites()
{
const QStringList symbolNames = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity );
selectSymbols( symbolNames );
for ( int row = 0; row < listItems->model()->rowCount(); ++row )
{
const QModelIndex index = listItems->model()->index( row, 0 );
if ( index.data( QgsStyleModel::IsFavoriteRole ).toBool() )
{
listItems->selectionModel()->select( index, QItemSelectionModel::Select );
}
}
}

void QgsStyleExportImportDialog::deselectFavorites()
{
const QStringList symbolNames = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity );
deselectSymbols( symbolNames );
for ( int row = 0; row < listItems->model()->rowCount(); ++row )
{
const QModelIndex index = listItems->model()->index( row, 0 );
if ( index.data( QgsStyleModel::IsFavoriteRole ).toBool() )
{
const QItemSelection deselection( index, index );
listItems->selectionModel()->select( deselection, QItemSelectionModel::Deselect );
}
}
}

void QgsStyleExportImportDialog::selectSymbols( const QStringList &symbolNames )
Expand Down Expand Up @@ -304,14 +317,27 @@ void QgsStyleExportImportDialog::deselectSymbols( const QStringList &symbolNames

void QgsStyleExportImportDialog::selectTag( const QString &tagName )
{
const QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
selectSymbols( symbolNames );
for ( int row = 0; row < listItems->model()->rowCount(); ++row )
{
const QModelIndex index = listItems->model()->index( row, 0 );
if ( index.data( QgsStyleModel::TagRole ).toStringList().contains( tagName, Qt::CaseInsensitive ) )
{
listItems->selectionModel()->select( index, QItemSelectionModel::Select );
}
}
}

void QgsStyleExportImportDialog::deselectTag( const QString &tagName )
{
const QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
deselectSymbols( symbolNames );
for ( int row = 0; row < listItems->model()->rowCount(); ++row )
{
const QModelIndex index = listItems->model()->index( row, 0 );
if ( index.data( QgsStyleModel::TagRole ).toStringList().contains( tagName, Qt::CaseInsensitive ) )
{
const QItemSelection deselection( index, index );
listItems->selectionModel()->select( deselection, QItemSelectionModel::Deselect );
}
}
}

void QgsStyleExportImportDialog::selectSmartgroup( const QString &groupName )
Expand Down

0 comments on commit 0735975

Please sign in to comment.