53#include <QInputDialog>
56#include <QStandardItemModel>
59#include <QDesktopServices>
73QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
75 , mStyle( sourceModel->style() )
76 , mReadOnly( readOnly )
81QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
84 , mReadOnly( readOnly )
88void QgsCheckableStyleModel::setCheckable(
bool checkable )
90 if ( checkable == mCheckable )
93 mCheckable = checkable;
94 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
97void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
99 if ( tag == mCheckTag )
103 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
106Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
108 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
109 if ( !mReadOnly && mCheckable && index.column() == 0 )
110 f |= Qt::ItemIsUserCheckable;
113 f &= ~Qt::ItemIsEditable;
118QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
125 QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
130 case Qt::CheckStateRole:
132 if ( !mCheckable || index.column() != 0 )
136 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
143 return QgsStyleProxyModel::data( index, role );
146bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
148 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) ||
149 ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
155 if ( role == Qt::CheckStateRole )
157 if ( !mCheckable || mCheckTag.isEmpty() )
160 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
163 if ( value.toInt() == Qt::Checked )
164 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
166 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
168 return QgsStyleProxyModel::setData( i, value, role );
178QString QgsStyleManagerDialog::sPreviousTag;
181 : QDialog( parent, flags )
182 , mReadOnly( readOnly )
185 setCurrentStyle( style );
186 mStyleDatabaseWidget->hide();
190 : QDialog( parent, flags )
196 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
200 connect( mComboBoxStyleDatabase, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ]()
202 if ( mBlockStyleDatabaseChanges )
205 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
209 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
false ); } );
210 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
true ); } );
213void QgsStyleManagerDialog::init()
217 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
221 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
222 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
224 connect( downloadButton, &QPushButton::clicked,
this, [ = ]
226 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://plugins.qgis.org/styles" ) ) );
230 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
231 mVerticalLayout->insertWidget( 0, mMessageBar );
234 setWindowModality( Qt::WindowModal );
239 mSplitter->setSizes( QList<int>() << 170 << 540 );
240 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
242 tabItemType->setDocumentMode(
true );
243 searchBox->setShowSearchIcon(
true );
244 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
248 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
250 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
254 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool )
257 if ( !btnAddItem->menu() )
264 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
266 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
269 mShareMenu =
new QMenu( tr(
"Share Menu" ),
this );
270 mExportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
272 mShareMenu->addAction( mExportAction );
274 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
276 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
277 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
278 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
279 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
281 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
282 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
283 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
284 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
285 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
287 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
290 mShareMenu->addSeparator();
291 mShareMenu->addAction( actnExportAsPNG );
292 mShareMenu->addAction( actnExportAsSVG );
297 btnShare->setMenu( mShareMenu );
299 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
301 mSymbolTreeView->setIconSize( QSize(
static_cast< int >( treeIconSize ),
static_cast< int >( treeIconSize ) ) );
303 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
304 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
305 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
307 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
308 groupTree->setModel( groupModel );
309 groupTree->setHeaderHidden(
true );
311 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
315 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
317 groupMenu->addAction( actnTagSymbols );
319 actnFinishTagging->setVisible(
false );
320 groupMenu->addAction( actnFinishTagging );
321 groupMenu->addAction( actnEditSmartGroup );
322 btnManageGroups->setMenu( groupMenu );
327 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
328 connect( groupTree, &QWidget::customContextMenuRequested,
332 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
333 connect( listItems, &QWidget::customContextMenuRequested,
335 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
336 connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
339 mMenuBtnAddItemAll =
new QMenu(
this );
340 mMenuBtnAddItemColorRamp =
new QMenu(
this );
341 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
342 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
343 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
347 mMenuBtnAddItemAll->addAction( item );
350 mMenuBtnAddItemAll->addAction( item );
353 mMenuBtnAddItemAll->addAction( item );
354 mMenuBtnAddItemAll->addSeparator();
357 for (
const QPair< QString, QString > &rampType : rampTypes )
359 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
360 connect( item, &QAction::triggered,
this, [ = ](
bool ) {
addColorRamp( rampType.first ); } );
361 mMenuBtnAddItemAll->addAction( item );
362 mMenuBtnAddItemColorRamp->addAction( item );
364 mMenuBtnAddItemAll->addSeparator();
366 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addTextFormat(); } );
367 mMenuBtnAddItemAll->addAction( item );
368 mMenuBtnAddItemAll->addSeparator();
371 mMenuBtnAddItemAll->addAction( item );
372 mMenuBtnAddItemLabelSettings->addAction( item );
375 mMenuBtnAddItemAll->addAction( item );
376 mMenuBtnAddItemLabelSettings->addAction( item );
379 mMenuBtnAddItemAll->addAction( item );
380 mMenuBtnAddItemLabelSettings->addAction( item );
382 mMenuBtnAddItemAll->addSeparator();
385 mMenuBtnAddItemAll->addAction( item );
386 mMenuBtnAddItemLegendPatchShape->addAction( item );
388 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
389 mMenuBtnAddItemAll->addAction( item );
390 mMenuBtnAddItemLegendPatchShape->addAction( item );
392 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
393 mMenuBtnAddItemAll->addAction( item );
394 mMenuBtnAddItemLegendPatchShape->addAction( item );
396 mMenuBtnAddItemAll->addSeparator();
398 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"point" ) ); } );
399 mMenuBtnAddItemAll->addAction( item );
400 mMenuBtnAddItemSymbol3D->addAction( item );
402 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
403 mMenuBtnAddItemAll->addAction( item );
404 mMenuBtnAddItemSymbol3D->addAction( item );
406 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
407 mMenuBtnAddItemAll->addAction( item );
408 mMenuBtnAddItemSymbol3D->addAction( item );
411 mGroupMenu =
new QMenu(
this );
412 mGroupListMenu =
new QMenu( mGroupMenu );
413 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
414 mGroupListMenu->setEnabled(
false );
421 mGroupTreeContextMenu =
new QMenu(
this );
423 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); } );
424 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); } );
427 tabItemType_currentChanged( 0 );
429 connect( mButtonIconView, &QToolButton::toggled,
this, [ = ](
bool active )
433 mSymbolViewStackedWidget->setCurrentIndex( 0 );
438 connect( mButtonListView, &QToolButton::toggled,
this, [ = ](
bool active )
443 mSymbolViewStackedWidget->setCurrentIndex( 1 );
447 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
448 if ( currentView == 0 )
449 mButtonIconView->setChecked(
true );
451 mButtonListView->setChecked(
true );
453 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
454 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this]
457 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
460 const int thumbnailSize = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), 0,
QgsSettings::Gui ).toInt();
461 mSliderIconSize->setValue( thumbnailSize );
462 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
463 setThumbnailSize( thumbnailSize );
466void QgsStyleManagerDialog::setCurrentStyle(
QgsStyle *style )
468 if ( mStyle == style )
478 QgsCheckableStyleModel *oldModel = mModel;
481 const bool readOnly = isReadOnly();
484 if ( !mActionCopyToDefault )
486 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
487 mShareMenu->insertAction( mActionCopyItem, mActionCopyToDefault );
488 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
490 mCopyToDefaultButton->show();
491 mModel =
new QgsCheckableStyleModel( mStyle,
this, readOnly );
495 mCopyToDefaultButton->hide();
496 if ( mActionCopyToDefault )
498 mActionCopyToDefault->deleteLater();
499 mActionCopyToDefault =
nullptr;
503 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
504 mModel->addDesiredIconSize( listItems->iconSize() );
507 mModel->setFilterString( searchBox->text() );
509 listItems->setModel( mModel );
510 mSymbolTreeView->setModel( mModel );
512 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
514 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
516 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
521 oldModel->deleteLater();
529 if ( mProjectStyleModel )
531 const QModelIndex styleIndex = mProjectStyleModel->
indexFromStyle( mStyle );
532 mBlockStyleDatabaseChanges++;
533 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
534 mBlockStyleDatabaseChanges--;
539 btnAddTag->setEnabled(
false );
540 btnAddSmartgroup->setEnabled(
false );
541 btnManageGroups->setEnabled(
false );
543 btnAddItem->setVisible(
false );
544 btnRemoveItem->setVisible(
false );
545 btnEditItem->setVisible(
false );
546 btnAddSmartgroup->setVisible(
false );
547 btnAddTag->setVisible(
false );
548 btnManageGroups->setVisible(
false );
550 delete mImportAction;
551 mImportAction =
nullptr;
553 mGroupTreeContextMenu->clear();
555 mGroupMenu->addAction( mActionCopyItem );
559 btnAddTag->setEnabled(
true );
560 btnAddSmartgroup->setEnabled(
true );
561 btnManageGroups->setEnabled(
true );
563 btnAddItem->setVisible(
true );
564 btnRemoveItem->setVisible(
true );
565 btnEditItem->setVisible(
true );
566 btnAddSmartgroup->setVisible(
true );
567 btnAddTag->setVisible(
true );
568 btnManageGroups->setVisible(
true );
570 if ( !mImportAction )
572 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
574 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
578 mGroupTreeContextMenu->clear();
579 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
580 mGroupTreeContextMenu->addAction( actnAddTag );
581 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
582 mGroupTreeContextMenu->addAction( actnRemoveGroup );
585 mGroupMenu->addAction( actnAddFavorite );
586 mGroupMenu->addAction( actnRemoveFavorite );
587 mGroupMenu->addSeparator()->setParent(
this );
588 mGroupMenu->addMenu( mGroupListMenu );
589 mGroupMenu->addAction( actnDetag );
590 mGroupMenu->addSeparator()->setParent(
this );
591 mGroupMenu->addAction( actnRemoveItem );
592 mGroupMenu->addAction( actnEditItem );
593 mGroupMenu->addAction( mActionCopyItem );
594 mGroupMenu->addAction( mActionPasteItem );
595 mGroupMenu->addSeparator()->setParent(
this );
598 if ( mActionCopyToDefault )
600 mGroupMenu->addAction( mActionCopyToDefault );
602 mGroupMenu->addAction( actnExportAsPNG );
603 mGroupMenu->addAction( actnExportAsSVG );
606 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
607 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
610 tabItemType_currentChanged( tabItemType->currentIndex() );
616void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
627 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
634void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
643 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
644 isColorRamp ? tr(
"Filter color ramps…" ) :
645 isTextFormat ? tr(
"Filter text symbols…" ) :
646 isLabelSettings ? tr(
"Filter label settings…" ) :
647 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
649 const bool readOnly = isReadOnly();
650 if ( !readOnly && isColorRamp )
652 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
654 else if ( !readOnly && isLegendPatchShape )
656 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
658 else if ( !readOnly && isSymbol3D )
660 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
662 else if ( !readOnly && isLabelSettings )
664 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
666 else if ( !readOnly && !isSymbol && !isColorRamp )
668 btnAddItem->setMenu(
nullptr );
670 else if ( !readOnly && tabItemType->currentIndex() == 0 )
672 btnAddItem->setMenu( mMenuBtnAddItemAll );
676 btnAddItem->setMenu(
nullptr );
679 actnExportAsPNG->setVisible( isSymbol );
680 actnExportAsSVG->setVisible( isSymbol );
685 mModel->setEntityFilterEnabled( !allTypesSelected() );
686 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
687 if ( isSymbol && !allTypesSelected() )
694void QgsStyleManagerDialog::copyItemsToDefault()
696 const QList< ItemDetails > items = selectedItems();
697 if ( !items.empty() )
701 if ( !mBaseName.isEmpty() )
702 options.append( mBaseName );
705 defaultTags.sort( Qt::CaseInsensitive );
706 options.append( defaultTags );
707 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
708 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0, true, &ok );
712#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
713 const QStringList parts = tags.split(
',', QString::SkipEmptyParts );
715 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
717 QStringList additionalTags;
718 additionalTags.reserve( parts.count() );
719 for (
const QString &tag : parts )
720 additionalTags << tag.trimmed();
722 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
723 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
724 cursorOverride.reset();
727 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
732void QgsStyleManagerDialog::copyItem()
734 const QList< ItemDetails > items = selectedItems();
738 ItemDetails details = items.at( 0 );
739 switch ( details.entityType )
743 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
753 QApplication::clipboard()->setMimeData( format.toMimeData() );
760 QApplication::clipboard()->setMimeData( format.toMimeData() );
774void QgsStyleManagerDialog::pasteItem()
776 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
781 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
782 saveDlg.setDefaultTags( defaultTag );
783 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
786 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
788 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
789 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
790 .arg( saveDlg.name() ),
791 QMessageBox::Yes | QMessageBox::No );
792 if ( res != QMessageBox::Yes )
799 QStringList symbolTags = saveDlg.tags().split(
',' );
801 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
803 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
812 saveDlg.setDefaultTags( defaultTag );
813 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
814 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
819 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
820 tr(
"A format with the name '%1' already exists. Overwrite?" )
821 .arg( saveDlg.name() ),
822 QMessageBox::Yes | QMessageBox::No );
823 if ( res != QMessageBox::Yes )
830 QStringList symbolTags = saveDlg.tags().split(
',' );
833 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
838void QgsStyleManagerDialog::setThumbnailSize(
int value )
843 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
846 listItems->setIconSize( QSize(
static_cast< int >( iconSize ),
static_cast< int >( iconSize * 0.9 ) ) );
847 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
850 mModel->addDesiredIconSize( listItems->iconSize() );
856int QgsStyleManagerDialog::selectedItemType()
858 QModelIndex index = listItems->selectionModel()->currentIndex();
859 if ( !index.isValid() )
877bool QgsStyleManagerDialog::allTypesSelected()
const
879 return tabItemType->currentIndex() == 0;
882bool QgsStyleManagerDialog::isReadOnly()
const
884 return mReadOnly || ( mStyle && mStyle->
isReadOnly() );
887QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
889 QList<QgsStyleManagerDialog::ItemDetails > res;
890 QModelIndexList indices = listItems->selectionModel()->selectedRows();
891 for (
const QModelIndex &index : indices )
893 if ( !index.isValid() )
900 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
907int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
908 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
911 bool overwriteAll =
true;
921 for (
auto &details : items )
923 QStringList symbolTags;
924 if ( !ignoreSourceTags )
926 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
929 bool addItemToFavorites =
false;
932 symbolTags << importTags;
933 addItemToFavorites = addToFavorites;
936 switch ( details.entityType )
940 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
944 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
945 bool overwriteThis =
false;
947 addItemToFavorites = favoriteSymbols.contains( details.name );
949 if ( hasDuplicateName && prompt )
951 cursorOverride.reset();
952 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
953 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
954 .arg( details.name ),
955 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
956 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
959 case QMessageBox::Cancel:
962 case QMessageBox::No:
965 case QMessageBox::Yes:
966 overwriteThis =
true;
969 case QMessageBox::YesToAll:
974 case QMessageBox::NoToAll:
976 overwriteAll =
false;
981 if ( !hasDuplicateName || overwriteAll || overwriteThis )
984 dst->
addSymbol( details.name, symbol.release() );
985 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
993 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
997 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
998 bool overwriteThis =
false;
1000 addItemToFavorites = favoriteColorramps.contains( details.name );
1002 if ( hasDuplicateName && prompt )
1004 cursorOverride.reset();
1005 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1006 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
1007 .arg( details.name ),
1008 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1009 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1012 case QMessageBox::Cancel:
1015 case QMessageBox::No:
1018 case QMessageBox::Yes:
1019 overwriteThis =
true;
1022 case QMessageBox::YesToAll:
1024 overwriteAll =
true;
1027 case QMessageBox::NoToAll:
1029 overwriteAll =
false;
1034 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1038 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1048 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1049 bool overwriteThis =
false;
1051 addItemToFavorites = favoriteTextFormats.contains( details.name );
1053 if ( hasDuplicateName && prompt )
1055 cursorOverride.reset();
1056 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1057 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
1058 .arg( details.name ),
1059 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1060 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1063 case QMessageBox::Cancel:
1066 case QMessageBox::No:
1069 case QMessageBox::Yes:
1070 overwriteThis =
true;
1073 case QMessageBox::YesToAll:
1075 overwriteAll =
true;
1078 case QMessageBox::NoToAll:
1080 overwriteAll =
false;
1085 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1088 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1099 bool overwriteThis =
false;
1101 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1103 if ( hasDuplicateName && prompt )
1105 cursorOverride.reset();
1106 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1107 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1108 .arg( details.name ),
1109 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1110 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1113 case QMessageBox::Cancel:
1116 case QMessageBox::No:
1119 case QMessageBox::Yes:
1120 overwriteThis =
true;
1123 case QMessageBox::YesToAll:
1125 overwriteAll =
true;
1128 case QMessageBox::NoToAll:
1130 overwriteAll =
false;
1135 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1138 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1149 bool overwriteThis =
false;
1151 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1153 if ( hasDuplicateName && prompt )
1155 cursorOverride.reset();
1156 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1157 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1158 .arg( details.name ),
1159 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1160 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1163 case QMessageBox::Cancel:
1166 case QMessageBox::No:
1169 case QMessageBox::Yes:
1170 overwriteThis =
true;
1173 case QMessageBox::YesToAll:
1175 overwriteAll =
true;
1178 case QMessageBox::NoToAll:
1180 overwriteAll =
false;
1185 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1196 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1200 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1201 bool overwriteThis =
false;
1203 addItemToFavorites = favorite3dSymbols.contains( details.name );
1205 if ( hasDuplicateName && prompt )
1207 cursorOverride.reset();
1208 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1209 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1210 .arg( details.name ),
1211 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1212 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1215 case QMessageBox::Cancel:
1218 case QMessageBox::No:
1221 case QMessageBox::Yes:
1222 overwriteThis =
true;
1225 case QMessageBox::YesToAll:
1227 overwriteAll =
true;
1230 case QMessageBox::NoToAll:
1232 overwriteAll =
false;
1237 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1240 dst->
addSymbol3D( details.name, symbol.release() );
1241 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1256bool QgsStyleManagerDialog::addTextFormat()
1260 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1261 if ( !formatDlg.exec() )
1263 format = formatDlg.format();
1266 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1267 saveDlg.setDefaultTags( defaultTag );
1268 if ( !saveDlg.exec() )
1270 QString name = saveDlg.name();
1273 bool nameInvalid =
true;
1274 while ( nameInvalid )
1277 if ( name.isEmpty() )
1279 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1280 tr(
"Cannot save text format without name. Enter a name." ) );
1284 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1285 tr(
"Text format with name '%1' already exists. Overwrite?" )
1287 QMessageBox::Yes | QMessageBox::No );
1288 if ( res == QMessageBox::Yes )
1291 nameInvalid =
false;
1297 nameInvalid =
false;
1302 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1303 tr(
"Please enter a name for new text format:" ),
1304 QLineEdit::Normal, name, &ok );
1312 QStringList symbolTags = saveDlg.tags().split(
',' );
1316 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1324 groupChanged( groupTree->selectionModel()->currentIndex() );
1337 switch ( tabItemType->currentIndex() )
1362 QModelIndex index = listItems->selectionModel()->currentIndex();
1363 if ( !index.isValid() )
1366 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1371 bool changed =
false;
1382 changed = addTextFormat();
1401 Q_ASSERT(
false &&
"not implemented" );
1414 QString name = tr(
"new symbol" );
1415 QString dialogTitle;
1420 name = tr(
"new marker" );
1421 dialogTitle = tr(
"New Marker Symbol" );
1425 name = tr(
"new line" );
1426 dialogTitle = tr(
"New Line Symbol" );
1430 name = tr(
"new fill symbol" );
1431 dialogTitle = tr(
"New Fill Symbol" );
1434 Q_ASSERT(
false &&
"unknown symbol type" );
1444 dlg.setWindowTitle( dialogTitle );
1445 if ( dlg.exec() == 0 )
1452 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1454 if ( !saveDlg.exec() )
1460 name = saveDlg.
name();
1463 bool nameInvalid =
true;
1464 while ( nameInvalid )
1467 if ( name.isEmpty() )
1469 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1470 tr(
"Cannot save symbol without name. Enter a name." ) );
1472 else if ( mStyle->
symbolNames().contains( name ) )
1474 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1475 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1477 QMessageBox::Yes | QMessageBox::No );
1478 if ( res == QMessageBox::Yes )
1481 nameInvalid =
false;
1487 nameInvalid =
false;
1492 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1493 tr(
"Please enter a name for new symbol:" ),
1494 QLineEdit::Normal, name, &ok );
1503 QStringList symbolTags = saveDlg.
tags().split(
',' );
1516 QString rampType = type;
1518 if ( rampType.isEmpty() )
1523 QStringList rampTypeNames;
1524 rampTypeNames.reserve( rampTypes.size() );
1525 for (
const QPair< QString, QString > &type : rampTypes )
1526 rampTypeNames << type.second;
1527 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1528 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1529 if ( !ok || selectedRampTypeName.isEmpty() )
1532 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1535 QString name = tr(
"new ramp" );
1537 std::unique_ptr< QgsColorRamp > ramp;
1541 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1547 name = tr(
"new gradient ramp" );
1552 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1558 name = tr(
"new random ramp" );
1563 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1574 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1580 name = tr(
"new preset ramp" );
1585 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1605 QgsDebugError( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1610 if ( !saveDlg.exec() )
1615 name = saveDlg.
name();
1618 bool nameInvalid =
true;
1619 while ( nameInvalid )
1622 if ( name.isEmpty() )
1624 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1625 tr(
"Cannot save color ramp without name. Enter a name." ) );
1629 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1630 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1632 QMessageBox::Yes | QMessageBox::No );
1633 if ( res == QMessageBox::Yes )
1635 nameInvalid =
false;
1641 nameInvalid =
false;
1646 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1647 tr(
"Please enter a name for new color ramp:" ),
1648 QLineEdit::Normal, name, &ok );
1656 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1668 mFavoritesGroupVisible = show;
1674 mSmartGroupVisible = show;
1686 setWindowState( windowState() & ~Qt::WindowMinimized );
1694 if ( !rampName.isEmpty() )
1706 if ( selectedItemType() < 3 )
1710 else if ( selectedItemType() == 3 )
1714 else if ( selectedItemType() == 4 )
1718 else if ( selectedItemType() == 5 )
1720 editLabelSettings();
1722 else if ( selectedItemType() == 6 )
1724 editLegendPatchShape();
1726 else if ( selectedItemType() == 7 )
1732 Q_ASSERT(
false &&
"not implemented" );
1739 if ( symbolName.isEmpty() )
1742 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1746 dlg.setWindowTitle( symbolName );
1748 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1754 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1762 if ( name.isEmpty() )
1765 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1771 dlg.setWindowTitle( name );
1773 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1785 dlg.setWindowTitle( name );
1787 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1799 dlg.setWindowTitle( name );
1801 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1813 dlg.setWindowTitle( name );
1815 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1827 dlg.setWindowTitle( name );
1829 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1846 Q_ASSERT(
false &&
"invalid ramp type" );
1854bool QgsStyleManagerDialog::editTextFormat()
1857 if ( formatName.isEmpty() )
1864 dlg.setWindowTitle( formatName );
1866 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1880 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1881 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1883 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1885 if ( !settingsDlg.exec() )
1888 settings = settingsDlg.settings();
1892 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1893 saveDlg.setDefaultTags( defaultTag );
1894 if ( !saveDlg.exec() )
1896 QString name = saveDlg.name();
1899 bool nameInvalid =
true;
1900 while ( nameInvalid )
1903 if ( name.isEmpty() )
1905 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1906 tr(
"Cannot save label settings without a name. Enter a name." ) );
1910 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1911 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1913 QMessageBox::Yes | QMessageBox::No );
1914 if ( res == QMessageBox::Yes )
1917 nameInvalid =
false;
1923 nameInvalid =
false;
1928 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1929 tr(
"Please enter a name for the new label settings:" ),
1930 QLineEdit::Normal, name, &ok );
1938 QStringList symbolTags = saveDlg.tags().split(
',' );
1948bool QgsStyleManagerDialog::editLabelSettings()
1951 if ( formatName.isEmpty() )
1958 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1959 dlg.setWindowTitle( formatName );
1963 settings = dlg.settings();
1976 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1978 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1980 if ( !dialog.exec() )
1983 shape = dialog.shape();
1986 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1987 saveDlg.setDefaultTags( defaultTag );
1988 if ( !saveDlg.exec() )
1990 QString name = saveDlg.name();
1993 bool nameInvalid =
true;
1994 while ( nameInvalid )
1997 if ( name.isEmpty() )
1999 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
2000 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
2004 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
2005 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
2007 QMessageBox::Yes | QMessageBox::No );
2008 if ( res == QMessageBox::Yes )
2011 nameInvalid =
false;
2017 nameInvalid =
false;
2022 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
2023 tr(
"Please enter a name for the new legend patch shape:" ),
2024 QLineEdit::Normal, name, &ok );
2032 QStringList symbolTags = saveDlg.tags().split(
',' );
2042bool QgsStyleManagerDialog::editLegendPatchShape()
2045 if ( shapeName.isEmpty() )
2054 dlg.setWindowTitle( shapeName );
2058 shape = dlg.shape();
2066bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2073 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2075 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2077 if ( !dialog.exec() )
2080 symbol.reset( dialog.symbol() );
2085 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2086 saveDlg.setDefaultTags( defaultTag );
2087 if ( !saveDlg.exec() )
2089 QString name = saveDlg.name();
2092 bool nameInvalid =
true;
2093 while ( nameInvalid )
2096 if ( name.isEmpty() )
2098 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2099 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2103 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2104 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2106 QMessageBox::Yes | QMessageBox::No );
2107 if ( res == QMessageBox::Yes )
2110 nameInvalid =
false;
2116 nameInvalid =
false;
2121 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2122 tr(
"Please enter a name for the new 3D symbol:" ),
2123 QLineEdit::Normal, name, &ok );
2131 QStringList symbolTags = saveDlg.tags().split(
',' );
2136 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2142bool QgsStyleManagerDialog::editSymbol3D()
2145 if ( symbolName.isEmpty() )
2148 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2154 dlg.setWindowTitle( symbolName );
2158 symbol.reset( dlg.symbol() );
2163 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2168void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2171 if ( initialFolder.isEmpty() )
2172 initialFolder = QDir::homePath();
2174 QString databasePath = createNew
2175 ? QFileDialog::getSaveFileName(
2177 tr(
"Create Style Database" ),
2179 tr(
"Style databases" ) +
" (*.db)" )
2180 : QFileDialog::getOpenFileName(
2182 tr(
"Add Style Database" ),
2184 tr(
"Style databases" ) +
" (*.db *.xml)" );
2188 if ( ! databasePath.isEmpty() )
2195 if ( QFile::exists( databasePath ) )
2197 QFile::remove( databasePath );
2202 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2214 const QList< ItemDetails > items = selectedItems();
2216 if ( allTypesSelected() )
2218 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2219 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2228 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2229 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2236 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2237 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2244 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2245 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2252 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2253 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2260 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2261 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2268 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2269 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2278 for (
const ItemDetails &details : items )
2280 if ( details.name.isEmpty() )
2305 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2306 QDir::home().absolutePath(),
2307 QFileDialog::DontResolveSymlinks );
2313 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2314 QDir::home().absolutePath(),
2315 QFileDialog::DontResolveSymlinks );
2322 if ( dir.isEmpty() )
2325 const QList< ItemDetails > items = selectedItems();
2326 for (
const ItemDetails &details : items )
2331 QString path = dir +
'/' + details.name +
'.' + format;
2332 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2334 sym->exportImage( path, format, size );
2354 QFont font = item->font();
2355 font.setBold(
true );
2356 item->setFont( font );
2361 if ( mBlockGroupUpdates )
2364 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2367 const bool readOnly = isReadOnly();
2369 if ( mFavoritesGroupVisible )
2371 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2372 favoriteSymbols->setData(
"favorite" );
2373 favoriteSymbols->setEditable(
false );
2375 model->appendRow( favoriteSymbols );
2378 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2379 allSymbols->setData(
"all" );
2380 allSymbols->setEditable(
false );
2382 model->appendRow( allSymbols );
2384 QStandardItem *taggroup =
new QStandardItem( QString() );
2385 taggroup->setData(
"tags" );
2386 taggroup->setEditable(
false );
2387 QStringList tags = mStyle->
tags();
2389 for (
const QString &tag : std::as_const( tags ) )
2391 QStandardItem *item =
new QStandardItem( tag );
2392 item->setData( mStyle->
tagId( tag ) );
2393 item->setData( tag, GroupModelRoles::TagName );
2394 item->setEditable( !readOnly );
2395 taggroup->appendRow( item );
2397 taggroup->setText( tr(
"Tags" ) );
2399 model->appendRow( taggroup );
2401 if ( mSmartGroupVisible )
2403 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2404 smart->setData(
"smartgroups" );
2405 smart->setEditable(
false );
2408 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2409 while ( i != sgMap.constEnd() )
2411 QStandardItem *item =
new QStandardItem( i.value() );
2412 item->setData( i.key() );
2413 item->setEditable( !readOnly );
2414 smart->appendRow( item );
2417 model->appendRow( smart );
2421 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2422 for (
int i = 0; i < rows; i++ )
2424 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2430 const QString category = index.data( Qt::UserRole + 1 ).toString();
2431 sPreviousTag = category;
2433 const bool readOnly = isReadOnly();
2435 if ( mGroupingMode && mModel )
2437 mModel->setTagId( -1 );
2438 mModel->setSmartGroupId( -1 );
2439 mModel->setFavoritesOnly(
false );
2440 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2442 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2445 if ( category == QLatin1String(
"tags" ) )
2447 actnAddTag->setEnabled( !readOnly );
2448 actnAddSmartgroup->setEnabled(
false );
2450 else if ( category == QLatin1String(
"smartgroups" ) )
2452 actnAddTag->setEnabled(
false );
2453 actnAddSmartgroup->setEnabled( !readOnly );
2458 mModel->setTagId( -1 );
2459 mModel->setSmartGroupId( -1 );
2460 mModel->setFavoritesOnly(
false );
2463 else if ( category == QLatin1String(
"favorite" ) )
2466 mModel->setTagId( -1 );
2467 mModel->setSmartGroupId( -1 );
2468 mModel->setFavoritesOnly(
true );
2470 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2472 actnRemoveGroup->setEnabled( !readOnly );
2473 btnManageGroups->setEnabled( !readOnly );
2474 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2477 mModel->setTagId( -1 );
2478 mModel->setSmartGroupId( groupId );
2479 mModel->setFavoritesOnly(
false );
2485 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2488 mModel->setTagId( tagId );
2489 mModel->setSmartGroupId( -1 );
2490 mModel->setFavoritesOnly(
false );
2494 actnEditSmartGroup->setVisible(
false );
2495 actnAddTag->setVisible(
false );
2496 actnAddSmartgroup->setVisible(
false );
2497 actnRemoveGroup->setVisible(
false );
2498 actnTagSymbols->setVisible(
false );
2499 actnFinishTagging->setVisible(
false );
2501 if ( index.parent().isValid() )
2503 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2505 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2507 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2509 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2510 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2511 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2513 actnRemoveGroup->setVisible( !readOnly );
2515 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2517 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2519 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2521 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2530 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2532 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2534 index = groupTree->model()->index( i, 0 );
2535 QString data = index.data( Qt::UserRole + 1 ).toString();
2536 if ( data == QLatin1String(
"tags" ) )
2545 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2546 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2547 if ( !ok || itemName.isEmpty() )
2550 int check = mStyle->
tagId( itemName );
2553 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2559 mBlockGroupUpdates++;
2560 id = mStyle->
addTag( itemName );
2561 mBlockGroupUpdates--;
2565 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2569 QStandardItem *parentItem = model->itemFromIndex( index );
2570 QStandardItem *childItem =
new QStandardItem( itemName );
2571 childItem->setData(
id );
2572 childItem->setData( itemName, GroupModelRoles::TagName );
2573 parentItem->appendRow( childItem );
2583 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2585 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2587 index = groupTree->model()->index( i, 0 );
2588 QString data = index.data( Qt::UserRole + 1 ).toString();
2589 if ( data == QLatin1String(
"smartgroups" ) )
2598 if ( dlg.exec() == QDialog::Rejected )
2603 mBlockGroupUpdates++;
2605 mBlockGroupUpdates--;
2611 QStandardItem *parentItem = model->itemFromIndex( index );
2612 QStandardItem *childItem =
new QStandardItem( itemName );
2613 childItem->setData(
id );
2614 parentItem->appendRow( childItem );
2624 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2625 QModelIndex index = groupTree->currentIndex();
2628 QString data = index.data( Qt::UserRole + 1 ).toString();
2629 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2632 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2633 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2634 "Kindly select a group or smart group you might want to delete." ) );
2639 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2643 mBlockGroupUpdates++;
2645 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2654 mBlockGroupUpdates--;
2655 parentItem->removeRow( index.row() );
2663 QgsDebugMsgLevel( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2664 int id = item->data( Qt::UserRole + 1 ).toInt();
2665 QString name = item->text();
2666 mBlockGroupUpdates++;
2667 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2675 mBlockGroupUpdates--;
2683 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2685 if ( mGroupingMode )
2687 mGroupingMode =
false;
2688 mModel->setCheckable(
false );
2689 actnTagSymbols->setVisible(
true );
2690 actnFinishTagging->setVisible(
false );
2698 connect( treeModel, &QStandardItemModel::itemChanged,
2702 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2703 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2707 bool validGroup =
false;
2709 QModelIndex present = groupTree->currentIndex();
2710 while ( present.parent().isValid() )
2712 if ( present.parent().data() ==
"Tags" )
2717 present = present.parent();
2722 mGroupingMode =
true;
2724 actnTagSymbols->setVisible(
false );
2725 actnFinishTagging->setVisible(
true );
2727 disconnect( treeModel, &QStandardItemModel::itemChanged,
2733 btnManageGroups->setEnabled(
true );
2735 mModel->setCheckable(
true );
2738 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2739 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2753 mModel->setFilterString( qword );
2758 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2763 Q_UNUSED( selected )
2764 Q_UNUSED( deselected )
2765 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2766 const bool readOnly = isReadOnly();
2767 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2768 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2769 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2770 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2771 actnDetag->setDisabled( nothingSelected || readOnly );
2772 actnExportAsPNG->setDisabled( nothingSelected );
2773 actnExportAsSVG->setDisabled( nothingSelected );
2774 if ( mActionCopyToDefault )
2775 mActionCopyToDefault->setDisabled( nothingSelected );
2776 mCopyToDefaultButton->setDisabled( nothingSelected );
2777 actnEditItem->setDisabled( nothingSelected || readOnly );
2782 const bool readOnly = isReadOnly();
2783 groupTree->setEnabled( enable );
2784 btnAddTag->setEnabled( enable && !readOnly );
2785 btnAddSmartgroup->setEnabled( enable && !readOnly );
2786 actnAddTag->setEnabled( enable && !readOnly );
2787 actnAddSmartgroup->setEnabled( enable && !readOnly );
2788 actnRemoveGroup->setEnabled( enable && !readOnly );
2789 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2790 searchBox->setEnabled( enable );
2795 const bool readOnly = isReadOnly();
2796 actnRemoveGroup->setEnabled( enable && !readOnly );
2797 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2802 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2803 for (
int i = 0; i < treeModel->rowCount(); i++ )
2805 treeModel->item( i )->setEnabled( enable );
2807 if ( treeModel->item( i )->data() ==
"smartgroups" )
2809 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2811 treeModel->item( i )->child( j )->setEnabled( enable );
2818 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2820 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2822 w->setEnabled( enable );
2826 actnRemoveItem->setEnabled( enable );
2827 actnEditItem->setEnabled( enable );
2828 mActionCopyItem->setEnabled( enable );
2829 mActionPasteItem->setEnabled( enable );
2834 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2836 QModelIndex index = groupTree->indexAt( point );
2837 if ( index.isValid() && !mGroupingMode )
2838 mGroupTreeContextMenu->popup( globalPos );
2843 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2844 ? listItems->viewport()->mapToGlobal( point )
2845 : mSymbolTreeView->viewport()->mapToGlobal( point );
2848 mGroupListMenu->clear();
2850 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2852 if ( !isReadOnly() )
2854 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
QgsStyleModel::TagRole ).toStringList() : QStringList();
2855 QAction *a =
nullptr;
2856 QStringList tags = mStyle->
tags();
2858 for (
const QString &tag : std::as_const( tags ) )
2860 a =
new QAction( tag, mGroupListMenu );
2862 if ( indices.count() == 1 )
2864 a->setCheckable(
true );
2865 a->setChecked( currentTags.contains( tag ) );
2869 mGroupListMenu->addAction( a );
2872 if ( tags.count() > 0 )
2874 mGroupListMenu->addSeparator();
2876 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2879 mGroupListMenu->addAction( a );
2882 const QList< ItemDetails > items = selectedItems();
2885 bool enablePaste =
false;
2893 mActionPasteItem->setEnabled( enablePaste );
2895 mGroupMenu->popup( globalPos );
2903 const QList< ItemDetails > items = selectedItems();
2904 for (
const ItemDetails &details : items )
2906 mStyle->
addFavorite( details.entityType, details.name );
2915 const QList< ItemDetails > items = selectedItems();
2916 for (
const ItemDetails &details : items )
2924 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2927 const QList< ItemDetails > items = selectedItems();
2937 tag = mStyle->
tag(
id );
2941 tag = selectedItem->data().toString();
2944 for (
const ItemDetails &details : items )
2946 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2956 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2960 const QList< ItemDetails > items = selectedItems();
2961 for (
const ItemDetails &details : items )
2963 mStyle->
detagSymbol( details.entityType, details.name );
2973 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2976 QModelIndex present = groupTree->currentIndex();
2977 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2980 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2981 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2984 QStandardItem *item = treeModel->itemFromIndex( present );
2992 if ( dlg.exec() == QDialog::Rejected )
2995 mBlockGroupUpdates++;
2998 mBlockGroupUpdates--;
3001 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
3005 item->setData(
id );
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
SymbolType
Attribute editing capabilities which may be supported by vector data providers.
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
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
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.
Contains settings for how a map layer will be labeled.
Qgis::GeometryType layerType
Geometry type of layers associated with these settings.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
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.
List model representing the style databases associated with a QgsProject.
void setShowDefaultStyle(bool show)
Sets whether the default style should also be included in the model.
QModelIndex indexFromStyle(QgsStyle *style) const
Returns the model index corresponding to a style.
QgsStyle * styleFromIndex(const QModelIndex &index) const
Returns the style at the corresponding index.
void addStyleDatabasePath(const QString &path)
Adds a style database path to the project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
Stores properties relating to a screen.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
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 bool removeSymbol()
void onClose()
Closes the dialog.
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed.
static const QgsSettingsEntryString * settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
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.
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.
void showHelp()
Opens the associated help.
void detagSelectedSymbols()
Remove all tags from selected symbols.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
bool addSymbol(int symbolType=-1)
add a new symbol to style
Q_DECL_DEPRECATED void populateTypes()
Populate combo box with known style items (symbols, color ramps).
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.
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), bool readOnly=false)
Constructor for QgsStyleManagerDialog, with the specified parent widget and window flags.
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.
Q_DECL_DEPRECATED void populateSymbols(const QStringList &symbolNames, bool checkable=false)
Populates the list view with symbols of the current type with the given names.
void populateGroups()
populate the groups
Q_DECL_DEPRECATED bool removeColorRamp()
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 ...
Q_DECL_DEPRECATED void regrouped(QStandardItem *)
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item)
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.
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &)
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()
Q_DECL_DEPRECATED void populateColorRamps(const QStringList &colorRamps, bool checkable=false)
Populates the list view with color ramps of the current type with the given names.
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.
void aboutToBeDestroyed()
Emitted just before the style object is destroyed.
bool createDatabase(const QString &filename)
Creates an on-disk 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 isReadOnly() const
Returns true if the style is considered a read-only library.
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 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.
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.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QMap< int, QString > QgsSymbolGroupMap