Skip to content
Permalink
Browse files
Default to current selected tag for new items created in style manager
dialog
  • Loading branch information
nyalldawson committed Nov 18, 2021
1 parent 8ff2a90 commit 4c49c77ef1335b9974373d68ed059ea7ad22a08f
Showing with 19 additions and 1 deletion.
  1. +13 −1 src/gui/symbology/qgsstylemanagerdialog.cpp
  2. +6 −0 src/gui/symbology/qgsstylemanagerdialog.h
@@ -676,7 +676,7 @@ void QgsStyleManagerDialog::copyItem()

void QgsStyleManagerDialog::pasteItem()
{
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data().toString() : QString();
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
if ( tempSymbol )
{
@@ -1158,6 +1158,8 @@ bool QgsStyleManagerDialog::addTextFormat()
format = formatDlg.format();

QgsStyleSaveDialog saveDlg( this, QgsStyle::TextFormatEntity );
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
saveDlg.setDefaultTags( defaultTag );
if ( !saveDlg.exec() )
return false;
QString name = saveDlg.name();
@@ -1342,6 +1344,8 @@ bool QgsStyleManagerDialog::addSymbol( int symbolType )
}

QgsStyleSaveDialog saveDlg( this );
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
saveDlg.setDefaultTags( defaultTag );
if ( !saveDlg.exec() )
{
delete symbol;
@@ -1780,6 +1784,8 @@ bool QgsStyleManagerDialog::addLabelSettings( QgsWkbTypes::GeometryType type )
settings.layerType = type;

QgsStyleSaveDialog saveDlg( this, QgsStyle::LabelSettingsEntity );
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
saveDlg.setDefaultTags( defaultTag );
if ( !saveDlg.exec() )
return false;
QString name = saveDlg.name();
@@ -1872,6 +1878,8 @@ bool QgsStyleManagerDialog::addLegendPatchShape( Qgis::SymbolType type )
shape = dialog.shape();

QgsStyleSaveDialog saveDlg( this, QgsStyle::LegendPatchShapeEntity );
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
saveDlg.setDefaultTags( defaultTag );
if ( !saveDlg.exec() )
return false;
QString name = saveDlg.name();
@@ -1969,6 +1977,8 @@ bool QgsStyleManagerDialog::addSymbol3D( const QString &type )
return false;

QgsStyleSaveDialog saveDlg( this, QgsStyle::Symbol3DEntity );
const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
saveDlg.setDefaultTags( defaultTag );
if ( !saveDlg.exec() )
return false;
QString name = saveDlg.name();
@@ -2231,6 +2241,7 @@ void QgsStyleManagerDialog::populateGroups()
{
QStandardItem *item = new QStandardItem( tag );
item->setData( mStyle->tagId( tag ) );
item->setData( tag, GroupModelRoles::TagName );
item->setEditable( !mReadOnly );
taggroup->appendRow( item );
}
@@ -2397,6 +2408,7 @@ int QgsStyleManagerDialog::addTag()
QStandardItem *parentItem = model->itemFromIndex( index );
QStandardItem *childItem = new QStandardItem( itemName );
childItem->setData( id );
childItem->setData( itemName, GroupModelRoles::TagName );
parentItem->appendRow( childItem );

return id;
@@ -364,6 +364,12 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
QString name;
};

enum GroupModelRoles
{
Name = Qt::UserRole + 1,
TagName
};

QList< ItemDetails > selectedItems();

/**

0 comments on commit 4c49c77

Please sign in to comment.