38 #include <QFileDialog>    39 #include <QInputDialog>    40 #include <QMessageBox>    41 #include <QPushButton>    42 #include <QStandardItemModel>    54 QgsCheckableStyleModel::QgsCheckableStyleModel( 
QgsStyleModel *sourceModel, QObject *parent, 
bool readOnly )
    56   , mStyle( sourceModel->style() )
    57   , mReadOnly( readOnly )
    62 QgsCheckableStyleModel::QgsCheckableStyleModel( 
QgsStyle *style, QObject *parent, 
bool readOnly )
    65   , mReadOnly( readOnly )
    69 void QgsCheckableStyleModel::setCheckable( 
bool checkable )
    71   if ( checkable == mCheckable )
    74   mCheckable = checkable;
    75   emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
    78 void QgsCheckableStyleModel::setCheckTag( 
const QString &tag )
    80   if ( tag == mCheckTag )
    84   emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
    87 Qt::ItemFlags QgsCheckableStyleModel::flags( 
const QModelIndex &index )
 const    89   Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
    90   if ( !mReadOnly && mCheckable && index.column() == 0 )
    91     f |= Qt::ItemIsUserCheckable;
    94     f &= ~Qt::ItemIsEditable;
    99 QVariant QgsCheckableStyleModel::data( 
const QModelIndex &index, 
int role )
 const   106       QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
   111     case Qt::CheckStateRole:
   113       if ( !mCheckable || index.column() != 0 )
   117       return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
   124   return QgsStyleProxyModel::data( index, role );
   127 bool QgsCheckableStyleModel::setData( 
const QModelIndex &i, 
const QVariant &value, 
int role )
   129   if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) ||
   130        ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
   136   if ( role == Qt::CheckStateRole )
   138     if ( !mCheckable || mCheckTag.isEmpty() )
   141     const QString name = data( index( i.row(), 
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
   144     if ( value.toInt() == Qt::Checked )
   145       return mStyle->
tagSymbol( entity, name, QStringList() << mCheckTag );
   147       return mStyle->
detagSymbol( entity, name, QStringList() << mCheckTag );
   149   return QgsStyleProxyModel::setData( i, value, role );
   160   : QDialog( parent, flags )
   162   , mReadOnly( readOnly )
   166   connect( tabItemType, &QTabWidget::currentChanged, 
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
   171   mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
   172   mVerticalLayout->insertWidget( 0,  mMessageBar );
   175   setWindowModality( Qt::WindowModal );
   180   mSplitter->setSizes( QList<int>() << 170 << 540 );
   181   mSplitter->restoreState( settings.
value( QStringLiteral( 
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
   183   tabItemType->setDocumentMode( 
true );
   184   searchBox->setShowSearchIcon( 
true );
   185   searchBox->setPlaceholderText( tr( 
"Filter symbols…" ) );
   189   connect( btnEditItem, &QPushButton::clicked, 
this, [ = ]( 
bool ) { 
editItem(); }
   191   connect( actnEditItem, &QAction::triggered, 
this, [ = ]( 
bool ) { 
editItem(); }
   196     connect( btnAddItem, &QPushButton::clicked, 
this, [ = ]( 
bool ) { 
addItem(); }
   199     connect( btnRemoveItem, &QPushButton::clicked, 
this, [ = ]( 
bool ) { 
removeItem(); }
   201     connect( actnRemoveItem, &QAction::triggered, 
this, [ = ]( 
bool ) { 
removeItem(); }
   206     btnAddTag->setEnabled( 
false );
   207     btnAddSmartgroup->setEnabled( 
false );
   210   QMenu *shareMenu = 
new QMenu( tr( 
"Share Menu" ), 
this );
   211   QAction *exportAction = 
new QAction( tr( 
"Export Item(s)…" ), 
this );
   213   shareMenu->addAction( exportAction );
   216     QAction *importAction = 
new QAction( tr( 
"Import Item(s)…" ), 
this );
   218     shareMenu->addAction( importAction );
   223     mActionCopyToDefault = 
new QAction( tr( 
"Copy Selection to Default Style…" ), 
this );
   224     shareMenu->addAction( mActionCopyToDefault );
   225     connect( mActionCopyToDefault, &QAction::triggered, 
this, &QgsStyleManagerDialog::copyItemsToDefault );
   226     connect( mCopyToDefaultButton, &QPushButton::clicked, 
this, &QgsStyleManagerDialog::copyItemsToDefault );
   230     mCopyToDefaultButton->hide();
   233   mActionCopyItem = 
new QAction( tr( 
"Copy Item" ), 
this );
   234   connect( mActionCopyItem, &QAction::triggered, 
this, &QgsStyleManagerDialog::copyItem );
   235   mActionPasteItem = 
new QAction( tr( 
"Paste Item…" ), 
this );
   236   connect( mActionPasteItem, &QAction::triggered, 
this, &QgsStyleManagerDialog::pasteItem );
   238   shareMenu->addSeparator();
   239   shareMenu->addAction( actnExportAsPNG );
   240   shareMenu->addAction( actnExportAsSVG );
   245   btnShare->setMenu( shareMenu );
   247 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)   252   listItems->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) );  
   253 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)   258   mSymbolTreeView->setIconSize( QSize( static_cast< int >( treeIconSize ), static_cast< int >( treeIconSize ) ) );
   261            : 
new QgsCheckableStyleModel( mStyle, 
this, mReadOnly );
   262   mModel->addDesiredIconSize( listItems->iconSize() );
   263   mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
   264   listItems->setModel( mModel );
   265   mSymbolTreeView->setModel( mModel );
   267   listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
   268   listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
   269   mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
   270   mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
   272   connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
   274   connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
   277   QStandardItemModel *groupModel = 
new QStandardItemModel( groupTree );
   278   groupTree->setModel( groupModel );
   279   groupTree->setHeaderHidden( 
true );
   281   groupTree->setCurrentIndex( groupTree->model()->index( 0, 0 ) );
   283   connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
   287     connect( groupModel, &QStandardItemModel::itemChanged,
   293     QMenu *groupMenu = 
new QMenu( tr( 
"Group Actions" ), 
this );
   295     groupMenu->addAction( actnTagSymbols );
   297     actnFinishTagging->setVisible( 
false );
   298     groupMenu->addAction( actnFinishTagging );
   299     groupMenu->addAction( actnEditSmartGroup );
   300     btnManageGroups->setMenu( groupMenu );
   304     btnManageGroups->setEnabled( 
false );
   310   groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
   311   connect( groupTree, &QWidget::customContextMenuRequested,
   315   listItems->setContextMenuPolicy( Qt::CustomContextMenu );
   316   connect( listItems, &QWidget::customContextMenuRequested,
   318   mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
   319   connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
   325     QStringList rampTypes;
   326     rampTypes << tr( 
"Gradient…" ) << tr( 
"Color presets…" ) << tr( 
"Random…" ) << tr( 
"Catalog: cpt-city…" );
   327     rampTypes << tr( 
"Catalog: ColorBrewer…" );
   329     mMenuBtnAddItemAll = 
new QMenu( 
this );
   330     mMenuBtnAddItemColorRamp = 
new QMenu( 
this );
   331     mMenuBtnAddItemLabelSettings = 
new QMenu( 
this );
   335     mMenuBtnAddItemAll->addAction( item );
   338     mMenuBtnAddItemAll->addAction( item );
   341     mMenuBtnAddItemAll->addAction( item );
   342     mMenuBtnAddItemAll->addSeparator();
   343     for ( 
const QString &rampType : qgis::as_const( rampTypes ) )
   346       connect( item, &QAction::triggered, 
this, [ = ]( 
bool ) { 
addColorRamp( item ); } );
   347       mMenuBtnAddItemAll->addAction( item );
   348       mMenuBtnAddItemColorRamp->addAction( 
new QAction( rampType, 
this ) );
   350     mMenuBtnAddItemAll->addSeparator();
   352     connect( item, &QAction::triggered, 
this, [ = ]( 
bool ) { addTextFormat(); } );
   353     mMenuBtnAddItemAll->addAction( item );
   354     mMenuBtnAddItemAll->addSeparator();
   357     mMenuBtnAddItemAll->addAction( item );
   358     mMenuBtnAddItemLabelSettings->addAction( item );
   361     mMenuBtnAddItemAll->addAction( item );
   362     mMenuBtnAddItemLabelSettings->addAction( item );
   365     mMenuBtnAddItemAll->addAction( item );
   366     mMenuBtnAddItemLabelSettings->addAction( item );
   368     connect( mMenuBtnAddItemColorRamp, &QMenu::triggered,
   373   mGroupMenu = 
new QMenu( 
this );
   374   mGroupListMenu = 
new QMenu( mGroupMenu );
   375   mGroupListMenu->setTitle( tr( 
"Add to Tag" ) );
   376   mGroupListMenu->setEnabled( 
false );
   380     mGroupMenu->addAction( actnAddFavorite );
   382     mGroupMenu->addAction( actnRemoveFavorite );
   383     mGroupMenu->addSeparator()->setParent( 
this );
   384     mGroupMenu->addMenu( mGroupListMenu );
   385     actnDetag->setData( 0 );
   387     mGroupMenu->addAction( actnDetag );
   388     mGroupMenu->addSeparator()->setParent( 
this );
   389     mGroupMenu->addAction( actnRemoveItem );
   390     mGroupMenu->addAction( actnEditItem );
   391     mGroupMenu->addAction( mActionCopyItem );
   392     mGroupMenu->addAction( mActionPasteItem );
   393     mGroupMenu->addSeparator()->setParent( 
this );
   397     btnAddItem->setVisible( 
false );
   398     btnRemoveItem->setVisible( 
false );
   399     btnEditItem->setVisible( 
false );
   400     btnAddSmartgroup->setVisible( 
false );
   401     btnAddTag->setVisible( 
false );
   402     btnManageGroups->setVisible( 
false );
   404     mGroupMenu->addAction( mActionCopyItem );
   406   if ( mActionCopyToDefault )
   408     mGroupMenu->addAction( mActionCopyToDefault );
   410   mGroupMenu->addAction( actnExportAsPNG );
   411   mGroupMenu->addAction( actnExportAsSVG );
   414   mGroupTreeContextMenu = 
new QMenu( 
this );
   418     mGroupTreeContextMenu->addAction( actnEditSmartGroup );
   419     connect( actnAddTag, &QAction::triggered, 
this, [ = ]( 
bool ) { 
addTag(); }
   421     mGroupTreeContextMenu->addAction( actnAddTag );
   422     connect( actnAddSmartgroup, &QAction::triggered, 
this, [ = ]( 
bool ) { 
addSmartgroup(); }
   424     mGroupTreeContextMenu->addAction( actnAddSmartgroup );
   426     mGroupTreeContextMenu->addAction( actnRemoveGroup );
   429   tabItemType_currentChanged( 0 );
   434   connect( mButtonIconView, &QToolButton::toggled, 
this, [ = ]( 
bool active )
   438       mSymbolViewStackedWidget->setCurrentIndex( 0 );
   443   connect( mButtonListView, &QToolButton::toggled, 
this, [ = ]( 
bool active )
   448       mSymbolViewStackedWidget->setCurrentIndex( 1 );
   452   const int currentView = settings.
value( QStringLiteral( 
"Windows/StyleV2Manager/lastIconView" ), 0, 
QgsSettings::Gui ).toInt();
   453   if ( currentView == 0 )
   454     mButtonIconView->setChecked( 
true );
   456     mButtonListView->setChecked( 
true );
   458   mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral( 
"Windows/StyleV2Manager/treeState" ), QByteArray(), 
QgsSettings::Gui ).toByteArray() );
   459   connect( mSymbolTreeView->header(), &QHeaderView::sectionResized, 
this, [
this]
   471   if ( mModified && !mReadOnly )
   477   settings.
setValue( QStringLiteral( 
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
   484 void QgsStyleManagerDialog::tabItemType_currentChanged( 
int )
   490   searchBox->setPlaceholderText( isSymbol ? tr( 
"Filter symbols…" ) :
   491                                  isColorRamp ? tr( 
"Filter color ramps…" ) :
   492                                  isTextFormat ? tr( 
"Filter text symbols…" ) : tr( 
"Filter label settings…" ) );
   494   if ( !mReadOnly && isColorRamp ) 
   496     btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
   498   if ( !mReadOnly && !isSymbol && !isColorRamp && !isTextFormat ) 
   500     btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
   502   else if ( !mReadOnly && !isSymbol && !isColorRamp ) 
   504     btnAddItem->setMenu( 
nullptr );
   506   else if ( !mReadOnly && tabItemType->currentIndex() == 0 ) 
   508     btnAddItem->setMenu( mMenuBtnAddItemAll );
   512     btnAddItem->setMenu( 
nullptr );
   515   actnExportAsPNG->setVisible( isSymbol );
   516   actnExportAsSVG->setVisible( isSymbol );
   519   mModel->setEntityFilterEnabled( !allTypesSelected() );
   520   mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
   521   if ( isSymbol && !allTypesSelected() )
   522     mModel->setSymbolType( static_cast< QgsSymbol::SymbolType >( 
currentItemType() ) );
   527 void QgsStyleManagerDialog::copyItemsToDefault()
   529   const QList< ItemDetails > items = selectedItems();
   530   if ( !items.empty() )
   534     if ( !mBaseName.isEmpty() )
   535       options.append( mBaseName );
   538     defaultTags.sort( Qt::CaseInsensitive );
   539     options.append( defaultTags );
   540     const QString tags = QInputDialog::getItem( 
this, tr( 
"Import Items" ),
   541                          tr( 
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0, 
true, &ok );
   545     const QStringList parts = tags.split( 
',', QString::SkipEmptyParts );
   546     QStringList additionalTags;
   547     additionalTags.reserve( parts.count() );
   548     for ( 
const QString &tag : parts )
   549       additionalTags << tag.trimmed();
   551     auto cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
   552     const int count = copyItems( items, mStyle, 
QgsStyle::defaultStyle(), 
this, cursorOverride, 
true, additionalTags, 
false, 
false );
   553     cursorOverride.reset();
   556       mMessageBar->
pushSuccess( tr( 
"Import Items" ), count > 1 ? tr( 
"Successfully imported %1 items." ).arg( count ) : tr( 
"Successfully imported item." ) );
   561 void QgsStyleManagerDialog::copyItem()
   563   const QList< ItemDetails > items = selectedItems();
   567   ItemDetails details = items.at( 0 );
   568   switch ( details.entityType )
   572       std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
   582       QApplication::clipboard()->setMimeData( format.toMimeData() );
   589       QApplication::clipboard()->setMimeData( format.toMimeData() );
   601 void QgsStyleManagerDialog::pasteItem()
   603   const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data().toString() : QString();
   607     QgsStyleSaveDialog saveDlg( 
this );
   608     saveDlg.setWindowTitle( tr( 
"Paste Symbol" ) );
   609     saveDlg.setDefaultTags( defaultTag );
   610     if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
   613     if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
   615       int res = QMessageBox::warning( 
this, tr( 
"Paste Symbol" ),
   616                                       tr( 
"A symbol with the name '%1' already exists. Overwrite?" )
   617                                       .arg( saveDlg.name() ),
   618                                       QMessageBox::Yes | QMessageBox::No );
   619       if ( res != QMessageBox::Yes )
   626     QStringList symbolTags = saveDlg.tags().split( 
',' );
   627     mStyle->
addSymbol( saveDlg.name(), tempSymbol->clone() );
   629     mStyle->
saveSymbol( saveDlg.name(), tempSymbol->clone(), saveDlg.isFavorite(), symbolTags );
   637     QgsStyleSaveDialog saveDlg( 
this );
   638     saveDlg.setDefaultTags( defaultTag );
   639     saveDlg.setWindowTitle( tr( 
"Paste Text Format" ) );
   640     if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
   645       int res = QMessageBox::warning( 
this, tr( 
"Paste Text Format" ),
   646                                       tr( 
"A format with the name '%1' already exists. Overwrite?" )
   647                                       .arg( saveDlg.name() ),
   648                                       QMessageBox::Yes | QMessageBox::No );
   649       if ( res != QMessageBox::Yes )
   656     QStringList symbolTags = saveDlg.tags().split( 
',' );
   659     mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
   664 int QgsStyleManagerDialog::selectedItemType()
   666   QModelIndex index = listItems->selectionModel()->currentIndex();
   667   if ( !index.isValid() )
   681 bool QgsStyleManagerDialog::allTypesSelected()
 const   683   return tabItemType->currentIndex() == 0;
   686 QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
   688   QList<QgsStyleManagerDialog::ItemDetails > res;
   689   QModelIndexList indices = listItems->selectionModel()->selectedRows();
   690   for ( 
const QModelIndex &index : indices )
   692     if ( !index.isValid() )
   699     details.name = mModel->data( mModel->index( index.row(), 
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
   706 int QgsStyleManagerDialog::copyItems( 
const QList<QgsStyleManagerDialog::ItemDetails> &items, 
QgsStyle *src, 
QgsStyle *dst, QWidget *parentWidget,
   707                                       std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride, 
bool isImport, 
const QStringList &importTags, 
bool addToFavorites, 
bool ignoreSourceTags )
   710   bool overwriteAll = 
true;
   718   for ( 
auto &details : items )
   720     QStringList symbolTags;
   721     if ( !ignoreSourceTags )
   723       symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
   726     bool addItemToFavorites = 
false;
   729       symbolTags << importTags;
   730       addItemToFavorites = addToFavorites;
   733     switch ( details.entityType )
   737         std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
   741         const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
   742         bool overwriteThis = 
false;
   744           addItemToFavorites = favoriteSymbols.contains( details.name );
   746         if ( hasDuplicateName && prompt )
   748           cursorOverride.reset();
   749           int res = QMessageBox::warning( parentWidget, isImport ? tr( 
"Import Symbol" ) : tr( 
"Export Symbol" ),
   750                                           tr( 
"A symbol with the name “%1” already exists.\nOverwrite?" )
   751                                           .arg( details.name ),
   752                                           QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
   753           cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
   756             case QMessageBox::Cancel:
   759             case QMessageBox::No:
   762             case QMessageBox::Yes:
   763               overwriteThis = 
true;
   766             case QMessageBox::YesToAll:
   771             case QMessageBox::NoToAll:
   773               overwriteAll = 
false;
   778         if ( !hasDuplicateName || overwriteAll || overwriteThis )
   781           dst->
addSymbol( details.name, symbol.release() );
   782           dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
   790         std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
   794         const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
   795         bool overwriteThis = 
false;
   797           addItemToFavorites = favoriteColorramps.contains( details.name );
   799         if ( hasDuplicateName && prompt )
   801           cursorOverride.reset();
   802           int res = QMessageBox::warning( parentWidget, isImport ? tr( 
"Import Color Ramp" ) : tr( 
"Export Color Ramp" ),
   803                                           tr( 
"A color ramp with the name “%1” already exists.\nOverwrite?" )
   804                                           .arg( details.name ),
   805                                           QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
   806           cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
   809             case QMessageBox::Cancel:
   812             case QMessageBox::No:
   815             case QMessageBox::Yes:
   816               overwriteThis = 
true;
   819             case QMessageBox::YesToAll:
   824             case QMessageBox::NoToAll:
   826               overwriteAll = 
false;
   831         if ( !hasDuplicateName || overwriteAll || overwriteThis )
   835           dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
   845         const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
   846         bool overwriteThis = 
false;
   848           addItemToFavorites = favoriteTextFormats.contains( details.name );
   850         if ( hasDuplicateName && prompt )
   852           cursorOverride.reset();
   853           int res = QMessageBox::warning( parentWidget, isImport ? tr( 
"Import Text Format" ) : tr( 
"Export Text Format" ),
   854                                           tr( 
"A text format with the name “%1” already exists.\nOverwrite?" )
   855                                           .arg( details.name ),
   856                                           QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
   857           cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
   860             case QMessageBox::Cancel:
   863             case QMessageBox::No:
   866             case QMessageBox::Yes:
   867               overwriteThis = 
true;
   870             case QMessageBox::YesToAll:
   875             case QMessageBox::NoToAll:
   877               overwriteAll = 
false;
   882         if ( !hasDuplicateName || overwriteAll || overwriteThis )
   885           dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
   896         bool overwriteThis = 
false;
   898           addItemToFavorites = favoriteLabelSettings.contains( details.name );
   900         if ( hasDuplicateName && prompt )
   902           cursorOverride.reset();
   903           int res = QMessageBox::warning( parentWidget, isImport ? tr( 
"Import Label Settings" ) : tr( 
"Export Label Settings" ),
   904                                           tr( 
"Label settings with the name “%1” already exist.\nOverwrite?" )
   905                                           .arg( details.name ),
   906                                           QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
   907           cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
   910             case QMessageBox::Cancel:
   913             case QMessageBox::No:
   916             case QMessageBox::Yes:
   917               overwriteThis = 
true;
   920             case QMessageBox::YesToAll:
   925             case QMessageBox::NoToAll:
   927               overwriteAll = 
false;
   932         if ( !hasDuplicateName || overwriteAll || overwriteThis )
   935           dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
   950 bool QgsStyleManagerDialog::addTextFormat()
   954   if ( !formatDlg.exec() )
   956   format = formatDlg.
format();
   958   QgsStyleSaveDialog saveDlg( 
this );
   959   if ( !saveDlg.exec() )
   961   QString name = saveDlg.name();
   964   bool nameInvalid = 
true;
   965   while ( nameInvalid )
   968     if ( name.isEmpty() )
   970       QMessageBox::warning( 
this, tr( 
"Save Text Format" ),
   971                             tr( 
"Cannot save text format without name. Enter a name." ) );
   975       int res = QMessageBox::warning( 
this, tr( 
"Save Text Format" ),
   976                                       tr( 
"Text format with name '%1' already exists. Overwrite?" )
   978                                       QMessageBox::Yes | QMessageBox::No );
   979       if ( res == QMessageBox::Yes )
   993       name = QInputDialog::getText( 
this, tr( 
"Text Format Name" ),
   994                                     tr( 
"Please enter a name for new text format:" ),
   995                                     QLineEdit::Normal, name, &ok );
  1003   QStringList symbolTags = saveDlg.tags().split( 
',' );
  1007   mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
  1015   groupChanged( groupTree->selectionModel()->currentIndex() );
  1028   switch ( tabItemType->currentIndex() )
  1049   QModelIndex index = listItems->selectionModel()->currentIndex();
  1050   if ( !index.isValid() )
  1053   return mModel->data( mModel->index( index.row(), 
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
  1058   bool changed = 
false;
  1069     changed = addTextFormat();
  1077     Q_ASSERT( 
false && 
"not implemented" );
  1090   QString name = tr( 
"new symbol" );
  1095       name = tr( 
"new marker" );
  1099       name = tr( 
"new line" );
  1103       name = tr( 
"new fill symbol" );
  1106       Q_ASSERT( 
false && 
"unknown symbol type" );
  1116   if ( dlg.exec() == 0 )
  1122   QgsStyleSaveDialog saveDlg( 
this );
  1123   if ( !saveDlg.exec() )
  1129   name = saveDlg.name();
  1132   bool nameInvalid = 
true;
  1133   while ( nameInvalid )
  1136     if ( name.isEmpty() )
  1138       QMessageBox::warning( 
this, tr( 
"Save Symbol" ),
  1139                             tr( 
"Cannot save symbol without name. Enter a name." ) );
  1141     else if ( mStyle->
symbolNames().contains( name ) )
  1143       int res = QMessageBox::warning( 
this, tr( 
"Save Symbol" ),
  1144                                       tr( 
"Symbol with name '%1' already exists. Overwrite?" )
  1146                                       QMessageBox::Yes | QMessageBox::No );
  1147       if ( res == QMessageBox::Yes )
  1150         nameInvalid = 
false;
  1156       nameInvalid = 
false;
  1161       name = QInputDialog::getText( 
this, tr( 
"Symbol Name" ),
  1162                                     tr( 
"Please enter a name for new symbol:" ),
  1163                                     QLineEdit::Normal, name, &ok );
  1172   QStringList symbolTags = saveDlg.tags().split( 
',' );
  1176   mStyle->
saveSymbol( name, symbol, saveDlg.isFavorite(), symbolTags );
  1187   if ( rampType.isEmpty() )
  1189     QStringList rampTypes;
  1190     rampTypes << tr( 
"Gradient" ) << tr( 
"Color presets" ) << tr( 
"Random" ) << tr( 
"Catalog: cpt-city" );
  1191     rampTypes << tr( 
"Catalog: ColorBrewer" );
  1192     rampType = QInputDialog::getItem( parent, tr( 
"Color Ramp Type" ),
  1193                                       tr( 
"Please select color ramp type:" ), rampTypes, 0, 
false, &ok );
  1195   if ( !ok || rampType.isEmpty() )
  1198   QString name = tr( 
"new ramp" );
  1200   std::unique_ptr< QgsColorRamp  > ramp;
  1201   if ( rampType == tr( 
"Gradient" ) )
  1209     name = tr( 
"new gradient ramp" );
  1211   else if ( rampType == tr( 
"Random" ) )
  1219     name = tr( 
"new random ramp" );
  1221   else if ( rampType == tr( 
"Catalog: ColorBrewer" ) )
  1231   else if ( rampType == tr( 
"Color presets" ) )
  1239     name = tr( 
"new preset ramp" );
  1241   else if ( rampType == tr( 
"Catalog: cpt-city" ) )
  1263     QgsDebugMsg( QStringLiteral( 
"invalid ramp type %1" ).arg( rampType ) );
  1268   if ( !saveDlg.exec() )
  1273   name = saveDlg.name();
  1276   bool nameInvalid = 
true;
  1277   while ( nameInvalid )
  1280     if ( name.isEmpty() )
  1282       QMessageBox::warning( parent, tr( 
"Save Color Ramp" ),
  1283                             tr( 
"Cannot save color ramp without name. Enter a name." ) );
  1287       int res = QMessageBox::warning( parent, tr( 
"Save Color Ramp" ),
  1288                                       tr( 
"Color ramp with name '%1' already exists. Overwrite?" )
  1290                                       QMessageBox::Yes | QMessageBox::No );
  1291       if ( res == QMessageBox::Yes )
  1293         nameInvalid = 
false;
  1299       nameInvalid = 
false;
  1304       name = QInputDialog::getText( parent, tr( 
"Color Ramp Name" ),
  1305                                     tr( 
"Please enter a name for new color ramp:" ),
  1306                                     QLineEdit::Normal, name, &ok );
  1314   QStringList colorRampTags = saveDlg.tags().split( 
',' );
  1319   style->
saveColorRamp( name, r, saveDlg.isFavorite(), colorRampTags );
  1326   mFavoritesGroupVisible = show;
  1332   mSmartGroupVisible = show;
  1344   setWindowState( windowState() & ~Qt::WindowMinimized );
  1357                                          action ? action->text() : QString() );
  1358   if ( !rampName.isEmpty() )
  1370   if ( selectedItemType() < 3 )
  1374   else if ( selectedItemType() == 3 )
  1378   else if ( selectedItemType() == 4 )
  1382   else if ( selectedItemType() == 5 )
  1384     editLabelSettings();
  1388     Q_ASSERT( 
false && 
"not implemented" );
  1395   if ( symbolName.isEmpty() )
  1398   std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
  1403     dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1409   mStyle->
addSymbol( symbolName, symbol.release(), true );
  1417   if ( name.isEmpty() )
  1420   std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
  1422   if ( ramp->type() == QLatin1String( 
"gradient" ) )
  1427       dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1435   else if ( ramp->type() == QLatin1String( 
"random" ) )
  1440       dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1448   else if ( ramp->type() == QLatin1String( 
"colorbrewer" ) )
  1453       dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1461   else if ( ramp->type() == QLatin1String( 
"preset" ) )
  1466       dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1474   else if ( ramp->type() == QLatin1String( 
"cpt-city" ) )
  1479       dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1496     Q_ASSERT( 
false && 
"invalid ramp type" );
  1504 bool QgsStyleManagerDialog::editTextFormat()
  1507   if ( formatName.isEmpty() )
  1515     dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1529   QgsLabelSettingsDialog settingsDlg( settings, 
nullptr, 
nullptr, 
this, type );
  1531     settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( 
false );
  1533   if ( !settingsDlg.exec() )
  1536   settings = settingsDlg.settings();
  1539   QgsStyleSaveDialog saveDlg( 
this );
  1540   if ( !saveDlg.exec() )
  1542   QString name = saveDlg.name();
  1545   bool nameInvalid = 
true;
  1546   while ( nameInvalid )
  1549     if ( name.isEmpty() )
  1551       QMessageBox::warning( 
this, tr( 
"Save Label Settings" ),
  1552                             tr( 
"Cannot save label settings without a name. Enter a name." ) );
  1556       int res = QMessageBox::warning( 
this, tr( 
"Save Label Settings" ),
  1557                                       tr( 
"Label settings with the name '%1' already exist. Overwrite?" )
  1559                                       QMessageBox::Yes | QMessageBox::No );
  1560       if ( res == QMessageBox::Yes )
  1563         nameInvalid = 
false;
  1569       nameInvalid = 
false;
  1574       name = QInputDialog::getText( 
this, tr( 
"Label Settings Name" ),
  1575                                     tr( 
"Please enter a name for the new label settings:" ),
  1576                                     QLineEdit::Normal, name, &ok );
  1584   QStringList symbolTags = saveDlg.tags().split( 
',' );
  1594 bool QgsStyleManagerDialog::editLabelSettings()
  1597   if ( formatName.isEmpty() )
  1604   QgsLabelSettingsDialog dlg( settings, 
nullptr, 
nullptr, 
this, geomType );
  1608   settings = dlg.settings();
  1620   const QList< ItemDetails > items = selectedItems();
  1622   if ( allTypesSelected() )
  1624     if ( QMessageBox::Yes != QMessageBox::question( 
this, tr( 
"Remove Items" ),
  1625          QString( tr( 
"Do you really want to remove %n item(s)?", 
nullptr, items.count() ) ),
  1634       if ( QMessageBox::Yes != QMessageBox::question( 
this, tr( 
"Remove Symbol" ),
  1635            QString( tr( 
"Do you really want to remove %n symbol(s)?", 
nullptr, items.count() ) ),
  1642       if ( QMessageBox::Yes != QMessageBox::question( 
this, tr( 
"Remove Color Ramp" ),
  1643            QString( tr( 
"Do you really want to remove %n ramp(s)?", 
nullptr, items.count() ) ),
  1650       if ( QMessageBox::Yes != QMessageBox::question( 
this, tr( 
"Remove Text Formats" ),
  1651            QString( tr( 
"Do you really want to remove %n text format(s)?", 
nullptr, items.count() ) ),
  1658       if ( QMessageBox::Yes != QMessageBox::question( 
this, tr( 
"Remove Label Settings" ),
  1659            QString( tr( 
"Do you really want to remove %n label settings?", 
nullptr, items.count() ) ),
  1668   for ( 
const ItemDetails &details : items )
  1670     if ( details.name.isEmpty() )
  1673     switch ( details.entityType )
  1716   QString dir = QFileDialog::getExistingDirectory( 
this, tr( 
"Export Selected Symbols as PNG" ),
  1717                 QDir::home().absolutePath(),
  1718                 QFileDialog::ShowDirsOnly
  1719                 | QFileDialog::DontResolveSymlinks );
  1725   QString dir = QFileDialog::getExistingDirectory( 
this, tr( 
"Export Selected Symbols as SVG" ),
  1726                 QDir::home().absolutePath(),
  1727                 QFileDialog::ShowDirsOnly
  1728                 | QFileDialog::DontResolveSymlinks );
  1735   if ( dir.isEmpty() )
  1738   const QList< ItemDetails > items = selectedItems();
  1739   for ( 
const ItemDetails &details : items )
  1744     QString path = dir + 
'/' + details.name + 
'.' + format;
  1745     std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
  1747       sym->exportImage( path, format, size );
  1767   QFont font = item->font();
  1768   font.setBold( 
true );
  1769   item->setFont( font );
  1774   if ( mBlockGroupUpdates )
  1777   QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
  1780   if ( mFavoritesGroupVisible )
  1782     QStandardItem *favoriteSymbols = 
new QStandardItem( tr( 
"Favorites" ) );
  1783     favoriteSymbols->setData( 
"favorite" );
  1784     favoriteSymbols->setEditable( 
false );
  1786     model->appendRow( favoriteSymbols );
  1789   QStandardItem *allSymbols = 
new QStandardItem( tr( 
"All" ) );
  1790   allSymbols->setData( 
"all" );
  1791   allSymbols->setEditable( 
false );
  1793   model->appendRow( allSymbols );
  1795   QStandardItem *taggroup = 
new QStandardItem( QString() ); 
  1796   taggroup->setData( 
"tags" );
  1797   taggroup->setEditable( 
false );
  1798   QStringList tags = mStyle->
tags();
  1800   for ( 
const QString &tag : qgis::as_const( tags ) )
  1802     QStandardItem *item = 
new QStandardItem( tag );
  1803     item->setData( mStyle->
tagId( tag ) );
  1804     item->setEditable( !mReadOnly );
  1805     taggroup->appendRow( item );
  1807   taggroup->setText( tr( 
"Tags" ) );
  1809   model->appendRow( taggroup );
  1811   if ( mSmartGroupVisible )
  1813     QStandardItem *smart = 
new QStandardItem( tr( 
"Smart Groups" ) );
  1814     smart->setData( 
"smartgroups" );
  1815     smart->setEditable( 
false );
  1818     QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
  1819     while ( i != sgMap.constEnd() )
  1821       QStandardItem *item = 
new QStandardItem( i.value() );
  1822       item->setData( i.key() );
  1823       item->setEditable( !mReadOnly );
  1824       smart->appendRow( item );
  1827     model->appendRow( smart );
  1831   int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
  1832   for ( 
int i = 0; i < rows; i++ )
  1834     groupTree->setExpanded( model->indexFromItem( model->item( i ) ), 
true );
  1840   QStringList groupSymbols;
  1842   const QString category = index.data( Qt::UserRole + 1 ).toString();
  1843   if ( mGroupingMode )
  1845     mModel->setTagId( -1 );
  1846     mModel->setSmartGroupId( -1 );
  1847     mModel->setFavoritesOnly( 
false );
  1848     mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
  1850   else if ( category == QLatin1String( 
"all" ) || category == QLatin1String( 
"tags" ) || category == QLatin1String( 
"smartgroups" ) )
  1853     if ( category == QLatin1String( 
"tags" ) )
  1855       actnAddTag->setEnabled( !mReadOnly );
  1856       actnAddSmartgroup->setEnabled( 
false );
  1858     else if ( category == QLatin1String( 
"smartgroups" ) )
  1860       actnAddTag->setEnabled( 
false );
  1861       actnAddSmartgroup->setEnabled( !mReadOnly );
  1864     mModel->setTagId( -1 );
  1865     mModel->setSmartGroupId( -1 );
  1866     mModel->setFavoritesOnly( 
false );
  1868   else if ( category == QLatin1String( 
"favorite" ) )
  1871     mModel->setTagId( -1 );
  1872     mModel->setSmartGroupId( -1 );
  1873     mModel->setFavoritesOnly( 
true );
  1875   else if ( index.parent().data( Qt::UserRole + 1 ) == 
"smartgroups" )
  1877     actnRemoveGroup->setEnabled( !mReadOnly );
  1878     btnManageGroups->setEnabled( !mReadOnly );
  1879     const int groupId = index.data( Qt::UserRole + 1 ).toInt();
  1880     mModel->setTagId( -1 );
  1881     mModel->setSmartGroupId( groupId );
  1882     mModel->setFavoritesOnly( 
false );
  1887     int tagId = index.data( Qt::UserRole + 1 ).toInt();
  1888     mModel->setTagId( tagId );
  1889     mModel->setSmartGroupId( -1 );
  1890     mModel->setFavoritesOnly( 
false );
  1893   actnEditSmartGroup->setVisible( 
false );
  1894   actnAddTag->setVisible( 
false );
  1895   actnAddSmartgroup->setVisible( 
false );
  1896   actnRemoveGroup->setVisible( 
false );
  1897   actnTagSymbols->setVisible( 
false );
  1898   actnFinishTagging->setVisible( 
false );
  1900   if ( index.parent().isValid() )
  1902     if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String( 
"smartgroups" ) )
  1904       actnEditSmartGroup->setVisible( !mGroupingMode && !mReadOnly );
  1906     else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String( 
"tags" ) )
  1908       actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
  1909       actnTagSymbols->setVisible( !mGroupingMode && !mReadOnly );
  1910       actnFinishTagging->setVisible( mGroupingMode && !mReadOnly );
  1912     actnRemoveGroup->setVisible( !mReadOnly );
  1914   else if ( index.data( Qt::UserRole + 1 ) == 
"smartgroups" )
  1916     actnAddSmartgroup->setVisible( !mGroupingMode && !mReadOnly );
  1918   else if ( index.data( Qt::UserRole + 1 ) == 
"tags" )
  1920     actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
  1926   QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
  1928   for ( 
int i = 0; i < groupTree->model()->rowCount(); i++ )
  1930     index = groupTree->model()->index( i, 0 );
  1931     QString data = index.data( Qt::UserRole + 1 ).toString();
  1932     if ( data == QLatin1String( 
"tags" ) )
  1941   itemName = QInputDialog::getText( 
this, tr( 
"Add Tag" ),
  1942                                     tr( 
"Please enter name for the new tag:" ), QLineEdit::Normal, tr( 
"New tag" ), &ok ).trimmed();
  1943   if ( !ok || itemName.isEmpty() )
  1946   int check = mStyle->
tagId( itemName );
  1949     mMessageBar->
pushCritical( tr( 
"Add Tag" ), tr( 
"The tag “%1” already exists." ).arg( itemName ) );
  1955   mBlockGroupUpdates++;
  1956   id = mStyle->
addTag( itemName );
  1957   mBlockGroupUpdates--;
  1961     mMessageBar->
pushCritical( tr( 
"Add Tag" ),  tr( 
"New tag could not be created — There was a problem with the symbol database." ) );
  1965   QStandardItem *parentItem = model->itemFromIndex( index );
  1966   QStandardItem *childItem = 
new QStandardItem( itemName );
  1967   childItem->setData( 
id );
  1968   parentItem->appendRow( childItem );
  1975   QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
  1977   for ( 
int i = 0; i < groupTree->model()->rowCount(); i++ )
  1979     index = groupTree->model()->index( i, 0 );
  1980     QString data = index.data( Qt::UserRole + 1 ).toString();
  1981     if ( data == QLatin1String( 
"smartgroups" ) )
  1990   if ( dlg.exec() == QDialog::Rejected )
  1995   mBlockGroupUpdates++;
  1997   mBlockGroupUpdates--;
  2003   QStandardItem *parentItem = model->itemFromIndex( index );
  2004   QStandardItem *childItem = 
new QStandardItem( itemName );
  2005   childItem->setData( 
id );
  2006   parentItem->appendRow( childItem );
  2013   QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
  2014   QModelIndex index = groupTree->currentIndex();
  2017   QString data = index.data( Qt::UserRole + 1 ).toString();
  2018   if ( data == QLatin1String( 
"all" ) || data == QLatin1String( 
"favorite" ) || data == QLatin1String( 
"tags" ) || index.data() == 
"smartgroups" )
  2021     int err = QMessageBox::critical( 
this, tr( 
"Remove Group" ),
  2022                                      tr( 
"Invalid selection. Cannot delete system defined categories.\n"  2023                                          "Kindly select a group or smart group you might want to delete." ) );
  2028   QStandardItem *parentItem = model->itemFromIndex( index.parent() );
  2032   mBlockGroupUpdates++;
  2034   if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String( 
"smartgroups" ) )
  2043   mBlockGroupUpdates--;
  2044   parentItem->removeRow( index.row() );
  2049   QgsDebugMsg( QStringLiteral( 
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ) );
  2050   int id = item->data( Qt::UserRole + 1 ).toInt();
  2051   QString name = item->text();
  2052   mBlockGroupUpdates++;
  2053   if ( item->parent()->data( Qt::UserRole + 1 ) == 
"smartgroups" )
  2061   mBlockGroupUpdates--;
  2066   QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
  2068   if ( mGroupingMode )
  2070     mGroupingMode = 
false;
  2071     mModel->setCheckable( 
false );
  2072     actnTagSymbols->setVisible( 
true );
  2073     actnFinishTagging->setVisible( 
false );
  2081     connect( treeModel, &QStandardItemModel::itemChanged,
  2085     listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
  2086     mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
  2090     bool validGroup = 
false;
  2092     QModelIndex present = groupTree->currentIndex();
  2093     while ( present.parent().isValid() )
  2095       if ( present.parent().data() == 
"Tags" )
  2100       present = present.parent();
  2105     mGroupingMode = 
true;
  2107     actnTagSymbols->setVisible( 
false );
  2108     actnFinishTagging->setVisible( 
true );
  2110     disconnect( treeModel, &QStandardItemModel::itemChanged,
  2116     btnManageGroups->setEnabled( 
true );
  2118     mModel->setCheckable( 
true );
  2121     listItems->setSelectionMode( QAbstractItemView::NoSelection );
  2122     mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
  2136   mModel->setFilterString( qword );
  2141   actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !mReadOnly );
  2146   Q_UNUSED( selected )
  2147   Q_UNUSED( deselected )
  2148   bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
  2149   actnRemoveItem->setDisabled( nothingSelected || mReadOnly );
  2150   actnAddFavorite->setDisabled( nothingSelected || mReadOnly );
  2151   actnRemoveFavorite->setDisabled( nothingSelected || mReadOnly );
  2152   mGroupListMenu->setDisabled( nothingSelected || mReadOnly );
  2153   actnDetag->setDisabled( nothingSelected || mReadOnly );
  2154   actnExportAsPNG->setDisabled( nothingSelected );
  2155   actnExportAsSVG->setDisabled( nothingSelected );
  2156   if ( mActionCopyToDefault )
  2157     mActionCopyToDefault->setDisabled( nothingSelected );
  2158   mCopyToDefaultButton->setDisabled( nothingSelected );
  2159   actnEditItem->setDisabled( nothingSelected || mReadOnly );
  2164   groupTree->setEnabled( enable );
  2165   btnAddTag->setEnabled( enable && !mReadOnly );
  2166   btnAddSmartgroup->setEnabled( enable && !mReadOnly );
  2167   actnAddTag->setEnabled( enable && !mReadOnly );
  2168   actnAddSmartgroup->setEnabled( enable && !mReadOnly );
  2169   actnRemoveGroup->setEnabled( enable && !mReadOnly );
  2170   btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) ); 
  2171   searchBox->setEnabled( enable );
  2176   actnRemoveGroup->setEnabled( enable && !mReadOnly );
  2177   btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) ); 
  2182   QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
  2183   for ( 
int i = 0; i < treeModel->rowCount(); i++ )
  2185     treeModel->item( i )->setEnabled( enable );
  2187     if ( treeModel->item( i )->data() == 
"smartgroups" )
  2189       for ( 
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
  2191         treeModel->item( i )->child( j )->setEnabled( enable );
  2198   for ( 
int i = 0; i < symbolBtnsLayout->count(); i++ )
  2200     QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
  2202       w->setEnabled( enable );
  2206   actnRemoveItem->setEnabled( enable );
  2207   actnEditItem->setEnabled( enable );
  2208   mActionCopyItem->setEnabled( enable );
  2209   mActionPasteItem->setEnabled( enable );
  2214   QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
  2216   QModelIndex index = groupTree->indexAt( point );
  2217   if ( index.isValid() && !mGroupingMode )
  2218     mGroupTreeContextMenu->popup( globalPos );
  2223   QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
  2224                      ? listItems->viewport()->mapToGlobal( point )
  2225                      : mSymbolTreeView->viewport()->mapToGlobal( point );
  2228   mGroupListMenu->clear();
  2230   const QModelIndexList indices = listItems->selectionModel()->selectedRows();
  2234     const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data( 
QgsStyleModel::TagRole ).toStringList() : QStringList();
  2235     QAction *a = 
nullptr;
  2236     QStringList tags = mStyle->
tags();
  2238     for ( 
const QString &tag : qgis::as_const( tags ) )
  2240       a = 
new QAction( tag, mGroupListMenu );
  2242       if ( indices.count() == 1 )
  2244         a->setCheckable( 
true );
  2245         a->setChecked( currentTags.contains( tag ) );
  2249       mGroupListMenu->addAction( a );
  2252     if ( tags.count() > 0 )
  2254       mGroupListMenu->addSeparator();
  2256     a = 
new QAction( tr( 
"Create New Tag…" ), mGroupListMenu );
  2259     mGroupListMenu->addAction( a );
  2262   const QList< ItemDetails > items = selectedItems();
  2265   bool enablePaste = 
false;
  2273   mActionPasteItem->setEnabled( enablePaste );
  2275   mGroupMenu->popup( globalPos );
  2280   const QList< ItemDetails > items = selectedItems();
  2281   for ( 
const ItemDetails &details : items )
  2283     mStyle->
addFavorite( details.entityType, details.name );
  2289   const QList< ItemDetails > items = selectedItems();
  2290   for ( 
const ItemDetails &details : items )
  2298   QAction *selectedItem = qobject_cast<QAction *>( sender() );
  2301     const QList< ItemDetails > items = selectedItems();
  2311       tag = mStyle->
tag( 
id );
  2315       tag = selectedItem->data().toString();
  2318     for ( 
const ItemDetails &details : items )
  2320       mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
  2327   QAction *selectedItem = qobject_cast<QAction *>( sender() );
  2331     const QList< ItemDetails > items = selectedItems();
  2332     for ( 
const ItemDetails &details : items )
  2334       mStyle->
detagSymbol( details.entityType, details.name );
  2341   QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
  2344   QModelIndex present = groupTree->currentIndex();
  2345   if ( present.parent().data( Qt::UserRole + 1 ) != 
"smartgroups" )
  2348     QMessageBox::critical( 
this, tr( 
"Edit Smart Group" ),
  2349                            tr( 
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
  2352   QStandardItem *item = treeModel->itemFromIndex( present );
  2360   if ( dlg.exec() == QDialog::Rejected )
  2363   mBlockGroupUpdates++;
  2366   mBlockGroupUpdates--;
  2369     mMessageBar->
pushCritical( tr( 
"Edit Smart Group" ), tr( 
"There was an error while editing the smart group." ) );
  2373   item->setData( 
id );
 A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
 
void setBaseStyleName(const QString &name)
Sets the base name for the style, which is used by the dialog to reflect the original style/XML file ...
 
void groupChanged(const QModelIndex &)
Triggered when the current group (or tag) is changed. 
 
void tagSymbolsAction()
Toggles the interactive item tagging mode. 
 
void setSmartGroupsVisible(bool show)
Sets whether smart groups should be shown. 
 
void editItem()
Triggers the dialog for editing the current item. 
 
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol. 
 
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style. 
 
Temporarily sets a cursor override for the QApplication for the lifetime of the object. 
 
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style. 
 
void symbolSaved(const QString &name, QgsSymbol *symbol)
Emitted every time a new symbol has been added to the database. 
 
Q_DECL_DEPRECATED void regrouped(QStandardItem *) SIP_DEPRECATED
 
void setBold(QStandardItem *)
sets the text of the item with bold font 
 
bool save(QString filename=QString())
Saves style into a file (will use current filename if empty string is passed) 
 
A dialog allowing users to customize and populate a QgsStyle. 
 
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), bool readOnly=false)
Constructor for QgsStyleManagerDialog, with the specified parent widget and window flags...
 
Abstract base class for all rendered symbols. 
 
static const double UI_SCALE_FACTOR
UI scaling factor. 
 
This class is a composition of two QSettings instances: 
 
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp. 
 
void populateList()
Refreshes the list of items. 
 
void onFinished()
Called when the dialog is going to be closed. 
 
QgsSmartConditionMap conditionMap()
returns the condition map 
 
int addSmartgroup()
Triggers the dialog to add a new smart group. 
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key. 
 
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change. 
 
bool addLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool update=false)
Adds label settings with the specified name to the style. 
 
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol. 
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
Abstract base class for color ramps. 
 
QMap< int, QString > QgsSymbolGroupMap
 
QString schemeName() const
 
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file. 
 
bool saveColorRamp(const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the DB. 
 
void populateGroups()
populate the groups 
 
bool tagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Tags the symbol with the tags in the list. 
 
A bar for displaying non-blocking messages to the user. 
 
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon. 
 
QgsTextFormat format() const
Returns the current formatting settings defined by the widget. 
 
void importItems()
Triggers the dialog to import items. 
 
bool addColorRamp()
add a new color ramp to style 
 
Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED
Populate combo box with known style items (symbols, color ramps). 
 
static QgsGui * instance()
Returns a pointer to the singleton instance. 
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp. 
 
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp. 
 
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item) SIP_DEPRECATED
 
QString smartgroupName()
returns the value from mNameLineEdit 
 
bool removeColorRamp(const QString &name)
Removes color ramp from style (and delete it) 
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
bool rename(StyleEntity type, int id, const QString &newName)
Renames the given entity with the specified id. 
 
void pushSuccess(const QString &title, const QString &message)
Pushes a success message with default timeout to the message bar. 
 
A dialog which allows users to modify the properties of a QgsGradientColorRamp. 
 
A dialog which allows users to modify the properties of a QgsPresetSchemeColorRamp. 
 
A marker symbol type, for rendering Point and MultiPoint geometries. 
 
A line symbol type, for rendering LineString and MultiLineString geometries. 
 
static QgsStyle * defaultStyle()
Returns default application-wide style. 
 
A dialog which allows users to modify the properties of a QgsLimitedRandomColorRamp. 
 
StyleEntity
Enum for Entities involved in a style. 
 
QString currentItemName()
 
static QgsTextFormat fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsTextFormat. 
 
SymbolType
Type of the symbol. 
 
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection. 
 
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp. 
 
QStringList textFormatNames() const
Returns a list of names of text formats in the style. 
 
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name. 
 
bool addSymbol(int symbolType=-1)
add a new symbol to style 
 
int colors() const
Returns the number of colors in the ramp. 
 
Constrained random color ramp, which returns random colors based on preset parameters. 
 
void filterSymbols(const QString &filter)
Sets the filter string to filter symbols by. 
 
QString tag(int id) const
Returns the tag name for the given id. 
 
Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED
 
void exportItemsSVG()
Triggers the dialog to export selected items as SVG files. 
 
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style. 
 
bool removeFavorite(StyleEntity type, const QString &name)
Removes the specified symbol from favorites. 
 
QgsGradientColorRamp ramp
 
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp. 
 
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol. 
 
bool remove(StyleEntity type, int id)
Removes the specified entity from the db. 
 
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed. 
 
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode. 
 
void editSmartgroupAction()
Triggers the dialog for editing the selected smart group. 
 
void exportSelectedItemsImages(const QString &dir, const QString &format, QSize size)
Triggers the dialog to export selected items as images of the specified format and size...
 
int addTag(const QString &tagName)
Adds a new tag and returns the tag's id. 
 
Q_DECL_DEPRECATED void populateColorRamps(const QStringList &colorRamps, bool checkable=false) SIP_DEPRECATED
Populates the list view with color ramps of the current type with the given names. 
 
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected. 
 
QString smartgroupOperator(int id)
Returns the operator for the smartgroup clumsy implementation TODO create a class for smartgroups...
 
void grouptreeContextMenu(QPoint)
Context menu for the groupTree. 
 
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, QString RampType=QString())
Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added...
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites. 
 
Export existing symbols mode. 
 
A scheme based color ramp consisting of a list of predefined colors. 
 
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons. 
 
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name. 
 
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
 
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
 
QgsGradientColorRamp * cloneGradientRamp() const
 
QgsSmartConditionMap smartgroup(int id)
Returns the QgsSmartConditionMap for the given id. 
 
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp. 
 
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs. 
 
Q_DECL_DEPRECATED void populateSymbols(const QStringList &symbolNames, bool checkable=false) SIP_DEPRECATED
Populates the list view with symbols of the current type with the given names. 
 
void setFavoritesGroupVisible(bool show)
Sets whether the favorites group should be shown. 
 
int tagId(const QString &tag)
Returns the DB id for the given tag name. 
 
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()). 
 
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way. 
 
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database. 
 
QString schemeName() const
Returns the name of the color brewer color scheme. 
 
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed. 
 
void addFavoriteSelectedSymbols()
Add selected symbols to favorites. 
 
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership. 
 
bool removeTextFormat(const QString &name)
Removes a text format from the style. 
 
QStringList tags() const
Returns a list of all tags in the style database. 
 
int addSmartgroup(const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
Adds a new smartgroup to the database and returns the id. 
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value. 
 
void setOperator(const QString &)
sets the operator AND/OR 
 
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp. 
 
void activate()
Raises, unminimizes and activates this window. 
 
QgsPresetSchemeColorRamp ramp
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &) SIP_DEPRECATED
 
QStringList colorRampNames() const
Returns a list of names of color ramps. 
 
void removeGroup()
Removes the selected tag or smartgroup. 
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser. 
 
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list ) 
 
Color ramp utilising "Color Brewer" preset color schemes. 
 
int addTag()
Triggers the dialog to add a new tag. 
 
void setSmartgroupName(const QString &)
sets the smart group Name 
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
void exportItemsPNG()
Triggers the dialog to export selected items as PNG files. 
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries. 
 
void showHelp()
Opens the associated help. 
 
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol. 
 
void addItem()
Triggers the dialog for adding a new item, based on the currently selected item type tab...
 
void exportItems()
Triggers the dialog to export items. 
 
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags. 
 
void onClose()
Closes the dialog. 
 
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it) 
 
Container for all settings relating to text rendering. 
 
bool saveLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
Adds label settings to the database. 
 
A dialog which allows users to modify the properties of a QgsCptCityColorRamp. 
 
A simple dialog for customizing text formatting settings. 
 
Style entity type, see QgsStyle::StyleEntity. 
 
QgsColorBrewerColorRamp ramp
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box. 
 
bool addFavorite(StyleEntity type, const QString &name)
Adds the specified symbol to favorites. 
 
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
 
QgsLimitedRandomColorRamp ramp
 
bool removeLabelSettings(const QString &name)
Removes label settings from the style. 
 
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap 
 
QString variantName() const
 
bool detagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Detags the symbol with the given list. 
 
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite. 
 
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs. 
 
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp. 
 
void removeItem()
Removes the current selected item. 
 
QgsSymbolGroupMap smartgroupsListMap()
Returns the smart groups map with id as key and name as value. 
 
Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED
 
void detagSelectedSymbols()
Remove all tags from selected symbols. 
 
Symbol type (for symbol entities) 
 
QString conditionOperator()
returns the AND/OR condition 
 
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs. 
 
void pushCritical(const QString &title, const QString &message)
Pushes a critical warning with default timeout to the message bar. 
 
QStringList symbolNames() const
Returns a list of names of symbols. 
 
QgsWkbTypes::GeometryType layerType
Geometry type of layers associated with these settings.