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 );
172 : QDialog( parent, flags )
174 , mReadOnly( readOnly )
178 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
182 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
183 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
185 connect( downloadButton, &QPushButton::clicked,
this, [ = ]
187 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://plugins.qgis.org/styles" ) ) );
191 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
192 mVerticalLayout->insertWidget( 0, mMessageBar );
195 setWindowModality( Qt::WindowModal );
200 mSplitter->setSizes( QList<int>() << 170 << 540 );
201 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
203 tabItemType->setDocumentMode(
true );
204 searchBox->setShowSearchIcon(
true );
205 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
209 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
211 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
216 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool )
219 if ( !btnAddItem->menu() )
224 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
226 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
231 btnAddTag->setEnabled(
false );
232 btnAddSmartgroup->setEnabled(
false );
235 QMenu *shareMenu =
new QMenu( tr(
"Share Menu" ),
this );
236 QAction *exportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
238 shareMenu->addAction( exportAction );
241 QAction *importAction =
new QAction( tr(
"Import Item(s)…" ),
this );
243 shareMenu->addAction( importAction );
248 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
249 shareMenu->addAction( mActionCopyToDefault );
250 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
251 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
255 mCopyToDefaultButton->hide();
258 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
259 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
260 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
261 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
263 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
264 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
265 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
266 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
267 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
269 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
272 shareMenu->addSeparator();
273 shareMenu->addAction( actnExportAsPNG );
274 shareMenu->addAction( actnExportAsSVG );
279 btnShare->setMenu( shareMenu );
282 listItems->setIconSize( QSize(
static_cast< int >(
iconSize ),
static_cast< int >(
iconSize * 0.9 ) ) );
284 listItems->setGridSize( QSize(
static_cast< int >( listItems->iconSize().width() * 1.4 ),
static_cast< int >( listItems->iconSize().height() * 1.7 ) ) );
285 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
287 mSymbolTreeView->setIconSize( QSize(
static_cast< int >( treeIconSize ),
static_cast< int >( treeIconSize ) ) );
290 :
new QgsCheckableStyleModel( mStyle,
this, mReadOnly );
291 mModel->addDesiredIconSize( listItems->iconSize() );
292 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
293 listItems->setModel( mModel );
294 mSymbolTreeView->setModel( mModel );
296 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
297 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
298 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
299 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
301 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
303 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
306 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
307 groupTree->setModel( groupModel );
308 groupTree->setHeaderHidden(
true );
310 groupTree->setCurrentIndex( groupTree->model()->index( 0, 0 ) );
312 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
316 connect( groupModel, &QStandardItemModel::itemChanged,
322 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
324 groupMenu->addAction( actnTagSymbols );
326 actnFinishTagging->setVisible(
false );
327 groupMenu->addAction( actnFinishTagging );
328 groupMenu->addAction( actnEditSmartGroup );
329 btnManageGroups->setMenu( groupMenu );
333 btnManageGroups->setEnabled(
false );
339 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
340 connect( groupTree, &QWidget::customContextMenuRequested,
344 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
345 connect( listItems, &QWidget::customContextMenuRequested,
347 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
348 connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
353 mMenuBtnAddItemAll =
new QMenu(
this );
354 mMenuBtnAddItemColorRamp =
new QMenu(
this );
355 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
356 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
357 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
361 mMenuBtnAddItemAll->addAction( item );
364 mMenuBtnAddItemAll->addAction( item );
367 mMenuBtnAddItemAll->addAction( item );
368 mMenuBtnAddItemAll->addSeparator();
371 for (
const QPair< QString, QString > &rampType : rampTypes )
373 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
374 connect( item, &QAction::triggered,
this, [ = ](
bool ) {
addColorRamp( rampType.first ); } );
375 mMenuBtnAddItemAll->addAction( item );
376 mMenuBtnAddItemColorRamp->addAction( item );
378 mMenuBtnAddItemAll->addSeparator();
380 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addTextFormat(); } );
381 mMenuBtnAddItemAll->addAction( item );
382 mMenuBtnAddItemAll->addSeparator();
385 mMenuBtnAddItemAll->addAction( item );
386 mMenuBtnAddItemLabelSettings->addAction( item );
389 mMenuBtnAddItemAll->addAction( item );
390 mMenuBtnAddItemLabelSettings->addAction( item );
393 mMenuBtnAddItemAll->addAction( item );
394 mMenuBtnAddItemLabelSettings->addAction( item );
396 mMenuBtnAddItemAll->addSeparator();
399 mMenuBtnAddItemAll->addAction( item );
400 mMenuBtnAddItemLegendPatchShape->addAction( item );
402 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
403 mMenuBtnAddItemAll->addAction( item );
404 mMenuBtnAddItemLegendPatchShape->addAction( item );
406 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
407 mMenuBtnAddItemAll->addAction( item );
408 mMenuBtnAddItemLegendPatchShape->addAction( item );
410 mMenuBtnAddItemAll->addSeparator();
412 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"point" ) ); } );
413 mMenuBtnAddItemAll->addAction( item );
414 mMenuBtnAddItemSymbol3D->addAction( item );
416 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
417 mMenuBtnAddItemAll->addAction( item );
418 mMenuBtnAddItemSymbol3D->addAction( item );
420 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
421 mMenuBtnAddItemAll->addAction( item );
422 mMenuBtnAddItemSymbol3D->addAction( item );
426 mGroupMenu =
new QMenu(
this );
427 mGroupListMenu =
new QMenu( mGroupMenu );
428 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
429 mGroupListMenu->setEnabled(
false );
433 mGroupMenu->addAction( actnAddFavorite );
435 mGroupMenu->addAction( actnRemoveFavorite );
436 mGroupMenu->addSeparator()->setParent(
this );
437 mGroupMenu->addMenu( mGroupListMenu );
438 actnDetag->setData( 0 );
440 mGroupMenu->addAction( actnDetag );
441 mGroupMenu->addSeparator()->setParent(
this );
442 mGroupMenu->addAction( actnRemoveItem );
443 mGroupMenu->addAction( actnEditItem );
444 mGroupMenu->addAction( mActionCopyItem );
445 mGroupMenu->addAction( mActionPasteItem );
446 mGroupMenu->addSeparator()->setParent(
this );
450 btnAddItem->setVisible(
false );
451 btnRemoveItem->setVisible(
false );
452 btnEditItem->setVisible(
false );
453 btnAddSmartgroup->setVisible(
false );
454 btnAddTag->setVisible(
false );
455 btnManageGroups->setVisible(
false );
457 mGroupMenu->addAction( mActionCopyItem );
459 if ( mActionCopyToDefault )
461 mGroupMenu->addAction( mActionCopyToDefault );
463 mGroupMenu->addAction( actnExportAsPNG );
464 mGroupMenu->addAction( actnExportAsSVG );
467 mGroupTreeContextMenu =
new QMenu(
this );
471 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
472 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); }
474 mGroupTreeContextMenu->addAction( actnAddTag );
475 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); }
477 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
479 mGroupTreeContextMenu->addAction( actnRemoveGroup );
482 tabItemType_currentChanged( 0 );
487 connect( mButtonIconView, &QToolButton::toggled,
this, [ = ](
bool active )
491 mSymbolViewStackedWidget->setCurrentIndex( 0 );
496 connect( mButtonListView, &QToolButton::toggled,
this, [ = ](
bool active )
501 mSymbolViewStackedWidget->setCurrentIndex( 1 );
505 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
506 if ( currentView == 0 )
507 mButtonIconView->setChecked(
true );
509 mButtonListView->setChecked(
true );
511 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
512 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this]
515 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
524 if ( mModified && !mReadOnly )
530 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
537 void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
546 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
547 isColorRamp ? tr(
"Filter color ramps…" ) :
548 isTextFormat ? tr(
"Filter text symbols…" ) :
549 isLabelSettings ? tr(
"Filter label settings…" ) :
550 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
552 if ( !mReadOnly && isColorRamp )
554 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
556 else if ( !mReadOnly && isLegendPatchShape )
558 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
560 else if ( !mReadOnly && isSymbol3D )
562 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
564 else if ( !mReadOnly && isLabelSettings )
566 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
568 else if ( !mReadOnly && !isSymbol && !isColorRamp )
570 btnAddItem->setMenu(
nullptr );
572 else if ( !mReadOnly && tabItemType->currentIndex() == 0 )
574 btnAddItem->setMenu( mMenuBtnAddItemAll );
578 btnAddItem->setMenu(
nullptr );
581 actnExportAsPNG->setVisible( isSymbol );
582 actnExportAsSVG->setVisible( isSymbol );
585 mModel->setEntityFilterEnabled( !allTypesSelected() );
586 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
587 if ( isSymbol && !allTypesSelected() )
593 void QgsStyleManagerDialog::copyItemsToDefault()
595 const QList< ItemDetails > items = selectedItems();
596 if ( !items.empty() )
600 if ( !mBaseName.isEmpty() )
601 options.append( mBaseName );
604 defaultTags.sort( Qt::CaseInsensitive );
605 options.append( defaultTags );
606 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
607 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
611 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
612 const QStringList parts = tags.split(
',', QString::SkipEmptyParts );
614 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
616 QStringList additionalTags;
617 additionalTags.reserve( parts.count() );
618 for (
const QString &tag : parts )
619 additionalTags << tag.trimmed();
621 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
622 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
623 cursorOverride.reset();
626 mMessageBar->
pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %1 items." ).arg( count ) : tr(
"Successfully imported item." ) );
631 void QgsStyleManagerDialog::copyItem()
633 const QList< ItemDetails > items = selectedItems();
637 ItemDetails details = items.at( 0 );
638 switch ( details.entityType )
642 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
652 QApplication::clipboard()->setMimeData( format.toMimeData() );
659 QApplication::clipboard()->setMimeData( format.toMimeData() );
673 void QgsStyleManagerDialog::pasteItem()
675 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
680 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
681 saveDlg.setDefaultTags( defaultTag );
682 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
685 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
687 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
688 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
689 .arg( saveDlg.name() ),
690 QMessageBox::Yes | QMessageBox::No );
691 if ( res != QMessageBox::Yes )
698 QStringList symbolTags = saveDlg.tags().split(
',' );
700 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
702 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
711 saveDlg.setDefaultTags( defaultTag );
712 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
713 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
718 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
719 tr(
"A format with the name '%1' already exists. Overwrite?" )
720 .arg( saveDlg.name() ),
721 QMessageBox::Yes | QMessageBox::No );
722 if ( res != QMessageBox::Yes )
729 QStringList symbolTags = saveDlg.tags().split(
',' );
732 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
737 int QgsStyleManagerDialog::selectedItemType()
739 QModelIndex index = listItems->selectionModel()->currentIndex();
740 if ( !index.isValid() )
758 bool QgsStyleManagerDialog::allTypesSelected()
const
760 return tabItemType->currentIndex() == 0;
763 QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
765 QList<QgsStyleManagerDialog::ItemDetails > res;
766 QModelIndexList indices = listItems->selectionModel()->selectedRows();
767 for (
const QModelIndex &index : indices )
769 if ( !index.isValid() )
776 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
783 int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
784 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
787 bool overwriteAll =
true;
797 for (
auto &details : items )
799 QStringList symbolTags;
800 if ( !ignoreSourceTags )
802 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
805 bool addItemToFavorites =
false;
808 symbolTags << importTags;
809 addItemToFavorites = addToFavorites;
812 switch ( details.entityType )
816 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
820 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
821 bool overwriteThis =
false;
823 addItemToFavorites = favoriteSymbols.contains( details.name );
825 if ( hasDuplicateName && prompt )
827 cursorOverride.reset();
828 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
829 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
830 .arg( details.name ),
831 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
832 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
835 case QMessageBox::Cancel:
838 case QMessageBox::No:
841 case QMessageBox::Yes:
842 overwriteThis =
true;
845 case QMessageBox::YesToAll:
850 case QMessageBox::NoToAll:
852 overwriteAll =
false;
857 if ( !hasDuplicateName || overwriteAll || overwriteThis )
860 dst->
addSymbol( details.name, symbol.release() );
861 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
869 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
873 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
874 bool overwriteThis =
false;
876 addItemToFavorites = favoriteColorramps.contains( details.name );
878 if ( hasDuplicateName && prompt )
880 cursorOverride.reset();
881 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
882 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
883 .arg( details.name ),
884 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
885 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
888 case QMessageBox::Cancel:
891 case QMessageBox::No:
894 case QMessageBox::Yes:
895 overwriteThis =
true;
898 case QMessageBox::YesToAll:
903 case QMessageBox::NoToAll:
905 overwriteAll =
false;
910 if ( !hasDuplicateName || overwriteAll || overwriteThis )
914 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
924 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
925 bool overwriteThis =
false;
927 addItemToFavorites = favoriteTextFormats.contains( details.name );
929 if ( hasDuplicateName && prompt )
931 cursorOverride.reset();
932 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
933 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
934 .arg( details.name ),
935 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
936 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
939 case QMessageBox::Cancel:
942 case QMessageBox::No:
945 case QMessageBox::Yes:
946 overwriteThis =
true;
949 case QMessageBox::YesToAll:
954 case QMessageBox::NoToAll:
956 overwriteAll =
false;
961 if ( !hasDuplicateName || overwriteAll || overwriteThis )
964 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
975 bool overwriteThis =
false;
977 addItemToFavorites = favoriteLabelSettings.contains( details.name );
979 if ( hasDuplicateName && prompt )
981 cursorOverride.reset();
982 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
983 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
984 .arg( details.name ),
985 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
986 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
989 case QMessageBox::Cancel:
992 case QMessageBox::No:
995 case QMessageBox::Yes:
996 overwriteThis =
true;
999 case QMessageBox::YesToAll:
1001 overwriteAll =
true;
1004 case QMessageBox::NoToAll:
1006 overwriteAll =
false;
1011 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1014 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1025 bool overwriteThis =
false;
1027 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1029 if ( hasDuplicateName && prompt )
1031 cursorOverride.reset();
1032 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1033 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1034 .arg( details.name ),
1035 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1036 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1039 case QMessageBox::Cancel:
1042 case QMessageBox::No:
1045 case QMessageBox::Yes:
1046 overwriteThis =
true;
1049 case QMessageBox::YesToAll:
1051 overwriteAll =
true;
1054 case QMessageBox::NoToAll:
1056 overwriteAll =
false;
1061 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1072 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1076 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1077 bool overwriteThis =
false;
1079 addItemToFavorites = favorite3dSymbols.contains( details.name );
1081 if ( hasDuplicateName && prompt )
1083 cursorOverride.reset();
1084 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1085 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1086 .arg( details.name ),
1087 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1088 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1091 case QMessageBox::Cancel:
1094 case QMessageBox::No:
1097 case QMessageBox::Yes:
1098 overwriteThis =
true;
1101 case QMessageBox::YesToAll:
1103 overwriteAll =
true;
1106 case QMessageBox::NoToAll:
1108 overwriteAll =
false;
1113 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1116 dst->
addSymbol3D( details.name, symbol.release() );
1117 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1132 bool QgsStyleManagerDialog::addTextFormat()
1136 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1137 if ( !formatDlg.exec() )
1139 format = formatDlg.format();
1142 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1143 saveDlg.setDefaultTags( defaultTag );
1144 if ( !saveDlg.exec() )
1146 QString name = saveDlg.name();
1149 bool nameInvalid =
true;
1150 while ( nameInvalid )
1153 if ( name.isEmpty() )
1155 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1156 tr(
"Cannot save text format without name. Enter a name." ) );
1160 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1161 tr(
"Text format with name '%1' already exists. Overwrite?" )
1163 QMessageBox::Yes | QMessageBox::No );
1164 if ( res == QMessageBox::Yes )
1167 nameInvalid =
false;
1173 nameInvalid =
false;
1178 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1179 tr(
"Please enter a name for new text format:" ),
1180 QLineEdit::Normal, name, &ok );
1188 QStringList symbolTags = saveDlg.tags().split(
',' );
1192 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1200 groupChanged( groupTree->selectionModel()->currentIndex() );
1213 switch ( tabItemType->currentIndex() )
1238 QModelIndex index = listItems->selectionModel()->currentIndex();
1239 if ( !index.isValid() )
1242 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1247 bool changed =
false;
1258 changed = addTextFormat();
1277 Q_ASSERT(
false &&
"not implemented" );
1290 QString name = tr(
"new symbol" );
1291 QString dialogTitle;
1296 name = tr(
"new marker" );
1297 dialogTitle = tr(
"New Marker Symbol" );
1301 name = tr(
"new line" );
1302 dialogTitle = tr(
"New Line Symbol" );
1306 name = tr(
"new fill symbol" );
1307 dialogTitle = tr(
"New Fill Symbol" );
1310 Q_ASSERT(
false &&
"unknown symbol type" );
1320 dlg.setWindowTitle( dialogTitle );
1321 if ( dlg.exec() == 0 )
1328 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1330 if ( !saveDlg.exec() )
1336 name = saveDlg.
name();
1339 bool nameInvalid =
true;
1340 while ( nameInvalid )
1343 if ( name.isEmpty() )
1345 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1346 tr(
"Cannot save symbol without name. Enter a name." ) );
1348 else if ( mStyle->
symbolNames().contains( name ) )
1350 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1351 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1353 QMessageBox::Yes | QMessageBox::No );
1354 if ( res == QMessageBox::Yes )
1357 nameInvalid =
false;
1363 nameInvalid =
false;
1368 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1369 tr(
"Please enter a name for new symbol:" ),
1370 QLineEdit::Normal, name, &ok );
1379 QStringList symbolTags = saveDlg.
tags().split(
',' );
1392 QString rampType = type;
1394 if ( rampType.isEmpty() )
1399 QStringList rampTypeNames;
1400 rampTypeNames.reserve( rampTypes.size() );
1401 for (
const QPair< QString, QString > &type : rampTypes )
1402 rampTypeNames << type.second;
1403 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1404 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1405 if ( !ok || selectedRampTypeName.isEmpty() )
1408 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1411 QString name = tr(
"new ramp" );
1413 std::unique_ptr< QgsColorRamp > ramp;
1417 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1423 name = tr(
"new gradient ramp" );
1428 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1434 name = tr(
"new random ramp" );
1439 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1450 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1456 name = tr(
"new preset ramp" );
1461 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1481 QgsDebugMsg( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1486 if ( !saveDlg.exec() )
1491 name = saveDlg.
name();
1494 bool nameInvalid =
true;
1495 while ( nameInvalid )
1498 if ( name.isEmpty() )
1500 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1501 tr(
"Cannot save color ramp without name. Enter a name." ) );
1505 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1506 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1508 QMessageBox::Yes | QMessageBox::No );
1509 if ( res == QMessageBox::Yes )
1511 nameInvalid =
false;
1517 nameInvalid =
false;
1522 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1523 tr(
"Please enter a name for new color ramp:" ),
1524 QLineEdit::Normal, name, &ok );
1532 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1544 mFavoritesGroupVisible = show;
1550 mSmartGroupVisible = show;
1562 setWindowState( windowState() & ~Qt::WindowMinimized );
1570 if ( !rampName.isEmpty() )
1582 if ( selectedItemType() < 3 )
1586 else if ( selectedItemType() == 3 )
1590 else if ( selectedItemType() == 4 )
1594 else if ( selectedItemType() == 5 )
1596 editLabelSettings();
1598 else if ( selectedItemType() == 6 )
1600 editLegendPatchShape();
1602 else if ( selectedItemType() == 7 )
1608 Q_ASSERT(
false &&
"not implemented" );
1615 if ( symbolName.isEmpty() )
1618 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1622 dlg.setWindowTitle( symbolName );
1624 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1630 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1638 if ( name.isEmpty() )
1641 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1647 dlg.setWindowTitle( name );
1649 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1661 dlg.setWindowTitle( name );
1663 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1675 dlg.setWindowTitle( name );
1677 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1689 dlg.setWindowTitle( name );
1691 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1703 dlg.setWindowTitle( name );
1705 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1722 Q_ASSERT(
false &&
"invalid ramp type" );
1730 bool QgsStyleManagerDialog::editTextFormat()
1733 if ( formatName.isEmpty() )
1740 dlg.setWindowTitle( formatName );
1742 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1756 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1757 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1759 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1761 if ( !settingsDlg.exec() )
1764 settings = settingsDlg.settings();
1768 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1769 saveDlg.setDefaultTags( defaultTag );
1770 if ( !saveDlg.exec() )
1772 QString name = saveDlg.name();
1775 bool nameInvalid =
true;
1776 while ( nameInvalid )
1779 if ( name.isEmpty() )
1781 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1782 tr(
"Cannot save label settings without a name. Enter a name." ) );
1786 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1787 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1789 QMessageBox::Yes | QMessageBox::No );
1790 if ( res == QMessageBox::Yes )
1793 nameInvalid =
false;
1799 nameInvalid =
false;
1804 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1805 tr(
"Please enter a name for the new label settings:" ),
1806 QLineEdit::Normal, name, &ok );
1814 QStringList symbolTags = saveDlg.tags().split(
',' );
1824 bool QgsStyleManagerDialog::editLabelSettings()
1827 if ( formatName.isEmpty() )
1834 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1835 dlg.setWindowTitle( formatName );
1839 settings = dlg.settings();
1852 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1854 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1856 if ( !dialog.exec() )
1859 shape = dialog.shape();
1862 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1863 saveDlg.setDefaultTags( defaultTag );
1864 if ( !saveDlg.exec() )
1866 QString name = saveDlg.name();
1869 bool nameInvalid =
true;
1870 while ( nameInvalid )
1873 if ( name.isEmpty() )
1875 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1876 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1880 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1881 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
1883 QMessageBox::Yes | QMessageBox::No );
1884 if ( res == QMessageBox::Yes )
1887 nameInvalid =
false;
1893 nameInvalid =
false;
1898 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
1899 tr(
"Please enter a name for the new legend patch shape:" ),
1900 QLineEdit::Normal, name, &ok );
1908 QStringList symbolTags = saveDlg.tags().split(
',' );
1918 bool QgsStyleManagerDialog::editLegendPatchShape()
1921 if ( shapeName.isEmpty() )
1930 dlg.setWindowTitle( shapeName );
1934 shape = dlg.shape();
1942 bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
1949 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
1951 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1953 if ( !dialog.exec() )
1956 symbol.reset( dialog.symbol() );
1961 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1962 saveDlg.setDefaultTags( defaultTag );
1963 if ( !saveDlg.exec() )
1965 QString name = saveDlg.name();
1968 bool nameInvalid =
true;
1969 while ( nameInvalid )
1972 if ( name.isEmpty() )
1974 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
1975 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
1979 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
1980 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
1982 QMessageBox::Yes | QMessageBox::No );
1983 if ( res == QMessageBox::Yes )
1986 nameInvalid =
false;
1992 nameInvalid =
false;
1997 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
1998 tr(
"Please enter a name for the new 3D symbol:" ),
1999 QLineEdit::Normal, name, &ok );
2007 QStringList symbolTags = saveDlg.tags().split(
',' );
2012 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2018 bool QgsStyleManagerDialog::editSymbol3D()
2021 if ( symbolName.isEmpty() )
2024 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2030 dlg.setWindowTitle( symbolName );
2034 symbol.reset( dlg.symbol() );
2039 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2046 const QList< ItemDetails > items = selectedItems();
2048 if ( allTypesSelected() )
2050 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2051 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2060 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2061 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2068 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2069 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2076 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2077 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2084 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2085 QString( tr(
"Do you really want to remove %n label settings?",
nullptr, items.count() ) ),
2092 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2093 QString( tr(
"Do you really want to remove %n legend patch shapes?",
nullptr, items.count() ) ),
2100 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2101 QString( tr(
"Do you really want to remove %n 3D symbols?",
nullptr, items.count() ) ),
2110 for (
const ItemDetails &details : items )
2112 if ( details.name.isEmpty() )
2137 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2138 QDir::home().absolutePath(),
2139 QFileDialog::ShowDirsOnly
2140 | QFileDialog::DontResolveSymlinks );
2146 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2147 QDir::home().absolutePath(),
2148 QFileDialog::ShowDirsOnly
2149 | QFileDialog::DontResolveSymlinks );
2156 if ( dir.isEmpty() )
2159 const QList< ItemDetails > items = selectedItems();
2160 for (
const ItemDetails &details : items )
2165 QString path = dir +
'/' + details.name +
'.' + format;
2166 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2168 sym->exportImage( path, format, size );
2188 QFont font = item->font();
2189 font.setBold(
true );
2190 item->setFont( font );
2195 if ( mBlockGroupUpdates )
2198 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2201 if ( mFavoritesGroupVisible )
2203 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2204 favoriteSymbols->setData(
"favorite" );
2205 favoriteSymbols->setEditable(
false );
2207 model->appendRow( favoriteSymbols );
2210 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2211 allSymbols->setData(
"all" );
2212 allSymbols->setEditable(
false );
2214 model->appendRow( allSymbols );
2216 QStandardItem *taggroup =
new QStandardItem( QString() );
2217 taggroup->setData(
"tags" );
2218 taggroup->setEditable(
false );
2219 QStringList tags = mStyle->
tags();
2221 for (
const QString &tag : std::as_const( tags ) )
2223 QStandardItem *item =
new QStandardItem( tag );
2224 item->setData( mStyle->
tagId( tag ) );
2226 item->setEditable( !mReadOnly );
2227 taggroup->appendRow( item );
2229 taggroup->setText( tr(
"Tags" ) );
2231 model->appendRow( taggroup );
2233 if ( mSmartGroupVisible )
2235 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2236 smart->setData(
"smartgroups" );
2237 smart->setEditable(
false );
2240 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2241 while ( i != sgMap.constEnd() )
2243 QStandardItem *item =
new QStandardItem( i.value() );
2244 item->setData( i.key() );
2245 item->setEditable( !mReadOnly );
2246 smart->appendRow( item );
2249 model->appendRow( smart );
2253 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2254 for (
int i = 0; i < rows; i++ )
2256 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2262 QStringList groupSymbols;
2264 const QString category = index.data( Qt::UserRole + 1 ).toString();
2265 if ( mGroupingMode )
2267 mModel->setTagId( -1 );
2268 mModel->setSmartGroupId( -1 );
2269 mModel->setFavoritesOnly(
false );
2270 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2272 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2275 if ( category == QLatin1String(
"tags" ) )
2277 actnAddTag->setEnabled( !mReadOnly );
2278 actnAddSmartgroup->setEnabled(
false );
2280 else if ( category == QLatin1String(
"smartgroups" ) )
2282 actnAddTag->setEnabled(
false );
2283 actnAddSmartgroup->setEnabled( !mReadOnly );
2286 mModel->setTagId( -1 );
2287 mModel->setSmartGroupId( -1 );
2288 mModel->setFavoritesOnly(
false );
2290 else if ( category == QLatin1String(
"favorite" ) )
2293 mModel->setTagId( -1 );
2294 mModel->setSmartGroupId( -1 );
2295 mModel->setFavoritesOnly(
true );
2297 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2299 actnRemoveGroup->setEnabled( !mReadOnly );
2300 btnManageGroups->setEnabled( !mReadOnly );
2301 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2302 mModel->setTagId( -1 );
2303 mModel->setSmartGroupId( groupId );
2304 mModel->setFavoritesOnly(
false );
2309 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2310 mModel->setTagId( tagId );
2311 mModel->setSmartGroupId( -1 );
2312 mModel->setFavoritesOnly(
false );
2315 actnEditSmartGroup->setVisible(
false );
2316 actnAddTag->setVisible(
false );
2317 actnAddSmartgroup->setVisible(
false );
2318 actnRemoveGroup->setVisible(
false );
2319 actnTagSymbols->setVisible(
false );
2320 actnFinishTagging->setVisible(
false );
2322 if ( index.parent().isValid() )
2324 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2326 actnEditSmartGroup->setVisible( !mGroupingMode && !mReadOnly );
2328 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2330 actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
2331 actnTagSymbols->setVisible( !mGroupingMode && !mReadOnly );
2332 actnFinishTagging->setVisible( mGroupingMode && !mReadOnly );
2334 actnRemoveGroup->setVisible( !mReadOnly );
2336 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2338 actnAddSmartgroup->setVisible( !mGroupingMode && !mReadOnly );
2340 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2342 actnAddTag->setVisible( !mGroupingMode && !mReadOnly );
2348 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2350 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2352 index = groupTree->model()->index( i, 0 );
2353 QString data = index.data( Qt::UserRole + 1 ).toString();
2354 if ( data == QLatin1String(
"tags" ) )
2363 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2364 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2365 if ( !ok || itemName.isEmpty() )
2368 int check = mStyle->
tagId( itemName );
2371 mMessageBar->
pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2377 mBlockGroupUpdates++;
2378 id = mStyle->
addTag( itemName );
2379 mBlockGroupUpdates--;
2383 mMessageBar->
pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2387 QStandardItem *parentItem = model->itemFromIndex( index );
2388 QStandardItem *childItem =
new QStandardItem( itemName );
2389 childItem->setData(
id );
2391 parentItem->appendRow( childItem );
2398 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2400 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2402 index = groupTree->model()->index( i, 0 );
2403 QString data = index.data( Qt::UserRole + 1 ).toString();
2404 if ( data == QLatin1String(
"smartgroups" ) )
2413 if ( dlg.exec() == QDialog::Rejected )
2418 mBlockGroupUpdates++;
2420 mBlockGroupUpdates--;
2426 QStandardItem *parentItem = model->itemFromIndex( index );
2427 QStandardItem *childItem =
new QStandardItem( itemName );
2428 childItem->setData(
id );
2429 parentItem->appendRow( childItem );
2436 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2437 QModelIndex index = groupTree->currentIndex();
2440 QString data = index.data( Qt::UserRole + 1 ).toString();
2441 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2444 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2445 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2446 "Kindly select a group or smart group you might want to delete." ) );
2451 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2455 mBlockGroupUpdates++;
2457 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2466 mBlockGroupUpdates--;
2467 parentItem->removeRow( index.row() );
2472 QgsDebugMsg( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ) );
2473 int id = item->data( Qt::UserRole + 1 ).toInt();
2474 QString name = item->text();
2475 mBlockGroupUpdates++;
2476 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2484 mBlockGroupUpdates--;
2489 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2491 if ( mGroupingMode )
2493 mGroupingMode =
false;
2494 mModel->setCheckable(
false );
2495 actnTagSymbols->setVisible(
true );
2496 actnFinishTagging->setVisible(
false );
2504 connect( treeModel, &QStandardItemModel::itemChanged,
2508 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2509 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2513 bool validGroup =
false;
2515 QModelIndex present = groupTree->currentIndex();
2516 while ( present.parent().isValid() )
2518 if ( present.parent().data() ==
"Tags" )
2523 present = present.parent();
2528 mGroupingMode =
true;
2530 actnTagSymbols->setVisible(
false );
2531 actnFinishTagging->setVisible(
true );
2533 disconnect( treeModel, &QStandardItemModel::itemChanged,
2539 btnManageGroups->setEnabled(
true );
2541 mModel->setCheckable(
true );
2544 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2545 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2559 mModel->setFilterString( qword );
2564 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !mReadOnly );
2569 Q_UNUSED( selected )
2570 Q_UNUSED( deselected )
2571 bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2572 actnRemoveItem->setDisabled( nothingSelected || mReadOnly );
2573 actnAddFavorite->setDisabled( nothingSelected || mReadOnly );
2574 actnRemoveFavorite->setDisabled( nothingSelected || mReadOnly );
2575 mGroupListMenu->setDisabled( nothingSelected || mReadOnly );
2576 actnDetag->setDisabled( nothingSelected || mReadOnly );
2577 actnExportAsPNG->setDisabled( nothingSelected );
2578 actnExportAsSVG->setDisabled( nothingSelected );
2579 if ( mActionCopyToDefault )
2580 mActionCopyToDefault->setDisabled( nothingSelected );
2581 mCopyToDefaultButton->setDisabled( nothingSelected );
2582 actnEditItem->setDisabled( nothingSelected || mReadOnly );
2587 groupTree->setEnabled( enable );
2588 btnAddTag->setEnabled( enable && !mReadOnly );
2589 btnAddSmartgroup->setEnabled( enable && !mReadOnly );
2590 actnAddTag->setEnabled( enable && !mReadOnly );
2591 actnAddSmartgroup->setEnabled( enable && !mReadOnly );
2592 actnRemoveGroup->setEnabled( enable && !mReadOnly );
2593 btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) );
2594 searchBox->setEnabled( enable );
2599 actnRemoveGroup->setEnabled( enable && !mReadOnly );
2600 btnManageGroups->setEnabled( !mReadOnly && ( enable || mGroupingMode ) );
2605 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2606 for (
int i = 0; i < treeModel->rowCount(); i++ )
2608 treeModel->item( i )->setEnabled( enable );
2610 if ( treeModel->item( i )->data() ==
"smartgroups" )
2612 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2614 treeModel->item( i )->child( j )->setEnabled( enable );
2621 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2623 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2625 w->setEnabled( enable );
2629 actnRemoveItem->setEnabled( enable );
2630 actnEditItem->setEnabled( enable );
2631 mActionCopyItem->setEnabled( enable );
2632 mActionPasteItem->setEnabled( enable );
2637 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2639 QModelIndex index = groupTree->indexAt( point );
2640 if ( index.isValid() && !mGroupingMode )
2641 mGroupTreeContextMenu->popup( globalPos );
2646 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2647 ? listItems->viewport()->mapToGlobal( point )
2648 : mSymbolTreeView->viewport()->mapToGlobal( point );
2651 mGroupListMenu->clear();
2653 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2657 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
QgsStyleModel::TagRole ).toStringList() : QStringList();
2658 QAction *a =
nullptr;
2659 QStringList tags = mStyle->
tags();
2661 for (
const QString &tag : std::as_const( tags ) )
2663 a =
new QAction( tag, mGroupListMenu );
2665 if ( indices.count() == 1 )
2667 a->setCheckable(
true );
2668 a->setChecked( currentTags.contains( tag ) );
2672 mGroupListMenu->addAction( a );
2675 if ( tags.count() > 0 )
2677 mGroupListMenu->addSeparator();
2679 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2682 mGroupListMenu->addAction( a );
2685 const QList< ItemDetails > items = selectedItems();
2688 bool enablePaste =
false;
2696 mActionPasteItem->setEnabled( enablePaste );
2698 mGroupMenu->popup( globalPos );
2703 const QList< ItemDetails > items = selectedItems();
2704 for (
const ItemDetails &details : items )
2706 mStyle->
addFavorite( details.entityType, details.name );
2712 const QList< ItemDetails > items = selectedItems();
2713 for (
const ItemDetails &details : items )
2721 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2724 const QList< ItemDetails > items = selectedItems();
2734 tag = mStyle->
tag(
id );
2738 tag = selectedItem->data().toString();
2741 for (
const ItemDetails &details : items )
2743 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2750 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2754 const QList< ItemDetails > items = selectedItems();
2755 for (
const ItemDetails &details : items )
2757 mStyle->
detagSymbol( details.entityType, details.name );
2764 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2767 QModelIndex present = groupTree->currentIndex();
2768 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2771 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2772 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2775 QStandardItem *item = treeModel->itemFromIndex( present );
2783 if ( dlg.exec() == QDialog::Rejected )
2786 mBlockGroupUpdates++;
2789 mBlockGroupUpdates--;
2792 mMessageBar->
pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2796 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 QgsGui * instance()
Returns a pointer to the singleton instance.
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