Skip to content
Permalink
Browse files
Remember the last used tag when closing the style manager window
We intentionally don't remember this between sessions, but just
for the current session only
  • Loading branch information
nyalldawson committed Nov 4, 2021
1 parent cb27c14 commit fa0ae4fc1fa5c51700496b6fb994c8e036b49021
Showing with 9 additions and 1 deletion.
  1. +7 −1 src/gui/symbology/qgsstylemanagerdialog.cpp
  2. +2 −0 src/gui/symbology/qgsstylemanagerdialog.h
@@ -168,6 +168,8 @@ bool QgsCheckableStyleModel::setData( const QModelIndex &i, const QVariant &valu

#include "qgsgui.h"

QString QgsStyleManagerDialog::sPreviousTag;

QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent, Qt::WindowFlags flags, bool readOnly )
: QDialog( parent, flags )
, mStyle( style )
@@ -302,7 +304,9 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
groupTree->setModel( groupModel );
groupTree->setHeaderHidden( true );
populateGroups();
groupTree->setCurrentIndex( groupTree->model()->index( 0, 0 ) );

const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );

connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
this, &QgsStyleManagerDialog::groupChanged );
@@ -2266,6 +2270,8 @@ void QgsStyleManagerDialog::groupChanged( const QModelIndex &index )
QStringList groupSymbols;

const QString category = index.data( Qt::UserRole + 1 ).toString();
sPreviousTag = category;

if ( mGroupingMode )
{
mModel->setTagId( -1 );
@@ -425,6 +425,8 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
bool mSmartGroupVisible = true;
QString mBaseName;

static QString sPreviousTag;

bool addTextFormat();
bool editTextFormat();

0 comments on commit fa0ae4f

Please sign in to comment.