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 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
713 QStringList additionalTags;
714 additionalTags.reserve( parts.count() );
715 for (
const QString &tag : parts )
716 additionalTags << tag.trimmed();
718 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
719 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
720 cursorOverride.reset();
723 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
728void QgsStyleManagerDialog::copyItem()
730 const QList< ItemDetails > items = selectedItems();
734 ItemDetails details = items.at( 0 );
735 switch ( details.entityType )
739 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
749 QApplication::clipboard()->setMimeData( format.toMimeData() );
756 QApplication::clipboard()->setMimeData( format.toMimeData() );
770void QgsStyleManagerDialog::pasteItem()
772 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
777 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
778 saveDlg.setDefaultTags( defaultTag );
779 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
782 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
784 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
785 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
786 .arg( saveDlg.name() ),
787 QMessageBox::Yes | QMessageBox::No );
788 if ( res != QMessageBox::Yes )
795 QStringList symbolTags = saveDlg.tags().split(
',' );
797 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
799 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
808 saveDlg.setDefaultTags( defaultTag );
809 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
810 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
815 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
816 tr(
"A format with the name '%1' already exists. Overwrite?" )
817 .arg( saveDlg.name() ),
818 QMessageBox::Yes | QMessageBox::No );
819 if ( res != QMessageBox::Yes )
826 QStringList symbolTags = saveDlg.tags().split(
',' );
829 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
834void QgsStyleManagerDialog::setThumbnailSize(
int value )
839 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
842 listItems->setIconSize( QSize(
static_cast< int >( iconSize ),
static_cast< int >( iconSize * 0.9 ) ) );
843 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
846 mModel->addDesiredIconSize( listItems->iconSize() );
852int QgsStyleManagerDialog::selectedItemType()
854 QModelIndex index = listItems->selectionModel()->currentIndex();
855 if ( !index.isValid() )
873bool QgsStyleManagerDialog::allTypesSelected()
const
875 return tabItemType->currentIndex() == 0;
878bool QgsStyleManagerDialog::isReadOnly()
const
880 return mReadOnly || ( mStyle && mStyle->
isReadOnly() );
883QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
885 QList<QgsStyleManagerDialog::ItemDetails > res;
886 QModelIndexList indices = listItems->selectionModel()->selectedRows();
887 for (
const QModelIndex &index : indices )
889 if ( !index.isValid() )
896 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
903int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
904 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
907 bool overwriteAll =
true;
917 for (
auto &details : items )
919 QStringList symbolTags;
920 if ( !ignoreSourceTags )
922 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
925 bool addItemToFavorites =
false;
928 symbolTags << importTags;
929 addItemToFavorites = addToFavorites;
932 switch ( details.entityType )
936 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
940 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
941 bool overwriteThis =
false;
943 addItemToFavorites = favoriteSymbols.contains( details.name );
945 if ( hasDuplicateName && prompt )
947 cursorOverride.reset();
948 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
949 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
950 .arg( details.name ),
951 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
952 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
955 case QMessageBox::Cancel:
958 case QMessageBox::No:
961 case QMessageBox::Yes:
962 overwriteThis =
true;
965 case QMessageBox::YesToAll:
970 case QMessageBox::NoToAll:
972 overwriteAll =
false;
977 if ( !hasDuplicateName || overwriteAll || overwriteThis )
980 dst->
addSymbol( details.name, symbol.release() );
981 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
989 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
993 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
994 bool overwriteThis =
false;
996 addItemToFavorites = favoriteColorramps.contains( details.name );
998 if ( hasDuplicateName && prompt )
1000 cursorOverride.reset();
1001 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1002 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
1003 .arg( details.name ),
1004 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1005 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1008 case QMessageBox::Cancel:
1011 case QMessageBox::No:
1014 case QMessageBox::Yes:
1015 overwriteThis =
true;
1018 case QMessageBox::YesToAll:
1020 overwriteAll =
true;
1023 case QMessageBox::NoToAll:
1025 overwriteAll =
false;
1030 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1034 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1044 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1045 bool overwriteThis =
false;
1047 addItemToFavorites = favoriteTextFormats.contains( details.name );
1049 if ( hasDuplicateName && prompt )
1051 cursorOverride.reset();
1052 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1053 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
1054 .arg( details.name ),
1055 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1056 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1059 case QMessageBox::Cancel:
1062 case QMessageBox::No:
1065 case QMessageBox::Yes:
1066 overwriteThis =
true;
1069 case QMessageBox::YesToAll:
1071 overwriteAll =
true;
1074 case QMessageBox::NoToAll:
1076 overwriteAll =
false;
1081 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1084 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1095 bool overwriteThis =
false;
1097 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1099 if ( hasDuplicateName && prompt )
1101 cursorOverride.reset();
1102 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1103 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1104 .arg( details.name ),
1105 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1106 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1109 case QMessageBox::Cancel:
1112 case QMessageBox::No:
1115 case QMessageBox::Yes:
1116 overwriteThis =
true;
1119 case QMessageBox::YesToAll:
1121 overwriteAll =
true;
1124 case QMessageBox::NoToAll:
1126 overwriteAll =
false;
1131 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1134 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1145 bool overwriteThis =
false;
1147 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1149 if ( hasDuplicateName && prompt )
1151 cursorOverride.reset();
1152 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1153 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1154 .arg( details.name ),
1155 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1156 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1159 case QMessageBox::Cancel:
1162 case QMessageBox::No:
1165 case QMessageBox::Yes:
1166 overwriteThis =
true;
1169 case QMessageBox::YesToAll:
1171 overwriteAll =
true;
1174 case QMessageBox::NoToAll:
1176 overwriteAll =
false;
1181 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1192 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1196 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1197 bool overwriteThis =
false;
1199 addItemToFavorites = favorite3dSymbols.contains( details.name );
1201 if ( hasDuplicateName && prompt )
1203 cursorOverride.reset();
1204 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1205 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1206 .arg( details.name ),
1207 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1208 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1211 case QMessageBox::Cancel:
1214 case QMessageBox::No:
1217 case QMessageBox::Yes:
1218 overwriteThis =
true;
1221 case QMessageBox::YesToAll:
1223 overwriteAll =
true;
1226 case QMessageBox::NoToAll:
1228 overwriteAll =
false;
1233 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1236 dst->
addSymbol3D( details.name, symbol.release() );
1237 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1252bool QgsStyleManagerDialog::addTextFormat()
1256 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1257 if ( !formatDlg.exec() )
1259 format = formatDlg.format();
1262 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1263 saveDlg.setDefaultTags( defaultTag );
1264 if ( !saveDlg.exec() )
1266 QString name = saveDlg.name();
1269 bool nameInvalid =
true;
1270 while ( nameInvalid )
1273 if ( name.isEmpty() )
1275 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1276 tr(
"Cannot save text format without name. Enter a name." ) );
1280 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1281 tr(
"Text format with name '%1' already exists. Overwrite?" )
1283 QMessageBox::Yes | QMessageBox::No );
1284 if ( res == QMessageBox::Yes )
1287 nameInvalid =
false;
1293 nameInvalid =
false;
1298 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1299 tr(
"Please enter a name for new text format:" ),
1300 QLineEdit::Normal, name, &ok );
1308 QStringList symbolTags = saveDlg.tags().split(
',' );
1312 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1320 groupChanged( groupTree->selectionModel()->currentIndex() );
1333 switch ( tabItemType->currentIndex() )
1358 QModelIndex index = listItems->selectionModel()->currentIndex();
1359 if ( !index.isValid() )
1362 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1367 bool changed =
false;
1378 changed = addTextFormat();
1397 Q_ASSERT(
false &&
"not implemented" );
1410 QString name = tr(
"new symbol" );
1411 QString dialogTitle;
1416 name = tr(
"new marker" );
1417 dialogTitle = tr(
"New Marker Symbol" );
1421 name = tr(
"new line" );
1422 dialogTitle = tr(
"New Line Symbol" );
1426 name = tr(
"new fill symbol" );
1427 dialogTitle = tr(
"New Fill Symbol" );
1430 Q_ASSERT(
false &&
"unknown symbol type" );
1440 dlg.setWindowTitle( dialogTitle );
1441 if ( dlg.exec() == 0 )
1448 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1450 if ( !saveDlg.exec() )
1456 name = saveDlg.
name();
1459 bool nameInvalid =
true;
1460 while ( nameInvalid )
1463 if ( name.isEmpty() )
1465 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1466 tr(
"Cannot save symbol without name. Enter a name." ) );
1468 else if ( mStyle->
symbolNames().contains( name ) )
1470 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1471 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1473 QMessageBox::Yes | QMessageBox::No );
1474 if ( res == QMessageBox::Yes )
1477 nameInvalid =
false;
1483 nameInvalid =
false;
1488 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1489 tr(
"Please enter a name for new symbol:" ),
1490 QLineEdit::Normal, name, &ok );
1499 QStringList symbolTags = saveDlg.
tags().split(
',' );
1512 QString rampType = type;
1514 if ( rampType.isEmpty() )
1519 QStringList rampTypeNames;
1520 rampTypeNames.reserve( rampTypes.size() );
1521 for (
const QPair< QString, QString > &type : rampTypes )
1522 rampTypeNames << type.second;
1523 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1524 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1525 if ( !ok || selectedRampTypeName.isEmpty() )
1528 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1531 QString name = tr(
"new ramp" );
1533 std::unique_ptr< QgsColorRamp > ramp;
1537 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1543 name = tr(
"new gradient ramp" );
1548 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1554 name = tr(
"new random ramp" );
1559 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1570 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1576 name = tr(
"new preset ramp" );
1581 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1601 QgsDebugError( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1606 if ( !saveDlg.exec() )
1611 name = saveDlg.
name();
1614 bool nameInvalid =
true;
1615 while ( nameInvalid )
1618 if ( name.isEmpty() )
1620 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1621 tr(
"Cannot save color ramp without name. Enter a name." ) );
1625 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1626 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1628 QMessageBox::Yes | QMessageBox::No );
1629 if ( res == QMessageBox::Yes )
1631 nameInvalid =
false;
1637 nameInvalid =
false;
1642 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1643 tr(
"Please enter a name for new color ramp:" ),
1644 QLineEdit::Normal, name, &ok );
1652 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1664 mFavoritesGroupVisible = show;
1670 mSmartGroupVisible = show;
1682 setWindowState( windowState() & ~Qt::WindowMinimized );
1690 if ( !rampName.isEmpty() )
1702 if ( selectedItemType() < 3 )
1706 else if ( selectedItemType() == 3 )
1710 else if ( selectedItemType() == 4 )
1714 else if ( selectedItemType() == 5 )
1716 editLabelSettings();
1718 else if ( selectedItemType() == 6 )
1720 editLegendPatchShape();
1722 else if ( selectedItemType() == 7 )
1728 Q_ASSERT(
false &&
"not implemented" );
1735 if ( symbolName.isEmpty() )
1738 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1742 dlg.setWindowTitle( symbolName );
1744 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1750 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1758 if ( name.isEmpty() )
1761 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1767 dlg.setWindowTitle( name );
1769 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1781 dlg.setWindowTitle( name );
1783 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1795 dlg.setWindowTitle( name );
1797 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1809 dlg.setWindowTitle( name );
1811 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1823 dlg.setWindowTitle( name );
1825 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1842 Q_ASSERT(
false &&
"invalid ramp type" );
1850bool QgsStyleManagerDialog::editTextFormat()
1853 if ( formatName.isEmpty() )
1860 dlg.setWindowTitle( formatName );
1862 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1876 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1877 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1879 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1881 if ( !settingsDlg.exec() )
1884 settings = settingsDlg.settings();
1888 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1889 saveDlg.setDefaultTags( defaultTag );
1890 if ( !saveDlg.exec() )
1892 QString name = saveDlg.name();
1895 bool nameInvalid =
true;
1896 while ( nameInvalid )
1899 if ( name.isEmpty() )
1901 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1902 tr(
"Cannot save label settings without a name. Enter a name." ) );
1906 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1907 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1909 QMessageBox::Yes | QMessageBox::No );
1910 if ( res == QMessageBox::Yes )
1913 nameInvalid =
false;
1919 nameInvalid =
false;
1924 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1925 tr(
"Please enter a name for the new label settings:" ),
1926 QLineEdit::Normal, name, &ok );
1934 QStringList symbolTags = saveDlg.tags().split(
',' );
1944bool QgsStyleManagerDialog::editLabelSettings()
1947 if ( formatName.isEmpty() )
1954 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1955 dlg.setWindowTitle( formatName );
1959 settings = dlg.settings();
1972 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1974 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1976 if ( !dialog.exec() )
1979 shape = dialog.shape();
1982 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1983 saveDlg.setDefaultTags( defaultTag );
1984 if ( !saveDlg.exec() )
1986 QString name = saveDlg.name();
1989 bool nameInvalid =
true;
1990 while ( nameInvalid )
1993 if ( name.isEmpty() )
1995 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1996 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
2000 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
2001 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
2003 QMessageBox::Yes | QMessageBox::No );
2004 if ( res == QMessageBox::Yes )
2007 nameInvalid =
false;
2013 nameInvalid =
false;
2018 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
2019 tr(
"Please enter a name for the new legend patch shape:" ),
2020 QLineEdit::Normal, name, &ok );
2028 QStringList symbolTags = saveDlg.tags().split(
',' );
2038bool QgsStyleManagerDialog::editLegendPatchShape()
2041 if ( shapeName.isEmpty() )
2050 dlg.setWindowTitle( shapeName );
2054 shape = dlg.shape();
2062bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2069 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2071 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2073 if ( !dialog.exec() )
2076 symbol.reset( dialog.symbol() );
2081 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2082 saveDlg.setDefaultTags( defaultTag );
2083 if ( !saveDlg.exec() )
2085 QString name = saveDlg.name();
2088 bool nameInvalid =
true;
2089 while ( nameInvalid )
2092 if ( name.isEmpty() )
2094 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2095 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2099 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2100 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2102 QMessageBox::Yes | QMessageBox::No );
2103 if ( res == QMessageBox::Yes )
2106 nameInvalid =
false;
2112 nameInvalid =
false;
2117 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2118 tr(
"Please enter a name for the new 3D symbol:" ),
2119 QLineEdit::Normal, name, &ok );
2127 QStringList symbolTags = saveDlg.tags().split(
',' );
2132 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2138bool QgsStyleManagerDialog::editSymbol3D()
2141 if ( symbolName.isEmpty() )
2144 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2150 dlg.setWindowTitle( symbolName );
2154 symbol.reset( dlg.symbol() );
2159 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2164void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2167 if ( initialFolder.isEmpty() )
2168 initialFolder = QDir::homePath();
2170 QString databasePath = createNew
2171 ? QFileDialog::getSaveFileName(
2173 tr(
"Create Style Database" ),
2175 tr(
"Style databases" ) +
" (*.db)" )
2176 : QFileDialog::getOpenFileName(
2178 tr(
"Add Style Database" ),
2180 tr(
"Style databases" ) +
" (*.db *.xml)" );
2184 if ( ! databasePath.isEmpty() )
2191 if ( QFile::exists( databasePath ) )
2193 QFile::remove( databasePath );
2198 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2210 const QList< ItemDetails > items = selectedItems();
2212 if ( allTypesSelected() )
2214 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2215 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2224 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2225 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2232 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2233 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2240 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2241 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2248 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2249 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2256 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2257 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2264 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2265 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2274 for (
const ItemDetails &details : items )
2276 if ( details.name.isEmpty() )
2301 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2302 QDir::home().absolutePath(),
2303 QFileDialog::DontResolveSymlinks );
2309 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2310 QDir::home().absolutePath(),
2311 QFileDialog::DontResolveSymlinks );
2318 if ( dir.isEmpty() )
2321 const QList< ItemDetails > items = selectedItems();
2322 for (
const ItemDetails &details : items )
2327 QString path = dir +
'/' + details.name +
'.' + format;
2328 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2330 sym->exportImage( path, format, size );
2350 QFont font = item->font();
2351 font.setBold(
true );
2352 item->setFont( font );
2357 if ( mBlockGroupUpdates )
2360 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2363 const bool readOnly = isReadOnly();
2365 if ( mFavoritesGroupVisible )
2367 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2368 favoriteSymbols->setData(
"favorite" );
2369 favoriteSymbols->setEditable(
false );
2371 model->appendRow( favoriteSymbols );
2374 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2375 allSymbols->setData(
"all" );
2376 allSymbols->setEditable(
false );
2378 model->appendRow( allSymbols );
2380 QStandardItem *taggroup =
new QStandardItem( QString() );
2381 taggroup->setData(
"tags" );
2382 taggroup->setEditable(
false );
2383 QStringList tags = mStyle->
tags();
2385 for (
const QString &tag : std::as_const( tags ) )
2387 QStandardItem *item =
new QStandardItem( tag );
2388 item->setData( mStyle->
tagId( tag ) );
2389 item->setData( tag, GroupModelRoles::TagName );
2390 item->setEditable( !readOnly );
2391 taggroup->appendRow( item );
2393 taggroup->setText( tr(
"Tags" ) );
2395 model->appendRow( taggroup );
2397 if ( mSmartGroupVisible )
2399 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2400 smart->setData(
"smartgroups" );
2401 smart->setEditable(
false );
2404 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2405 while ( i != sgMap.constEnd() )
2407 QStandardItem *item =
new QStandardItem( i.value() );
2408 item->setData( i.key() );
2409 item->setEditable( !readOnly );
2410 smart->appendRow( item );
2413 model->appendRow( smart );
2417 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2418 for (
int i = 0; i < rows; i++ )
2420 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2426 const QString category = index.data( Qt::UserRole + 1 ).toString();
2427 sPreviousTag = category;
2429 const bool readOnly = isReadOnly();
2431 if ( mGroupingMode && mModel )
2433 mModel->setTagId( -1 );
2434 mModel->setSmartGroupId( -1 );
2435 mModel->setFavoritesOnly(
false );
2436 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2438 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2441 if ( category == QLatin1String(
"tags" ) )
2443 actnAddTag->setEnabled( !readOnly );
2444 actnAddSmartgroup->setEnabled(
false );
2446 else if ( category == QLatin1String(
"smartgroups" ) )
2448 actnAddTag->setEnabled(
false );
2449 actnAddSmartgroup->setEnabled( !readOnly );
2454 mModel->setTagId( -1 );
2455 mModel->setSmartGroupId( -1 );
2456 mModel->setFavoritesOnly(
false );
2459 else if ( category == QLatin1String(
"favorite" ) )
2462 mModel->setTagId( -1 );
2463 mModel->setSmartGroupId( -1 );
2464 mModel->setFavoritesOnly(
true );
2466 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2468 actnRemoveGroup->setEnabled( !readOnly );
2469 btnManageGroups->setEnabled( !readOnly );
2470 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2473 mModel->setTagId( -1 );
2474 mModel->setSmartGroupId( groupId );
2475 mModel->setFavoritesOnly(
false );
2481 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2484 mModel->setTagId( tagId );
2485 mModel->setSmartGroupId( -1 );
2486 mModel->setFavoritesOnly(
false );
2490 actnEditSmartGroup->setVisible(
false );
2491 actnAddTag->setVisible(
false );
2492 actnAddSmartgroup->setVisible(
false );
2493 actnRemoveGroup->setVisible(
false );
2494 actnTagSymbols->setVisible(
false );
2495 actnFinishTagging->setVisible(
false );
2497 if ( index.parent().isValid() )
2499 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2501 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2503 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2505 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2506 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2507 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2509 actnRemoveGroup->setVisible( !readOnly );
2511 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2513 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2515 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2517 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2526 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2528 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2530 index = groupTree->model()->index( i, 0 );
2531 QString data = index.data( Qt::UserRole + 1 ).toString();
2532 if ( data == QLatin1String(
"tags" ) )
2541 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2542 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2543 if ( !ok || itemName.isEmpty() )
2546 int check = mStyle->
tagId( itemName );
2549 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2555 mBlockGroupUpdates++;
2556 id = mStyle->
addTag( itemName );
2557 mBlockGroupUpdates--;
2561 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2565 QStandardItem *parentItem = model->itemFromIndex( index );
2566 QStandardItem *childItem =
new QStandardItem( itemName );
2567 childItem->setData(
id );
2568 childItem->setData( itemName, GroupModelRoles::TagName );
2569 parentItem->appendRow( childItem );
2579 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2581 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2583 index = groupTree->model()->index( i, 0 );
2584 QString data = index.data( Qt::UserRole + 1 ).toString();
2585 if ( data == QLatin1String(
"smartgroups" ) )
2594 if ( dlg.exec() == QDialog::Rejected )
2599 mBlockGroupUpdates++;
2601 mBlockGroupUpdates--;
2607 QStandardItem *parentItem = model->itemFromIndex( index );
2608 QStandardItem *childItem =
new QStandardItem( itemName );
2609 childItem->setData(
id );
2610 parentItem->appendRow( childItem );
2620 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2621 QModelIndex index = groupTree->currentIndex();
2624 QString data = index.data( Qt::UserRole + 1 ).toString();
2625 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2628 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2629 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2630 "Kindly select a group or smart group you might want to delete." ) );
2635 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2639 mBlockGroupUpdates++;
2641 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2650 mBlockGroupUpdates--;
2651 parentItem->removeRow( index.row() );
2659 QgsDebugMsgLevel( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2660 int id = item->data( Qt::UserRole + 1 ).toInt();
2661 QString name = item->text();
2662 mBlockGroupUpdates++;
2663 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2671 mBlockGroupUpdates--;
2679 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2681 if ( mGroupingMode )
2683 mGroupingMode =
false;
2684 mModel->setCheckable(
false );
2685 actnTagSymbols->setVisible(
true );
2686 actnFinishTagging->setVisible(
false );
2694 connect( treeModel, &QStandardItemModel::itemChanged,
2698 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2699 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2703 bool validGroup =
false;
2705 QModelIndex present = groupTree->currentIndex();
2706 while ( present.parent().isValid() )
2708 if ( present.parent().data() ==
"Tags" )
2713 present = present.parent();
2718 mGroupingMode =
true;
2720 actnTagSymbols->setVisible(
false );
2721 actnFinishTagging->setVisible(
true );
2723 disconnect( treeModel, &QStandardItemModel::itemChanged,
2729 btnManageGroups->setEnabled(
true );
2731 mModel->setCheckable(
true );
2734 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2735 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2749 mModel->setFilterString( qword );
2754 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2759 Q_UNUSED( selected )
2760 Q_UNUSED( deselected )
2761 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2762 const bool readOnly = isReadOnly();
2763 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2764 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2765 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2766 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2767 actnDetag->setDisabled( nothingSelected || readOnly );
2768 actnExportAsPNG->setDisabled( nothingSelected );
2769 actnExportAsSVG->setDisabled( nothingSelected );
2770 if ( mActionCopyToDefault )
2771 mActionCopyToDefault->setDisabled( nothingSelected );
2772 mCopyToDefaultButton->setDisabled( nothingSelected );
2773 actnEditItem->setDisabled( nothingSelected || readOnly );
2778 const bool readOnly = isReadOnly();
2779 groupTree->setEnabled( enable );
2780 btnAddTag->setEnabled( enable && !readOnly );
2781 btnAddSmartgroup->setEnabled( enable && !readOnly );
2782 actnAddTag->setEnabled( enable && !readOnly );
2783 actnAddSmartgroup->setEnabled( enable && !readOnly );
2784 actnRemoveGroup->setEnabled( enable && !readOnly );
2785 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2786 searchBox->setEnabled( enable );
2791 const bool readOnly = isReadOnly();
2792 actnRemoveGroup->setEnabled( enable && !readOnly );
2793 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2798 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2799 for (
int i = 0; i < treeModel->rowCount(); i++ )
2801 treeModel->item( i )->setEnabled( enable );
2803 if ( treeModel->item( i )->data() ==
"smartgroups" )
2805 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2807 treeModel->item( i )->child( j )->setEnabled( enable );
2814 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2816 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2818 w->setEnabled( enable );
2822 actnRemoveItem->setEnabled( enable );
2823 actnEditItem->setEnabled( enable );
2824 mActionCopyItem->setEnabled( enable );
2825 mActionPasteItem->setEnabled( enable );
2830 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2832 QModelIndex index = groupTree->indexAt( point );
2833 if ( index.isValid() && !mGroupingMode )
2834 mGroupTreeContextMenu->popup( globalPos );
2839 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2840 ? listItems->viewport()->mapToGlobal( point )
2841 : mSymbolTreeView->viewport()->mapToGlobal( point );
2844 mGroupListMenu->clear();
2846 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2848 if ( !isReadOnly() )
2850 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
static_cast< int >(
QgsStyleModel::CustomRole::Tag ) ).toStringList() : QStringList();
2851 QAction *a =
nullptr;
2852 QStringList tags = mStyle->
tags();
2854 for (
const QString &tag : std::as_const( tags ) )
2856 a =
new QAction( tag, mGroupListMenu );
2858 if ( indices.count() == 1 )
2860 a->setCheckable(
true );
2861 a->setChecked( currentTags.contains( tag ) );
2865 mGroupListMenu->addAction( a );
2868 if ( tags.count() > 0 )
2870 mGroupListMenu->addSeparator();
2872 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2875 mGroupListMenu->addAction( a );
2878 const QList< ItemDetails > items = selectedItems();
2881 bool enablePaste =
false;
2889 mActionPasteItem->setEnabled( enablePaste );
2891 mGroupMenu->popup( globalPos );
2899 const QList< ItemDetails > items = selectedItems();
2900 for (
const ItemDetails &details : items )
2902 mStyle->
addFavorite( details.entityType, details.name );
2911 const QList< ItemDetails > items = selectedItems();
2912 for (
const ItemDetails &details : items )
2920 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2923 const QList< ItemDetails > items = selectedItems();
2933 tag = mStyle->
tag(
id );
2937 tag = selectedItem->data().toString();
2940 for (
const ItemDetails &details : items )
2942 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2952 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2956 const QList< ItemDetails > items = selectedItems();
2957 for (
const ItemDetails &details : items )
2959 mStyle->
detagSymbol( details.entityType, details.name );
2969 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2972 QModelIndex present = groupTree->currentIndex();
2973 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2976 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2977 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2980 QStandardItem *item = treeModel->itemFromIndex( present );
2988 if ( dlg.exec() == QDialog::Rejected )
2991 mBlockGroupUpdates++;
2994 mBlockGroupUpdates--;
2997 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
3001 item->setData(
id );
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
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.
A color ramp from the CPT City collection.
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 ...
@ SymbolType
Symbol type (for symbol or legend patch shape entities)
@ Type
Style entity type, see QgsStyle::StyleEntity.
@ Tag
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
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape.
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.
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.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
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.
A dialog that can be used to select and build 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