47 #include <QFileDialog>
48 #include <QInputDialog>
49 #include <QMessageBox>
50 #include <QPushButton>
51 #include <QStandardItemModel>
54 #include <QDesktopServices>
66 QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
68 , mStyle( sourceModel->style() )
69 , mReadOnly( readOnly )
74 QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
77 , mReadOnly( readOnly )
81 void QgsCheckableStyleModel::setCheckable(
bool checkable )
83 if ( checkable == mCheckable )
86 mCheckable = checkable;
87 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
90 void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
92 if ( tag == mCheckTag )
96 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
99 Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
101 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
102 if ( !mReadOnly && mCheckable && index.column() == 0 )
103 f |= Qt::ItemIsUserCheckable;
106 f &= ~Qt::ItemIsEditable;
111 QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
118 QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
123 case Qt::CheckStateRole:
125 if ( !mCheckable || index.column() != 0 )
129 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
136 return QgsStyleProxyModel::data( index, role );
139 bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
141 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) ||
142 ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
148 if ( role == Qt::CheckStateRole )
150 if ( !mCheckable || mCheckTag.isEmpty() )
153 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
156 if ( value.toInt() == Qt::Checked )
157 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
159 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
161 return QgsStyleProxyModel::setData( i, value, role );
171 QString QgsStyleManagerDialog::sPreviousTag;
174 : QDialog( parent, flags )
176 , mReadOnly( readOnly )
180 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
184 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
185 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
187 connect( downloadButton, &QPushButton::clicked,
this, [ = ]
189 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://plugins.qgis.org/styles" ) ) );
193 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
194 mVerticalLayout->insertWidget( 0, mMessageBar );
197 setWindowModality( Qt::WindowModal );
202 mSplitter->setSizes( QList<int>() << 170 << 540 );
203 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
205 tabItemType->setDocumentMode(
true );
206 searchBox->setShowSearchIcon(
true );
207 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
211 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
213 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
218 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool )
221 if ( !btnAddItem->menu() )
226 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
228 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
233 btnAddTag->setEnabled(
false );
234 btnAddSmartgroup->setEnabled(
false );
237 QMenu *shareMenu =
new QMenu( tr(
"Share Menu" ),
this );
238 QAction *exportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
240 shareMenu->addAction( exportAction );
243 QAction *importAction =
new QAction( tr(
"Import Item(s)…" ),
this );
245 shareMenu->addAction( importAction );
250 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
251 shareMenu->addAction( mActionCopyToDefault );
252 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
253 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
257 mCopyToDefaultButton->hide();
260 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
261 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
262 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
263 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
265 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
266 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
267 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
268 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
269 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
271 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
274 shareMenu->addSeparator();
275 shareMenu->addAction( actnExportAsPNG );
276 shareMenu->addAction( actnExportAsSVG );
281 btnShare->setMenu( shareMenu );
283 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
285 mSymbolTreeView->setIconSize( QSize(
static_cast< int >( treeIconSize ),
static_cast< int >( treeIconSize ) ) );
288 :
new QgsCheckableStyleModel( mStyle,
this, mReadOnly );
289 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
290 listItems->setModel( mModel );
291 mSymbolTreeView->setModel( mModel );
293 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
294 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
295 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
296 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
298 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
300 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
303 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
304 groupTree->setModel( groupModel );
305 groupTree->setHeaderHidden(
true );
308 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
309 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
311 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
315 connect( groupModel, &QStandardItemModel::itemChanged,
321 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
323 groupMenu->addAction( actnTagSymbols );
325 actnFinishTagging->setVisible(
false );
326 groupMenu->addAction( actnFinishTagging );
327 groupMenu->addAction( actnEditSmartGroup );
328 btnManageGroups->setMenu( groupMenu );
332 btnManageGroups->setEnabled(
false );
338 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
339 connect( groupTree, &QWidget::customContextMenuRequested,
343 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
344 connect( listItems, &QWidget::customContextMenuRequested,
346 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
347 connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
352 mMenuBtnAddItemAll =
new QMenu(
this );
353 mMenuBtnAddItemColorRamp =
new QMenu(
this );
354 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
355 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
356 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
360 mMenuBtnAddItemAll->addAction( item );
363 mMenuBtnAddItemAll->addAction( item );
366 mMenuBtnAddItemAll->addAction( item );
367 mMenuBtnAddItemAll->addSeparator();
370 for (
const QPair< QString, QString > &rampType : rampTypes )
372 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
373 connect( item, &QAction::triggered,
this, [ = ](
bool ) {
addColorRamp( rampType.first ); } );
374 mMenuBtnAddItemAll->addAction( item );
375 mMenuBtnAddItemColorRamp->addAction( item );
377 mMenuBtnAddItemAll->addSeparator();
379 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addTextFormat(); } );
380 mMenuBtnAddItemAll->addAction( item );
381 mMenuBtnAddItemAll->addSeparator();
384 mMenuBtnAddItemAll->addAction( item );
385 mMenuBtnAddItemLabelSettings->addAction( item );
388 mMenuBtnAddItemAll->addAction( item );
389 mMenuBtnAddItemLabelSettings->addAction( item );
392 mMenuBtnAddItemAll->addAction( item );
393 mMenuBtnAddItemLabelSettings->addAction( item );
395 mMenuBtnAddItemAll->addSeparator();
398 mMenuBtnAddItemAll->addAction( item );
399 mMenuBtnAddItemLegendPatchShape->addAction( item );
401 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
402 mMenuBtnAddItemAll->addAction( item );
403 mMenuBtnAddItemLegendPatchShape->addAction( item );
405 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
406 mMenuBtnAddItemAll->addAction( item );
407 mMenuBtnAddItemLegendPatchShape->addAction( item );
409 mMenuBtnAddItemAll->addSeparator();
411 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"point" ) ); } );
412 mMenuBtnAddItemAll->addAction( item );
413 mMenuBtnAddItemSymbol3D->addAction( item );
415 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
416 mMenuBtnAddItemAll->addAction( item );
417 mMenuBtnAddItemSymbol3D->addAction( item );
419 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
420 mMenuBtnAddItemAll->addAction( item );
421 mMenuBtnAddItemSymbol3D->addAction( item );
425 mGroupMenu =
new QMenu(
this );
426 mGroupListMenu =
new QMenu( mGroupMenu );
427 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
428 mGroupListMenu->setEnabled(
false );
432 mGroupMenu->addAction( actnAddFavorite );
434 mGroupMenu->addAction( actnRemoveFavorite );
435 mGroupMenu->addSeparator()->setParent(
this );
436 mGroupMenu->addMenu( mGroupListMenu );
437 actnDetag->setData( 0 );
439 mGroupMenu->addAction( actnDetag );
440 mGroupMenu->addSeparator()->setParent(
this );
441 mGroupMenu->addAction( actnRemoveItem );
442 mGroupMenu->addAction( actnEditItem );
443 mGroupMenu->addAction( mActionCopyItem );
444 mGroupMenu->addAction( mActionPasteItem );
445 mGroupMenu->addSeparator()->setParent(
this );
449 btnAddItem->setVisible(
false );
450 btnRemoveItem->setVisible(
false );
451 btnEditItem->setVisible(
false );
452 btnAddSmartgroup->setVisible(
false );
453 btnAddTag->setVisible(
false );
454 btnManageGroups->setVisible(
false );
456 mGroupMenu->addAction( mActionCopyItem );
458 if ( mActionCopyToDefault )
460 mGroupMenu->addAction( mActionCopyToDefault );
462 mGroupMenu->addAction( actnExportAsPNG );
463 mGroupMenu->addAction( actnExportAsSVG );
466 mGroupTreeContextMenu =
new QMenu(
this );
470 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
471 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); }
473 mGroupTreeContextMenu->addAction( actnAddTag );
474 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); }
476 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
478 mGroupTreeContextMenu->addAction( actnRemoveGroup );
481 tabItemType_currentChanged( 0 );
486 connect( mButtonIconView, &QToolButton::toggled,
this, [ = ](
bool active )
490 mSymbolViewStackedWidget->setCurrentIndex( 0 );
495 connect( mButtonListView, &QToolButton::toggled,
this, [ = ](
bool active )
500 mSymbolViewStackedWidget->setCurrentIndex( 1 );
504 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
505 if ( currentView == 0 )
506 mButtonIconView->setChecked(
true );
508 mButtonListView->setChecked(
true );
510 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
511 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this]
514 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
517 const int thumbnailSize = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), 0,
QgsSettings::Gui ).toInt();
518 mSliderIconSize->setValue( thumbnailSize );
519 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
520 setThumbnailSize( thumbnailSize );
528 if ( mModified && !mReadOnly )
534 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
541 void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
550 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
551 isColorRamp ? tr(
"Filter color ramps…" ) :
552 isTextFormat ? tr(
"Filter text symbols…" ) :
553 isLabelSettings ? tr(
"Filter label settings…" ) :
554 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
556 if ( !mReadOnly && isColorRamp )
558 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
560 else if ( !mReadOnly && isLegendPatchShape )
562 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
564 else if ( !mReadOnly && isSymbol3D )
566 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
568 else if ( !mReadOnly && isLabelSettings )
570 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
572 else if ( !mReadOnly && !isSymbol && !isColorRamp )
574 btnAddItem->setMenu(
nullptr );
576 else if ( !mReadOnly && tabItemType->currentIndex() == 0 )
578 btnAddItem->setMenu( mMenuBtnAddItemAll );
582 btnAddItem->setMenu(
nullptr );
585 actnExportAsPNG->setVisible( isSymbol );
586 actnExportAsSVG->setVisible( isSymbol );
589 mModel->setEntityFilterEnabled( !allTypesSelected() );
590 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
591 if ( isSymbol && !allTypesSelected() )
597 void QgsStyleManagerDialog::copyItemsToDefault()
599 const QList< ItemDetails > items = selectedItems();
600 if ( !items.empty() )
604 if ( !mBaseName.isEmpty() )
605 options.append( mBaseName );
608 defaultTags.sort( Qt::CaseInsensitive );
609 options.append( defaultTags );
610 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
611 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
615 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
616 const QStringList parts = tags.split(
',', QString::SkipEmptyParts );
618 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
620 QStringList additionalTags;
621 additionalTags.reserve( parts.count() );
622 for (
const QString &tag : parts )
623 additionalTags << tag.trimmed();
625 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
626 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
627 cursorOverride.reset();
630 mMessageBar->
pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
635 void QgsStyleManagerDialog::copyItem()
637 const QList< ItemDetails > items = selectedItems();
641 ItemDetails details = items.at( 0 );
642 switch ( details.entityType )
646 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
656 QApplication::clipboard()->setMimeData( format.toMimeData() );
663 QApplication::clipboard()->setMimeData( format.toMimeData() );
677 void QgsStyleManagerDialog::pasteItem()
679 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
684 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
685 saveDlg.setDefaultTags( defaultTag );
686 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
689 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
691 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
692 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
693 .arg( saveDlg.name() ),
694 QMessageBox::Yes | QMessageBox::No );
695 if ( res != QMessageBox::Yes )
702 QStringList symbolTags = saveDlg.tags().split(
',' );
704 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
706 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
715 saveDlg.setDefaultTags( defaultTag );
716 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
717 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
722 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
723 tr(
"A format with the name '%1' already exists. Overwrite?" )
724 .arg( saveDlg.name() ),
725 QMessageBox::Yes | QMessageBox::No );
726 if ( res != QMessageBox::Yes )
733 QStringList symbolTags = saveDlg.tags().split(
',' );
736 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
741 void QgsStyleManagerDialog::setThumbnailSize(
int value )
746 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
749 listItems->setIconSize( QSize(
static_cast< int >(
iconSize ),
static_cast< int >(
iconSize * 0.9 ) ) );
750 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
751 mModel->addDesiredIconSize( listItems->iconSize() );
756 int QgsStyleManagerDialog::selectedItemType()
758 QModelIndex index = listItems->selectionModel()->currentIndex();
759 if ( !index.isValid() )
777 bool QgsStyleManagerDialog::allTypesSelected()
const
779 return tabItemType->currentIndex() == 0;
782 QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
784 QList<QgsStyleManagerDialog::ItemDetails > res;
785 QModelIndexList indices = listItems->selectionModel()->selectedRows();
786 for (
const QModelIndex &index : indices )
788 if ( !index.isValid() )
795 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
802 int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
803 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
806 bool overwriteAll =
true;
816 for (
auto &details : items )
818 QStringList symbolTags;
819 if ( !ignoreSourceTags )
821 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
824 bool addItemToFavorites =
false;
827 symbolTags << importTags;
828 addItemToFavorites = addToFavorites;
831 switch ( details.entityType )
835 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
839 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
840 bool overwriteThis =
false;
842 addItemToFavorites = favoriteSymbols.contains( details.name );
844 if ( hasDuplicateName && prompt )
846 cursorOverride.reset();
847 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
848 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
849 .arg( details.name ),
850 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
851 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
854 case QMessageBox::Cancel:
857 case QMessageBox::No:
860 case QMessageBox::Yes:
861 overwriteThis =
true;
864 case QMessageBox::YesToAll:
869 case QMessageBox::NoToAll:
871 overwriteAll =
false;
876 if ( !hasDuplicateName || overwriteAll || overwriteThis )
879 dst->
addSymbol( details.name, symbol.release() );
880 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
888 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
892 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
893 bool overwriteThis =
false;
895 addItemToFavorites = favoriteColorramps.contains( details.name );
897 if ( hasDuplicateName && prompt )
899 cursorOverride.reset();
900 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
901 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
902 .arg( details.name ),
903 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
904 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
907 case QMessageBox::Cancel:
910 case QMessageBox::No:
913 case QMessageBox::Yes:
914 overwriteThis =
true;
917 case QMessageBox::YesToAll:
922 case QMessageBox::NoToAll:
924 overwriteAll =
false;
929 if ( !hasDuplicateName || overwriteAll || overwriteThis )
933 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
943 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
944 bool overwriteThis =
false;
946 addItemToFavorites = favoriteTextFormats.contains( details.name );
948 if ( hasDuplicateName && prompt )
950 cursorOverride.reset();
951 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
952 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
953 .arg( details.name ),
954 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
955 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
958 case QMessageBox::Cancel:
961 case QMessageBox::No:
964 case QMessageBox::Yes:
965 overwriteThis =
true;
968 case QMessageBox::YesToAll:
973 case QMessageBox::NoToAll:
975 overwriteAll =
false;
980 if ( !hasDuplicateName || overwriteAll || overwriteThis )
983 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
994 bool overwriteThis =
false;
996 addItemToFavorites = favoriteLabelSettings.contains( details.name );
998 if ( hasDuplicateName && prompt )
1000 cursorOverride.reset();
1001 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1002 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1003 .arg( details.name ),
1004 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1005 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1008 case QMessageBox::Cancel:
1011 case QMessageBox::No:
1014 case QMessageBox::Yes:
1015 overwriteThis =
true;
1018 case QMessageBox::YesToAll:
1020 overwriteAll =
true;
1023 case QMessageBox::NoToAll:
1025 overwriteAll =
false;
1030 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1033 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1044 bool overwriteThis =
false;
1046 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1048 if ( hasDuplicateName && prompt )
1050 cursorOverride.reset();
1051 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1052 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1053 .arg( details.name ),
1054 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1055 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1058 case QMessageBox::Cancel:
1061 case QMessageBox::No:
1064 case QMessageBox::Yes:
1065 overwriteThis =
true;
1068 case QMessageBox::YesToAll:
1070 overwriteAll =
true;
1073 case QMessageBox::NoToAll:
1075 overwriteAll =
false;
1080 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1091 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1095 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1096 bool overwriteThis =
false;
1098 addItemToFavorites = favorite3dSymbols.contains( details.name );
1100 if ( hasDuplicateName && prompt )
1102 cursorOverride.reset();
1103 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1104 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1105 .arg( details.name ),
1106 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1107 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1110 case QMessageBox::Cancel:
1113 case QMessageBox::No:
1116 case QMessageBox::Yes:
1117 overwriteThis =
true;
1120 case QMessageBox::YesToAll:
1122 overwriteAll =
true;
1125 case QMessageBox::NoToAll:
1127 overwriteAll =
false;
1132 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1135 dst->
addSymbol3D( details.name, symbol.release() );
1136 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1151 bool QgsStyleManagerDialog::addTextFormat()
1155 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1156 if ( !formatDlg.exec() )
1158 format = formatDlg.format();
1161 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1162 saveDlg.setDefaultTags( defaultTag );
1163 if ( !saveDlg.exec() )
1165 QString name = saveDlg.name();
1168 bool nameInvalid =
true;
1169 while ( nameInvalid )
1172 if ( name.isEmpty() )
1174 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1175 tr(
"Cannot save text format without name. Enter a name." ) );
1179 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1180 tr(
"Text format with name '%1' already exists. Overwrite?" )
1182 QMessageBox::Yes | QMessageBox::No );
1183 if ( res == QMessageBox::Yes )
1186 nameInvalid =
false;
1192 nameInvalid =
false;
1197 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1198 tr(
"Please enter a name for new text format:" ),
1199 QLineEdit::Normal, name, &ok );
1207 QStringList symbolTags = saveDlg.tags().split(
',' );
1211 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1219 groupChanged( groupTree->selectionModel()->currentIndex() );
1232 switch ( tabItemType->currentIndex() )
1257 QModelIndex index = listItems->selectionModel()->currentIndex();
1258 if ( !index.isValid() )
1261 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1266 bool changed =
false;
1277 changed = addTextFormat();
1296 Q_ASSERT(
false &&
"not implemented" );
1309 QString name = tr(
"new symbol" );
1310 QString dialogTitle;
1315 name = tr(
"new marker" );
1316 dialogTitle = tr(
"New Marker Symbol" );
1320 name = tr(
"new line" );
1321 dialogTitle = tr(
"New Line Symbol" );
1325 name = tr(
"new fill symbol" );
1326 dialogTitle = tr(
"New Fill Symbol" );
1329 Q_ASSERT(
false &&
"unknown symbol type" );
1339 dlg.setWindowTitle( dialogTitle );
1340 if ( dlg.exec() == 0 )
1347 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1349 if ( !saveDlg.exec() )
1355 name = saveDlg.
name();
1358 bool nameInvalid =
true;
1359 while ( nameInvalid )
1362 if ( name.isEmpty() )
1364 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1365 tr(
"Cannot save symbol without name. Enter a name." ) );
1367 else if ( mStyle->
symbolNames().contains( name ) )
1369 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1370 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1372 QMessageBox::Yes | QMessageBox::No );
1373 if ( res == QMessageBox::Yes )
1376 nameInvalid =
false;
1382 nameInvalid =
false;
1387 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1388 tr(
"Please enter a name for new symbol:" ),
1389 QLineEdit::Normal, name, &ok );
1398 QStringList symbolTags = saveDlg.
tags().split(
',' );
1411 QString rampType = type;
1413 if ( rampType.isEmpty() )
1418 QStringList rampTypeNames;
1419 rampTypeNames.reserve( rampTypes.size() );
1420 for (
const QPair< QString, QString > &type : rampTypes )
1421 rampTypeNames << type.second;
1422 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1423 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1424 if ( !ok || selectedRampTypeName.isEmpty() )
1427 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1430 QString name = tr(
"new ramp" );
1432 std::unique_ptr< QgsColorRamp > ramp;
1436 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1442 name = tr(
"new gradient ramp" );
1447 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1453 name = tr(
"new random ramp" );
1458 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1469 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1475 name = tr(
"new preset ramp" );
1480 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1500 QgsDebugMsg( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1505 if ( !saveDlg.exec() )
1510 name = saveDlg.
name();
1513 bool nameInvalid =
true;
1514 while ( nameInvalid )
1517 if ( name.isEmpty() )
1519 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1520 tr(
"Cannot save color ramp without name. Enter a name." ) );
1524 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1525 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1527 QMessageBox::Yes | QMessageBox::No );
1528 if ( res == QMessageBox::Yes )
1530 nameInvalid =
false;
1536 nameInvalid =
false;
1541 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1542 tr(
"Please enter a name for new color ramp:" ),
1543 QLineEdit::Normal, name, &ok );
1551 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1563 mFavoritesGroupVisible = show;
1569 mSmartGroupVisible = show;
1581 setWindowState( windowState() & ~Qt::WindowMinimized );
1589 if ( !rampName.isEmpty() )
1601 if ( selectedItemType() < 3 )
1605 else if ( selectedItemType() == 3 )
1609 else if ( selectedItemType() == 4 )
1613 else if ( selectedItemType() == 5 )
1615 editLabelSettings();
1617 else if ( selectedItemType() == 6 )
1619 editLegendPatchShape();
1621 else if ( selectedItemType() == 7 )
1627 Q_ASSERT(
false &&
"not implemented" );
1634 if ( symbolName.isEmpty() )
1637 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1641 dlg.setWindowTitle( symbolName );
1643 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1649 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1657 if ( name.isEmpty() )
1660 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1666 dlg.setWindowTitle( name );
1668 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1680 dlg.setWindowTitle( name );
1682 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1694 dlg.setWindowTitle( name );
1696 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1708 dlg.setWindowTitle( name );
1710 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1722 dlg.setWindowTitle( name );
1724 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1741 Q_ASSERT(
false &&
"invalid ramp type" );
1749 bool QgsStyleManagerDialog::editTextFormat()
1752 if ( formatName.isEmpty() )
1759 dlg.setWindowTitle( formatName );
1761 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1775 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1776 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1778 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1780 if ( !settingsDlg.exec() )
1783 settings = settingsDlg.settings();
1787 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1788 saveDlg.setDefaultTags( defaultTag );
1789 if ( !saveDlg.exec() )
1791 QString name = saveDlg.name();
1794 bool nameInvalid =
true;
1795 while ( nameInvalid )
1798 if ( name.isEmpty() )
1800 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1801 tr(
"Cannot save label settings without a name. Enter a name." ) );
1805 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1806 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1808 QMessageBox::Yes | QMessageBox::No );
1809 if ( res == QMessageBox::Yes )
1812 nameInvalid =
false;
1818 nameInvalid =
false;
1823 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1824 tr(
"Please enter a name for the new label settings:" ),
1825 QLineEdit::Normal, name, &ok );
1833 QStringList symbolTags = saveDlg.tags().split(
',' );
1843 bool QgsStyleManagerDialog::editLabelSettings()
1846 if ( formatName.isEmpty() )
1853 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1854 dlg.setWindowTitle( formatName );
1858 settings = dlg.settings();
1871 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1873 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1875 if ( !dialog.exec() )
1878 shape = dialog.shape();
1881 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1882 saveDlg.setDefaultTags( defaultTag );
1883 if ( !saveDlg.exec() )
1885 QString name = saveDlg.name();
1888 bool nameInvalid =
true;
1889 while ( nameInvalid )
1892 if ( name.isEmpty() )
1894 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1895 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1899 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1900 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
1902 QMessageBox::Yes | QMessageBox::No );
1903 if ( res == QMessageBox::Yes )
1906 nameInvalid =
false;
1912 nameInvalid =
false;
1917 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
1918 tr(
"Please enter a name for the new legend patch shape:" ),
1919 QLineEdit::Normal, name, &ok );
1927 QStringList symbolTags = saveDlg.tags().split(
',' );
1937 bool QgsStyleManagerDialog::editLegendPatchShape()
1940 if ( shapeName.isEmpty() )
1949 dlg.setWindowTitle( shapeName );
1953 shape = dlg.shape();
1961 bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
1968 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
1970 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1972 if ( !dialog.exec() )
1975 symbol.reset( dialog.symbol() );
1980 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1981 saveDlg.setDefaultTags( defaultTag );
1982 if ( !saveDlg.exec() )
1984 QString name = saveDlg.name();
1987 bool nameInvalid =
true;
1988 while ( nameInvalid )
1991 if ( name.isEmpty() )
1993 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
1994 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
1998 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
1999 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2001 QMessageBox::Yes | QMessageBox::No );
2002 if ( res == QMessageBox::Yes )
2005 nameInvalid =
false;
2011 nameInvalid =
false;
2016 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2017 tr(
"Please enter a name for the new 3D symbol:" ),
2018 QLineEdit::Normal, name, &ok );
2026 QStringList symbolTags = saveDlg.tags().split(
',' );
2031 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2037 bool QgsStyleManagerDialog::editSymbol3D()
2040 if ( symbolName.isEmpty() )
2043 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2049 dlg.setWindowTitle( symbolName );
2053 symbol.reset( dlg.symbol() );
2058 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2065 const QList< ItemDetails > items = selectedItems();
2067 if ( allTypesSelected() )
2069 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2070 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2079 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2080 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2087 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2088 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2095 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2096 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2103 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2104 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2111 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2112 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2119 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2120 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2129 for (
const ItemDetails &details : items )
2131 if ( details.name.isEmpty() )
2156 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2157 QDir::home().absolutePath(),
2158 QFileDialog::ShowDirsOnly
2159 | QFileDialog::DontResolveSymlinks );
2165 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2166 QDir::home().absolutePath(),
2167 QFileDialog::ShowDirsOnly
2168 | QFileDialog::DontResolveSymlinks );
2175 if ( dir.isEmpty() )
2178 const QList< ItemDetails > items = selectedItems();
2179 for (
const ItemDetails &details : items )
2184 QString path = dir +
'/' + details.name +
'.' + format;
2185 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2187 sym->exportImage( path, format, size );
2207 QFont font = item->font();
2208 font.setBold(
true );
2209 item->setFont( font );
2214 if ( mBlockGroupUpdates )
2217 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2220 if ( mFavoritesGroupVisible )
2222 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2223 favoriteSymbols->setData(
"favorite" );
2224 favoriteSymbols->setEditable(
false );
2226 model->appendRow( favoriteSymbols );
2229 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2230 allSymbols->setData(
"all" );
2231 allSymbols->setEditable(
false );
2233 model->appendRow( allSymbols );
2235 QStandardItem *taggroup =
new QStandardItem( QString() );
2236 taggroup->setData(
"tags" );
2237 taggroup->setEditable(
false );
2238 QStringList tags = mStyle->
tags();
2240 for (
const QString &tag : std::as_const( tags ) )
2242 QStandardItem *item =
new QStandardItem( tag );
2243 item->setData( mStyle->
tagId( tag ) );
2245 item->setEditable( !mReadOnly );
2246 taggroup->appendRow( item );
2248 taggroup->setText( tr(
"Tags" ) );
2250 model->appendRow( taggroup );
2252 if ( mSmartGroupVisible )
2254 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2255 smart->setData(
"smartgroups" );
2256 smart->setEditable(
false );
2259 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2260 while ( i != sgMap.constEnd() )
2262 QStandardItem *item =
new QStandardItem( i.value() );
2263 item->setData( i.key() );
2264 item->setEditable( !mReadOnly );
2265 smart->appendRow( item );
2268 model->appendRow( smart );
2272 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2273 for (
int i = 0; i < rows; i++ )
2275 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2281 QStringList groupSymbols;
2283 const QString category = index.data( Qt::UserRole + 1 ).toString();
2284 sPreviousTag = category;
2286 if ( mGroupingMode )
2288 mModel->setTagId( -1 );
2289 mModel->setSmartGroupId( -1 );
2290 mModel->setFavoritesOnly(
false );
2291 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2293 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2296 if ( category == QLatin1String(
"tags" ) )
2298 actnAddTag->setEnabled( !mReadOnly );
2299 actnAddSmartgroup->setEnabled(
false );
2301 else if ( category == QLatin1String(
"smartgroups" ) )
2303 actnAddTag->setEnabled(
false );
2304 actnAddSmartgroup->setEnabled( !mReadOnly );
2307 mModel->setTagId( -1 );
2308 mModel->setSmartGroupId( -1 );
2309 mModel->setFavoritesOnly(
false );
2311 else if ( category == QLatin1String(
"favorite" ) )
2314 mModel->setTagId( -1 );
2315 mModel->setSmartGroupId( -1 );
2316 mModel->setFavoritesOnly(
true );
2318 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2320 actnRemoveGroup->setEnabled( !mReadOnly );
2321 btnManageGroups->setEnabled( !mReadOnly );
2322 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2323 mModel->setTagId( -1 );
2324 mModel->setSmartGroupId( groupId );
2325 mModel->setFavoritesOnly(
false );
2330 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2331 mModel->setTagId( tagId );
2332 mModel->setSmartGroupId( -1 );
2333 mModel->setFavoritesOnly(
false );
2336 actnEditSmartGroup->setVisible(
false );
2337 actnAddTag->setVisible(
false );
2338 actnAddSmartgroup->setVisible(
false );
2339 actnRemoveGroup->setVisible(
false );
2340 actnTagSymbols->setVisible(
false );
2341 actnFinishTagging->setVisible(
false );
2343 if ( index.parent().isValid() )
2345 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2347 actnEditSmartGroup->setVisible( !mGroupingMode && !mReadOnly );
2349 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2351 actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
2352 actnTagSymbols->setVisible( !mGroupingMode && !mReadOnly );
2353 actnFinishTagging->setVisible( mGroupingMode && !mReadOnly );
2355 actnRemoveGroup->setVisible( !mReadOnly );
2357 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2359 actnAddSmartgroup->setVisible( !mGroupingMode && !mReadOnly );
2361 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2363 actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
2369 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2371 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2373 index = groupTree->model()->index( i, 0 );
2374 QString data = index.data( Qt::UserRole + 1 ).toString();
2375 if ( data == QLatin1String(
"tags" ) )
2384 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2385 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2386 if ( !ok || itemName.isEmpty() )
2389 int check = mStyle->
tagId( itemName );
2392 mMessageBar->
pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2398 mBlockGroupUpdates++;
2399 id = mStyle->
addTag( itemName );
2400 mBlockGroupUpdates--;
2404 mMessageBar->
pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2408 QStandardItem *parentItem = model->itemFromIndex( index );
2409 QStandardItem *childItem =
new QStandardItem( itemName );
2410 childItem->setData(
id );
2412 parentItem->appendRow( childItem );
2419 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2421 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2423 index = groupTree->model()->index( i, 0 );
2424 QString data = index.data( Qt::UserRole + 1 ).toString();
2425 if ( data == QLatin1String(
"smartgroups" ) )
2434 if ( dlg.exec() == QDialog::Rejected )
2439 mBlockGroupUpdates++;
2441 mBlockGroupUpdates--;
2447 QStandardItem *parentItem = model->itemFromIndex( index );
2448 QStandardItem *childItem =
new QStandardItem( itemName );
2449 childItem->setData(
id );
2450 parentItem->appendRow( childItem );
2457 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2458 QModelIndex index = groupTree->currentIndex();
2461 QString data = index.data( Qt::UserRole + 1 ).toString();
2462 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2465 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2466 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2467 "Kindly select a group or smart group you might want to delete." ) );
2472 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2476 mBlockGroupUpdates++;
2478 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2487 mBlockGroupUpdates--;
2488 parentItem->removeRow( index.row() );
2493 QgsDebugMsg( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ) );
2494 int id = item->data( Qt::UserRole + 1 ).toInt();
2495 QString name = item->text();
2496 mBlockGroupUpdates++;
2497 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2505 mBlockGroupUpdates--;
2510 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2512 if ( mGroupingMode )
2514 mGroupingMode =
false;
2515 mModel->setCheckable(
false );
2516 actnTagSymbols->setVisible(
true );
2517 actnFinishTagging->setVisible(
false );
2525 connect( treeModel, &QStandardItemModel::itemChanged,
2529 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2530 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2534 bool validGroup =
false;
2536 QModelIndex present = groupTree->currentIndex();
2537 while ( present.parent().isValid() )
2539 if ( present.parent().data() ==
"Tags" )
2544 present = present.parent();
2549 mGroupingMode =
true;
2551 actnTagSymbols->setVisible(
false );
2552 actnFinishTagging->setVisible(
true );
2554 disconnect( treeModel, &QStandardItemModel::itemChanged,
2560 btnManageGroups->setEnabled(
true );
2562 mModel->setCheckable(
true );
2565 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2566 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2580 mModel->setFilterString( qword );
2585 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !mReadOnly );
2590 Q_UNUSED( selected )
2591 Q_UNUSED( deselected )
2592 bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2593 actnRemoveItem->setDisabled( nothingSelected || mReadOnly );
2594 actnAddFavorite->setDisabled( nothingSelected || mReadOnly );
2595 actnRemoveFavorite->setDisabled( nothingSelected || mReadOnly );
2596 mGroupListMenu->setDisabled( nothingSelected || mReadOnly );
2597 actnDetag->setDisabled( nothingSelected || mReadOnly );
2598 actnExportAsPNG->setDisabled( nothingSelected );
2599 actnExportAsSVG->setDisabled( nothingSelected );
2600 if ( mActionCopyToDefault )
2601 mActionCopyToDefault->setDisabled( nothingSelected );
2602 mCopyToDefaultButton->setDisabled( nothingSelected );
2603 actnEditItem->setDisabled( nothingSelected || mReadOnly );
2608 groupTree->setEnabled( enable );
2609 btnAddTag->setEnabled( enable && !mReadOnly );
2610 btnAddSmartgroup->setEnabled( enable && !mReadOnly );
2611 actnAddTag->setEnabled( enable && !mReadOnly );
2612 actnAddSmartgroup->setEnabled( enable && !mReadOnly );
2613 actnRemoveGroup->setEnabled( enable && !mReadOnly );
2614 btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) );
2615 searchBox->setEnabled( enable );
2620 actnRemoveGroup->setEnabled( enable && !mReadOnly );
2621 btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) );
2626 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2627 for (
int i = 0; i < treeModel->rowCount(); i++ )
2629 treeModel->item( i )->setEnabled( enable );
2631 if ( treeModel->item( i )->data() ==
"smartgroups" )
2633 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2635 treeModel->item( i )->child( j )->setEnabled( enable );
2642 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2644 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2646 w->setEnabled( enable );
2650 actnRemoveItem->setEnabled( enable );
2651 actnEditItem->setEnabled( enable );
2652 mActionCopyItem->setEnabled( enable );
2653 mActionPasteItem->setEnabled( enable );
2658 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2660 QModelIndex index = groupTree->indexAt( point );
2661 if ( index.isValid() && !mGroupingMode )
2662 mGroupTreeContextMenu->popup( globalPos );
2667 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2668 ? listItems->viewport()->mapToGlobal( point )
2669 : mSymbolTreeView->viewport()->mapToGlobal( point );
2672 mGroupListMenu->clear();
2674 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2678 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
QgsStyleModel::TagRole ).toStringList() : QStringList();
2679 QAction *a =
nullptr;
2680 QStringList tags = mStyle->
tags();
2682 for (
const QString &tag : std::as_const( tags ) )
2684 a =
new QAction( tag, mGroupListMenu );
2686 if ( indices.count() == 1 )
2688 a->setCheckable(
true );
2689 a->setChecked( currentTags.contains( tag ) );
2693 mGroupListMenu->addAction( a );
2696 if ( tags.count() > 0 )
2698 mGroupListMenu->addSeparator();
2700 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2703 mGroupListMenu->addAction( a );
2706 const QList< ItemDetails > items = selectedItems();
2709 bool enablePaste =
false;
2717 mActionPasteItem->setEnabled( enablePaste );
2719 mGroupMenu->popup( globalPos );
2724 const QList< ItemDetails > items = selectedItems();
2725 for (
const ItemDetails &details : items )
2727 mStyle->
addFavorite( details.entityType, details.name );
2733 const QList< ItemDetails > items = selectedItems();
2734 for (
const ItemDetails &details : items )
2742 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2745 const QList< ItemDetails > items = selectedItems();
2755 tag = mStyle->
tag(
id );
2759 tag = selectedItem->data().toString();
2762 for (
const ItemDetails &details : items )
2764 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2771 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2775 const QList< ItemDetails > items = selectedItems();
2776 for (
const ItemDetails &details : items )
2778 mStyle->
detagSymbol( details.entityType, details.name );
2785 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2788 QModelIndex present = groupTree->currentIndex();
2789 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2792 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2793 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2796 QStandardItem *item = treeModel->itemFromIndex( present );
2804 if ( dlg.exec() == QDialog::Rejected )
2807 mBlockGroupUpdates++;
2810 mBlockGroupUpdates--;
2813 mMessageBar->
pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2817 item->setData(
id );
static const double UI_SCALE_FACTOR
UI scaling factor.
A dialog for configuring a 3D symbol.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp.
QgsColorBrewerColorRamp ramp
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Color ramp utilising "Color Brewer" preset color schemes.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
Abstract base class for color ramps.
static QList< QPair< QString, QString > > rampTypes()
Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type(...
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
QgsGradientColorRamp * cloneGradientRamp() const
QString schemeName() const
QString variantName() const
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsGradientColorRamp ramp
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp.
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.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconPoint()
Returns an icon representing point geometries.
A dialog for configuring a custom legend patch shape.
Represents a patch shape for use in map legends.
bool isNull() const
Returns true if the patch shape is a null QgsLegendPatchShape, which indicates that the default legen...
A dialog which allows users to modify the properties of a QgsLimitedRandomColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsLimitedRandomColorRamp ramp
Constrained random color ramp, which returns random colors based on preset parameters.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
A bar for displaying non-blocking messages to the user.
void pushSuccess(const QString &title, const QString &message)
Pushes a success message with default timeout to the message bar.
void pushCritical(const QString &title, const QString &message)
Pushes a critical warning message that must be manually dismissed by the user.
Contains settings for how a map layer will be labeled.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsWkbTypes::GeometryType layerType
Geometry type of layers associated with these settings.
A dialog which allows users to modify the properties of a QgsPresetSchemeColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsPresetSchemeColorRamp ramp
A scheme based color ramp consisting of a list of predefined colors.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap
QgsSmartConditionMap conditionMap()
returns the condition map
QString smartgroupName()
returns the value from mNameLineEdit
void setSmartgroupName(const QString &)
sets the smart group Name
void setOperator(const QString &)
sets the operator AND/OR
QString conditionOperator()
returns the AND/OR condition
@ Export
Export existing symbols mode.
@ Import
Import xml file mode.
Q_DECL_DEPRECATED void regrouped(QStandardItem *) SIP_DEPRECATED
void onClose()
Closes the dialog.
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed.
void addFavoriteSelectedSymbols()
Add selected symbols to favorites.
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change.
void removeGroup()
Removes the selected tag or smartgroup.
void exportItems()
Triggers the dialog to export items.
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 setFavoritesGroupVisible(bool show)
Sets whether the favorites group should be shown.
void grouptreeContextMenu(QPoint)
Context menu for the groupTree.
void setBold(QStandardItem *)
sets the text of the item with bold font
void filterSymbols(const QString &filter)
Sets the filter string to filter symbols by.
void addItem()
Triggers the dialog for adding a new item, based on the currently selected item type tab.
void tagSymbolsAction()
Toggles the interactive item tagging mode.
void editSmartgroupAction()
Triggers the dialog for editing the selected smart group.
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item) SIP_DEPRECATED
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 showHelp()
Opens the associated help.
Q_DECL_DEPRECATED bool removeColorRamp() SIP_DEPRECATED
void detagSelectedSymbols()
Remove all tags from selected symbols.
Q_DECL_DEPRECATED bool removeSymbol() SIP_DEPRECATED
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
bool addSymbol(int symbolType=-1)
add a new symbol to style
void populateList()
Refreshes the list of items.
void removeItem()
Removes the current selected item.
void groupChanged(const QModelIndex &)
Triggered when the current group (or tag) is changed.
Q_DECL_DEPRECATED void populateTypes() SIP_DEPRECATED
Populate combo box with known style items (symbols, color ramps).
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &) SIP_DEPRECATED
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.
int addTag()
Triggers the dialog to add a new tag.
void exportItemsSVG()
Triggers the dialog to export selected items as SVG files.
void populateGroups()
populate the groups
void importItems()
Triggers the dialog to import items.
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 exportItemsPNG()
Triggers the dialog to export selected items as PNG files.
void activate()
Raises, unminimizes and activates this window.
bool addColorRamp(const QString &type=QString())
Triggers adding a new color ramp.
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.
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode.
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.
void onFinished()
Called when the dialog is going to be closed.
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list )
void setSmartGroupsVisible(bool show)
Sets whether smart groups should be shown.
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, const QString &RampType=QString())
Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added.
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
void editItem()
Triggers the dialog for editing the current item.
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites.
int addSmartgroup()
Triggers the dialog to add a new smart group.
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection.
QString currentItemName()
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ TypeRole
Style entity type, see QgsStyle::StyleEntity.
@ SymbolTypeRole
Symbol type (for symbol or legend patch shape entities)
@ TagRole
String list of tags.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
a dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
bool saveColorRamp(const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the database.
bool detagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Detags the symbol with the given list.
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QgsLegendPatchShape defaultPatch(Qgis::SymbolType type, QSizeF size) const
Returns the default legend patch shape for the given symbol type.
bool remove(StyleEntity type, int id)
Removes the specified entity from the database.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
bool removeLabelSettings(const QString &name)
Removes label settings from the style.
QStringList tags() const
Returns a list of all tags in the style database.
QString tag(int id) const
Returns the tag name for the given id.
QgsSmartConditionMap smartgroup(int id)
Returns the QgsSmartConditionMap for the given id.
QStringList symbol3DNames() const
Returns a list of names of 3d symbols in the style.
bool tagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Tags the symbol with the tags in the list.
bool saveLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
Adds label settings to the database.
void symbolSaved(const QString &name, QgsSymbol *symbol)
Emitted every time a new symbol has been added to the database.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity (since QGIS 3.14)
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
int addSmartgroup(const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
Adds a new smartgroup to the database and returns the id.
QStringList colorRampNames() const
Returns a list of names of color ramps.
bool addSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool update=false)
Adds a 3d symbol with the specified name to the style.
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the style.
static QgsStyle * defaultStyle()
Returns default application-wide style.
bool removeEntityByName(StyleEntity type, const QString &name)
Removes the entry of the specified type with matching name from the database.
int tagId(const QString &tag)
Returns the database id for the given tag name.
bool addLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool update=false)
Adds a legend patch shape with the specified name to the style.
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style.
bool save(QString filename=QString())
Saves style into a file (will use current filename if empty string is passed)
bool rename(StyleEntity type, int id, const QString &newName)
Renames the given entity with the specified id.
bool removeFavorite(StyleEntity type, const QString &name)
Removes the specified symbol from favorites.
QgsSymbolGroupMap smartgroupsListMap()
Returns the smart groups map with id as key and name as value.
bool saveLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
Adds a legend patch shape to the database.
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
bool saveSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool favorite, const QStringList &tags)
Adds a 3d symbol to the database.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
QgsAbstract3DSymbol * symbol3D(const QString &name) const
Returns a new copy of the 3D symbol with the specified name.
int addTag(const QString &tagName)
Adds a new tag and returns the tag's id.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QgsLegendPatchShape legendPatchShape(const QString &name) const
Returns the legend patch shape with the specified name.
QStringList symbolNames() const
Returns a list of names of symbols.
bool addFavorite(StyleEntity type, const QString &name)
Adds the specified symbol to favorites.
QString smartgroupOperator(int id)
Returns the operator for the smartgroup.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
bool addLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool update=false)
Adds label settings with the specified name to the style.
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Abstract base class for all rendered symbols.
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
A simple dialog for customizing text formatting settings.
Container for all settings relating to text rendering.
static QgsTextFormat fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsTextFormat.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
QMap< int, QString > QgsSymbolGroupMap