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();
370 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLabelSettings( Qgis::GeometryType::Point ); } );
371 mMenuBtnAddItemAll->addAction( item );
372 mMenuBtnAddItemLabelSettings->addAction( item );
374 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLabelSettings( Qgis::GeometryType::Line ); } );
375 mMenuBtnAddItemAll->addAction( item );
376 mMenuBtnAddItemLabelSettings->addAction( item );
378 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLabelSettings( Qgis::GeometryType::Polygon ); } );
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() );
505 mModel->setFilterString( searchBox->text() );
507 listItems->setModel( mModel );
508 mSymbolTreeView->setModel( mModel );
510 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
512 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
514 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
519 oldModel->deleteLater();
527 if ( mProjectStyleModel )
529 const QModelIndex styleIndex = mProjectStyleModel->
indexFromStyle( mStyle );
530 mBlockStyleDatabaseChanges++;
531 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
532 mBlockStyleDatabaseChanges--;
537 btnAddTag->setEnabled(
false );
538 btnAddSmartgroup->setEnabled(
false );
539 btnManageGroups->setEnabled(
false );
541 btnAddItem->setVisible(
false );
542 btnRemoveItem->setVisible(
false );
543 btnEditItem->setVisible(
false );
544 btnAddSmartgroup->setVisible(
false );
545 btnAddTag->setVisible(
false );
546 btnManageGroups->setVisible(
false );
548 delete mImportAction;
549 mImportAction =
nullptr;
551 mGroupTreeContextMenu->clear();
553 mGroupMenu->addAction( mActionCopyItem );
557 btnAddTag->setEnabled(
true );
558 btnAddSmartgroup->setEnabled(
true );
559 btnManageGroups->setEnabled(
true );
561 btnAddItem->setVisible(
true );
562 btnRemoveItem->setVisible(
true );
563 btnEditItem->setVisible(
true );
564 btnAddSmartgroup->setVisible(
true );
565 btnAddTag->setVisible(
true );
566 btnManageGroups->setVisible(
true );
568 if ( !mImportAction )
570 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
572 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
576 mGroupTreeContextMenu->clear();
577 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
578 mGroupTreeContextMenu->addAction( actnAddTag );
579 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
580 mGroupTreeContextMenu->addAction( actnRemoveGroup );
583 mGroupMenu->addAction( actnAddFavorite );
584 mGroupMenu->addAction( actnRemoveFavorite );
585 mGroupMenu->addSeparator()->setParent(
this );
586 mGroupMenu->addMenu( mGroupListMenu );
587 mGroupMenu->addAction( actnDetag );
588 mGroupMenu->addSeparator()->setParent(
this );
589 mGroupMenu->addAction( actnRemoveItem );
590 mGroupMenu->addAction( actnEditItem );
591 mGroupMenu->addAction( mActionCopyItem );
592 mGroupMenu->addAction( mActionPasteItem );
593 mGroupMenu->addSeparator()->setParent(
this );
596 if ( mActionCopyToDefault )
598 mGroupMenu->addAction( mActionCopyToDefault );
600 mGroupMenu->addAction( actnExportAsPNG );
601 mGroupMenu->addAction( actnExportAsSVG );
604 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
605 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
608 tabItemType_currentChanged( tabItemType->currentIndex() );
614void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
625 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
632void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
641 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
642 isColorRamp ? tr(
"Filter color ramps…" ) :
643 isTextFormat ? tr(
"Filter text symbols…" ) :
644 isLabelSettings ? tr(
"Filter label settings…" ) :
645 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
647 const bool readOnly = isReadOnly();
648 if ( !readOnly && isColorRamp )
650 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
652 else if ( !readOnly && isLegendPatchShape )
654 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
656 else if ( !readOnly && isSymbol3D )
658 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
660 else if ( !readOnly && isLabelSettings )
662 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
664 else if ( !readOnly && !isSymbol && !isColorRamp )
666 btnAddItem->setMenu(
nullptr );
668 else if ( !readOnly && tabItemType->currentIndex() == 0 )
670 btnAddItem->setMenu( mMenuBtnAddItemAll );
674 btnAddItem->setMenu(
nullptr );
677 actnExportAsPNG->setVisible( isSymbol );
678 actnExportAsSVG->setVisible( isSymbol );
683 mModel->setEntityFilterEnabled( !allTypesSelected() );
684 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
685 if ( isSymbol && !allTypesSelected() )
692void QgsStyleManagerDialog::copyItemsToDefault()
694 const QList< ItemDetails > items = selectedItems();
695 if ( !items.empty() )
699 if ( !mBaseName.isEmpty() )
700 options.append( mBaseName );
703 defaultTags.sort( Qt::CaseInsensitive );
704 options.append( defaultTags );
705 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
706 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
710#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
711 const QStringList parts = tags.split(
',', QString::SkipEmptyParts );
713 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
715 QStringList additionalTags;
716 additionalTags.reserve( parts.count() );
717 for (
const QString &tag : parts )
718 additionalTags << tag.trimmed();
720 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
721 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
722 cursorOverride.reset();
725 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
730void QgsStyleManagerDialog::copyItem()
732 const QList< ItemDetails > items = selectedItems();
736 ItemDetails details = items.at( 0 );
737 switch ( details.entityType )
741 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
751 QApplication::clipboard()->setMimeData( format.toMimeData() );
758 QApplication::clipboard()->setMimeData( format.toMimeData() );
772void QgsStyleManagerDialog::pasteItem()
774 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
779 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
780 saveDlg.setDefaultTags( defaultTag );
781 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
784 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
786 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
787 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
788 .arg( saveDlg.name() ),
789 QMessageBox::Yes | QMessageBox::No );
790 if ( res != QMessageBox::Yes )
797 QStringList symbolTags = saveDlg.tags().split(
',' );
799 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
801 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
810 saveDlg.setDefaultTags( defaultTag );
811 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
812 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
817 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
818 tr(
"A format with the name '%1' already exists. Overwrite?" )
819 .arg( saveDlg.name() ),
820 QMessageBox::Yes | QMessageBox::No );
821 if ( res != QMessageBox::Yes )
828 QStringList symbolTags = saveDlg.tags().split(
',' );
831 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
836void QgsStyleManagerDialog::setThumbnailSize(
int value )
841 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
844 listItems->setIconSize( QSize(
static_cast< int >(
iconSize ),
static_cast< int >(
iconSize * 0.9 ) ) );
845 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
848 mModel->addDesiredIconSize( listItems->iconSize() );
854int QgsStyleManagerDialog::selectedItemType()
856 QModelIndex index = listItems->selectionModel()->currentIndex();
857 if ( !index.isValid() )
875bool QgsStyleManagerDialog::allTypesSelected()
const
877 return tabItemType->currentIndex() == 0;
880bool QgsStyleManagerDialog::isReadOnly()
const
882 return mReadOnly || ( mStyle && mStyle->
isReadOnly() );
885QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
887 QList<QgsStyleManagerDialog::ItemDetails > res;
888 QModelIndexList indices = listItems->selectionModel()->selectedRows();
889 for (
const QModelIndex &index : indices )
891 if ( !index.isValid() )
898 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
905int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
906 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
909 bool overwriteAll =
true;
919 for (
auto &details : items )
921 QStringList symbolTags;
922 if ( !ignoreSourceTags )
924 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
927 bool addItemToFavorites =
false;
930 symbolTags << importTags;
931 addItemToFavorites = addToFavorites;
934 switch ( details.entityType )
938 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
942 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
943 bool overwriteThis =
false;
945 addItemToFavorites = favoriteSymbols.contains( details.name );
947 if ( hasDuplicateName && prompt )
949 cursorOverride.reset();
950 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
951 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
952 .arg( details.name ),
953 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
954 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
957 case QMessageBox::Cancel:
960 case QMessageBox::No:
963 case QMessageBox::Yes:
964 overwriteThis =
true;
967 case QMessageBox::YesToAll:
972 case QMessageBox::NoToAll:
974 overwriteAll =
false;
979 if ( !hasDuplicateName || overwriteAll || overwriteThis )
982 dst->
addSymbol( details.name, symbol.release() );
983 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
991 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
995 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
996 bool overwriteThis =
false;
998 addItemToFavorites = favoriteColorramps.contains( details.name );
1000 if ( hasDuplicateName && prompt )
1002 cursorOverride.reset();
1003 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1004 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
1005 .arg( details.name ),
1006 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1007 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1010 case QMessageBox::Cancel:
1013 case QMessageBox::No:
1016 case QMessageBox::Yes:
1017 overwriteThis =
true;
1020 case QMessageBox::YesToAll:
1022 overwriteAll =
true;
1025 case QMessageBox::NoToAll:
1027 overwriteAll =
false;
1032 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1036 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1046 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1047 bool overwriteThis =
false;
1049 addItemToFavorites = favoriteTextFormats.contains( details.name );
1051 if ( hasDuplicateName && prompt )
1053 cursorOverride.reset();
1054 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1055 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
1056 .arg( details.name ),
1057 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1058 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1061 case QMessageBox::Cancel:
1064 case QMessageBox::No:
1067 case QMessageBox::Yes:
1068 overwriteThis =
true;
1071 case QMessageBox::YesToAll:
1073 overwriteAll =
true;
1076 case QMessageBox::NoToAll:
1078 overwriteAll =
false;
1083 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1086 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1097 bool overwriteThis =
false;
1099 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1101 if ( hasDuplicateName && prompt )
1103 cursorOverride.reset();
1104 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1105 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1106 .arg( details.name ),
1107 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1108 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1111 case QMessageBox::Cancel:
1114 case QMessageBox::No:
1117 case QMessageBox::Yes:
1118 overwriteThis =
true;
1121 case QMessageBox::YesToAll:
1123 overwriteAll =
true;
1126 case QMessageBox::NoToAll:
1128 overwriteAll =
false;
1133 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1136 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1147 bool overwriteThis =
false;
1149 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1151 if ( hasDuplicateName && prompt )
1153 cursorOverride.reset();
1154 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1155 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1156 .arg( details.name ),
1157 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1158 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1161 case QMessageBox::Cancel:
1164 case QMessageBox::No:
1167 case QMessageBox::Yes:
1168 overwriteThis =
true;
1171 case QMessageBox::YesToAll:
1173 overwriteAll =
true;
1176 case QMessageBox::NoToAll:
1178 overwriteAll =
false;
1183 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1194 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1198 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1199 bool overwriteThis =
false;
1201 addItemToFavorites = favorite3dSymbols.contains( details.name );
1203 if ( hasDuplicateName && prompt )
1205 cursorOverride.reset();
1206 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1207 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1208 .arg( details.name ),
1209 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1210 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1213 case QMessageBox::Cancel:
1216 case QMessageBox::No:
1219 case QMessageBox::Yes:
1220 overwriteThis =
true;
1223 case QMessageBox::YesToAll:
1225 overwriteAll =
true;
1228 case QMessageBox::NoToAll:
1230 overwriteAll =
false;
1235 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1238 dst->
addSymbol3D( details.name, symbol.release() );
1239 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1254bool QgsStyleManagerDialog::addTextFormat()
1258 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1259 if ( !formatDlg.exec() )
1261 format = formatDlg.format();
1264 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1265 saveDlg.setDefaultTags( defaultTag );
1266 if ( !saveDlg.exec() )
1268 QString name = saveDlg.name();
1271 bool nameInvalid =
true;
1272 while ( nameInvalid )
1275 if ( name.isEmpty() )
1277 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1278 tr(
"Cannot save text format without name. Enter a name." ) );
1282 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1283 tr(
"Text format with name '%1' already exists. Overwrite?" )
1285 QMessageBox::Yes | QMessageBox::No );
1286 if ( res == QMessageBox::Yes )
1289 nameInvalid =
false;
1295 nameInvalid =
false;
1300 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1301 tr(
"Please enter a name for new text format:" ),
1302 QLineEdit::Normal, name, &ok );
1310 QStringList symbolTags = saveDlg.tags().split(
',' );
1314 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1322 groupChanged( groupTree->selectionModel()->currentIndex() );
1335 switch ( tabItemType->currentIndex() )
1360 QModelIndex index = listItems->selectionModel()->currentIndex();
1361 if ( !index.isValid() )
1364 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1369 bool changed =
false;
1380 changed = addTextFormat();
1399 Q_ASSERT(
false &&
"not implemented" );
1412 QString name = tr(
"new symbol" );
1413 QString dialogTitle;
1418 name = tr(
"new marker" );
1419 dialogTitle = tr(
"New Marker Symbol" );
1423 name = tr(
"new line" );
1424 dialogTitle = tr(
"New Line Symbol" );
1428 name = tr(
"new fill symbol" );
1429 dialogTitle = tr(
"New Fill Symbol" );
1432 Q_ASSERT(
false &&
"unknown symbol type" );
1442 dlg.setWindowTitle( dialogTitle );
1443 if ( dlg.exec() == 0 )
1450 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1452 if ( !saveDlg.exec() )
1458 name = saveDlg.
name();
1461 bool nameInvalid =
true;
1462 while ( nameInvalid )
1465 if ( name.isEmpty() )
1467 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1468 tr(
"Cannot save symbol without name. Enter a name." ) );
1470 else if ( mStyle->
symbolNames().contains( name ) )
1472 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1473 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1475 QMessageBox::Yes | QMessageBox::No );
1476 if ( res == QMessageBox::Yes )
1479 nameInvalid =
false;
1485 nameInvalid =
false;
1490 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1491 tr(
"Please enter a name for new symbol:" ),
1492 QLineEdit::Normal, name, &ok );
1501 QStringList symbolTags = saveDlg.
tags().split(
',' );
1514 QString rampType = type;
1516 if ( rampType.isEmpty() )
1521 QStringList rampTypeNames;
1522 rampTypeNames.reserve( rampTypes.size() );
1523 for (
const QPair< QString, QString > &type : rampTypes )
1524 rampTypeNames << type.second;
1525 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1526 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1527 if ( !ok || selectedRampTypeName.isEmpty() )
1530 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1533 QString name = tr(
"new ramp" );
1535 std::unique_ptr< QgsColorRamp > ramp;
1539 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1545 name = tr(
"new gradient ramp" );
1550 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1556 name = tr(
"new random ramp" );
1561 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1572 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1578 name = tr(
"new preset ramp" );
1583 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1603 QgsDebugMsg( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1608 if ( !saveDlg.exec() )
1613 name = saveDlg.
name();
1616 bool nameInvalid =
true;
1617 while ( nameInvalid )
1620 if ( name.isEmpty() )
1622 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1623 tr(
"Cannot save color ramp without name. Enter a name." ) );
1627 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1628 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1630 QMessageBox::Yes | QMessageBox::No );
1631 if ( res == QMessageBox::Yes )
1633 nameInvalid =
false;
1639 nameInvalid =
false;
1644 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1645 tr(
"Please enter a name for new color ramp:" ),
1646 QLineEdit::Normal, name, &ok );
1654 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1666 mFavoritesGroupVisible = show;
1672 mSmartGroupVisible = show;
1684 setWindowState( windowState() & ~Qt::WindowMinimized );
1692 if ( !rampName.isEmpty() )
1704 if ( selectedItemType() < 3 )
1708 else if ( selectedItemType() == 3 )
1712 else if ( selectedItemType() == 4 )
1716 else if ( selectedItemType() == 5 )
1718 editLabelSettings();
1720 else if ( selectedItemType() == 6 )
1722 editLegendPatchShape();
1724 else if ( selectedItemType() == 7 )
1730 Q_ASSERT(
false &&
"not implemented" );
1737 if ( symbolName.isEmpty() )
1740 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1744 dlg.setWindowTitle( symbolName );
1746 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1752 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1760 if ( name.isEmpty() )
1763 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1769 dlg.setWindowTitle( name );
1771 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1783 dlg.setWindowTitle( name );
1785 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1797 dlg.setWindowTitle( name );
1799 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1811 dlg.setWindowTitle( name );
1813 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1825 dlg.setWindowTitle( name );
1827 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1844 Q_ASSERT(
false &&
"invalid ramp type" );
1852bool QgsStyleManagerDialog::editTextFormat()
1855 if ( formatName.isEmpty() )
1862 dlg.setWindowTitle( formatName );
1864 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1878 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1879 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1881 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1883 if ( !settingsDlg.exec() )
1886 settings = settingsDlg.settings();
1890 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1891 saveDlg.setDefaultTags( defaultTag );
1892 if ( !saveDlg.exec() )
1894 QString name = saveDlg.name();
1897 bool nameInvalid =
true;
1898 while ( nameInvalid )
1901 if ( name.isEmpty() )
1903 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1904 tr(
"Cannot save label settings without a name. Enter a name." ) );
1908 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1909 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1911 QMessageBox::Yes | QMessageBox::No );
1912 if ( res == QMessageBox::Yes )
1915 nameInvalid =
false;
1921 nameInvalid =
false;
1926 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1927 tr(
"Please enter a name for the new label settings:" ),
1928 QLineEdit::Normal, name, &ok );
1936 QStringList symbolTags = saveDlg.tags().split(
',' );
1946bool QgsStyleManagerDialog::editLabelSettings()
1949 if ( formatName.isEmpty() )
1956 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1957 dlg.setWindowTitle( formatName );
1961 settings = dlg.settings();
1974 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1976 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1978 if ( !dialog.exec() )
1981 shape = dialog.shape();
1984 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1985 saveDlg.setDefaultTags( defaultTag );
1986 if ( !saveDlg.exec() )
1988 QString name = saveDlg.name();
1991 bool nameInvalid =
true;
1992 while ( nameInvalid )
1995 if ( name.isEmpty() )
1997 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1998 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
2002 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
2003 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
2005 QMessageBox::Yes | QMessageBox::No );
2006 if ( res == QMessageBox::Yes )
2009 nameInvalid =
false;
2015 nameInvalid =
false;
2020 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
2021 tr(
"Please enter a name for the new legend patch shape:" ),
2022 QLineEdit::Normal, name, &ok );
2030 QStringList symbolTags = saveDlg.tags().split(
',' );
2040bool QgsStyleManagerDialog::editLegendPatchShape()
2043 if ( shapeName.isEmpty() )
2052 dlg.setWindowTitle( shapeName );
2056 shape = dlg.shape();
2064bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2071 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2073 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2075 if ( !dialog.exec() )
2078 symbol.reset( dialog.symbol() );
2083 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
2084 saveDlg.setDefaultTags( defaultTag );
2085 if ( !saveDlg.exec() )
2087 QString name = saveDlg.name();
2090 bool nameInvalid =
true;
2091 while ( nameInvalid )
2094 if ( name.isEmpty() )
2096 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2097 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2101 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2102 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2104 QMessageBox::Yes | QMessageBox::No );
2105 if ( res == QMessageBox::Yes )
2108 nameInvalid =
false;
2114 nameInvalid =
false;
2119 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2120 tr(
"Please enter a name for the new 3D symbol:" ),
2121 QLineEdit::Normal, name, &ok );
2129 QStringList symbolTags = saveDlg.tags().split(
',' );
2134 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2140bool QgsStyleManagerDialog::editSymbol3D()
2143 if ( symbolName.isEmpty() )
2146 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2152 dlg.setWindowTitle( symbolName );
2156 symbol.reset( dlg.symbol() );
2161 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2166void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2169 if ( initialFolder.isEmpty() )
2170 initialFolder = QDir::homePath();
2172 QString databasePath = createNew
2173 ? QFileDialog::getSaveFileName(
2175 tr(
"Create Style Database" ),
2177 tr(
"Style databases" ) +
" (*.db)" )
2178 : QFileDialog::getOpenFileName(
2180 tr(
"Add Style Database" ),
2182 tr(
"Style databases" ) +
" (*.db *.xml)" );
2183 if ( ! databasePath.isEmpty() )
2190 if ( QFile::exists( databasePath ) )
2192 QFile::remove( databasePath );
2197 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2209 const QList< ItemDetails > items = selectedItems();
2211 if ( allTypesSelected() )
2213 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2214 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2223 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2224 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2231 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2232 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2239 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2240 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2247 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2248 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2255 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2256 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2263 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2264 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2273 for (
const ItemDetails &details : items )
2275 if ( details.name.isEmpty() )
2300 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2301 QDir::home().absolutePath(),
2302 QFileDialog::DontResolveSymlinks );
2308 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2309 QDir::home().absolutePath(),
2310 QFileDialog::DontResolveSymlinks );
2317 if ( dir.isEmpty() )
2320 const QList< ItemDetails > items = selectedItems();
2321 for (
const ItemDetails &details : items )
2326 QString path = dir +
'/' + details.name +
'.' + format;
2327 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2329 sym->exportImage( path, format, size );
2349 QFont font = item->font();
2350 font.setBold(
true );
2351 item->setFont( font );
2356 if ( mBlockGroupUpdates )
2359 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2362 const bool readOnly = isReadOnly();
2364 if ( mFavoritesGroupVisible )
2366 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2367 favoriteSymbols->setData(
"favorite" );
2368 favoriteSymbols->setEditable(
false );
2370 model->appendRow( favoriteSymbols );
2373 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2374 allSymbols->setData(
"all" );
2375 allSymbols->setEditable(
false );
2377 model->appendRow( allSymbols );
2379 QStandardItem *taggroup =
new QStandardItem( QString() );
2380 taggroup->setData(
"tags" );
2381 taggroup->setEditable(
false );
2382 QStringList tags = mStyle->
tags();
2384 for (
const QString &tag : std::as_const( tags ) )
2386 QStandardItem *item =
new QStandardItem( tag );
2387 item->setData( mStyle->
tagId( tag ) );
2389 item->setEditable( !readOnly );
2390 taggroup->appendRow( item );
2392 taggroup->setText( tr(
"Tags" ) );
2394 model->appendRow( taggroup );
2396 if ( mSmartGroupVisible )
2398 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2399 smart->setData(
"smartgroups" );
2400 smart->setEditable(
false );
2403 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2404 while ( i != sgMap.constEnd() )
2406 QStandardItem *item =
new QStandardItem( i.value() );
2407 item->setData( i.key() );
2408 item->setEditable( !readOnly );
2409 smart->appendRow( item );
2412 model->appendRow( smart );
2416 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2417 for (
int i = 0; i < rows; i++ )
2419 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2425 const QString category = index.data( Qt::UserRole + 1 ).toString();
2426 sPreviousTag = category;
2428 const bool readOnly = isReadOnly();
2430 if ( mGroupingMode && mModel )
2432 mModel->setTagId( -1 );
2433 mModel->setSmartGroupId( -1 );
2434 mModel->setFavoritesOnly(
false );
2435 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2437 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2440 if ( category == QLatin1String(
"tags" ) )
2442 actnAddTag->setEnabled( !readOnly );
2443 actnAddSmartgroup->setEnabled(
false );
2445 else if ( category == QLatin1String(
"smartgroups" ) )
2447 actnAddTag->setEnabled(
false );
2448 actnAddSmartgroup->setEnabled( !readOnly );
2453 mModel->setTagId( -1 );
2454 mModel->setSmartGroupId( -1 );
2455 mModel->setFavoritesOnly(
false );
2458 else if ( category == QLatin1String(
"favorite" ) )
2461 mModel->setTagId( -1 );
2462 mModel->setSmartGroupId( -1 );
2463 mModel->setFavoritesOnly(
true );
2465 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2467 actnRemoveGroup->setEnabled( !readOnly );
2468 btnManageGroups->setEnabled( !readOnly );
2469 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2472 mModel->setTagId( -1 );
2473 mModel->setSmartGroupId( groupId );
2474 mModel->setFavoritesOnly(
false );
2480 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2483 mModel->setTagId( tagId );
2484 mModel->setSmartGroupId( -1 );
2485 mModel->setFavoritesOnly(
false );
2489 actnEditSmartGroup->setVisible(
false );
2490 actnAddTag->setVisible(
false );
2491 actnAddSmartgroup->setVisible(
false );
2492 actnRemoveGroup->setVisible(
false );
2493 actnTagSymbols->setVisible(
false );
2494 actnFinishTagging->setVisible(
false );
2496 if ( index.parent().isValid() )
2498 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2500 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2502 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2504 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2505 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2506 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2508 actnRemoveGroup->setVisible( !readOnly );
2510 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2512 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2514 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2516 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2525 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2527 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2529 index = groupTree->model()->index( i, 0 );
2530 QString data = index.data( Qt::UserRole + 1 ).toString();
2531 if ( data == QLatin1String(
"tags" ) )
2540 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2541 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2542 if ( !ok || itemName.isEmpty() )
2545 int check = mStyle->
tagId( itemName );
2548 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2554 mBlockGroupUpdates++;
2555 id = mStyle->
addTag( itemName );
2556 mBlockGroupUpdates--;
2560 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2564 QStandardItem *parentItem = model->itemFromIndex( index );
2565 QStandardItem *childItem =
new QStandardItem( itemName );
2566 childItem->setData(
id );
2568 parentItem->appendRow( childItem );
2578 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2580 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2582 index = groupTree->model()->index( i, 0 );
2583 QString data = index.data( Qt::UserRole + 1 ).toString();
2584 if ( data == QLatin1String(
"smartgroups" ) )
2593 if ( dlg.exec() == QDialog::Rejected )
2598 mBlockGroupUpdates++;
2600 mBlockGroupUpdates--;
2606 QStandardItem *parentItem = model->itemFromIndex( index );
2607 QStandardItem *childItem =
new QStandardItem( itemName );
2608 childItem->setData(
id );
2609 parentItem->appendRow( childItem );
2619 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2620 QModelIndex index = groupTree->currentIndex();
2623 QString data = index.data( Qt::UserRole + 1 ).toString();
2624 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2627 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2628 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2629 "Kindly select a group or smart group you might want to delete." ) );
2634 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2638 mBlockGroupUpdates++;
2640 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2649 mBlockGroupUpdates--;
2650 parentItem->removeRow( index.row() );
2658 QgsDebugMsg( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ) );
2659 int id = item->data( Qt::UserRole + 1 ).toInt();
2660 QString name = item->text();
2661 mBlockGroupUpdates++;
2662 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2670 mBlockGroupUpdates--;
2678 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2680 if ( mGroupingMode )
2682 mGroupingMode =
false;
2683 mModel->setCheckable(
false );
2684 actnTagSymbols->setVisible(
true );
2685 actnFinishTagging->setVisible(
false );
2693 connect( treeModel, &QStandardItemModel::itemChanged,
2697 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2698 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2702 bool validGroup =
false;
2704 QModelIndex present = groupTree->currentIndex();
2705 while ( present.parent().isValid() )
2707 if ( present.parent().data() ==
"Tags" )
2712 present = present.parent();
2717 mGroupingMode =
true;
2719 actnTagSymbols->setVisible(
false );
2720 actnFinishTagging->setVisible(
true );
2722 disconnect( treeModel, &QStandardItemModel::itemChanged,
2728 btnManageGroups->setEnabled(
true );
2730 mModel->setCheckable(
true );
2733 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2734 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2748 mModel->setFilterString( qword );
2753 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2758 Q_UNUSED( selected )
2759 Q_UNUSED( deselected )
2760 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2761 const bool readOnly = isReadOnly();
2762 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2763 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2764 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2765 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2766 actnDetag->setDisabled( nothingSelected || readOnly );
2767 actnExportAsPNG->setDisabled( nothingSelected );
2768 actnExportAsSVG->setDisabled( nothingSelected );
2769 if ( mActionCopyToDefault )
2770 mActionCopyToDefault->setDisabled( nothingSelected );
2771 mCopyToDefaultButton->setDisabled( nothingSelected );
2772 actnEditItem->setDisabled( nothingSelected || readOnly );
2777 const bool readOnly = isReadOnly();
2778 groupTree->setEnabled( enable );
2779 btnAddTag->setEnabled( enable && !readOnly );
2780 btnAddSmartgroup->setEnabled( enable && !readOnly );
2781 actnAddTag->setEnabled( enable && !readOnly );
2782 actnAddSmartgroup->setEnabled( enable && !readOnly );
2783 actnRemoveGroup->setEnabled( enable && !readOnly );
2784 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2785 searchBox->setEnabled( enable );
2790 const bool readOnly = isReadOnly();
2791 actnRemoveGroup->setEnabled( enable && !readOnly );
2792 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2797 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2798 for (
int i = 0; i < treeModel->rowCount(); i++ )
2800 treeModel->item( i )->setEnabled( enable );
2802 if ( treeModel->item( i )->data() ==
"smartgroups" )
2804 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2806 treeModel->item( i )->child( j )->setEnabled( enable );
2813 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2815 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2817 w->setEnabled( enable );
2821 actnRemoveItem->setEnabled( enable );
2822 actnEditItem->setEnabled( enable );
2823 mActionCopyItem->setEnabled( enable );
2824 mActionPasteItem->setEnabled( enable );
2829 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2831 QModelIndex index = groupTree->indexAt( point );
2832 if ( index.isValid() && !mGroupingMode )
2833 mGroupTreeContextMenu->popup( globalPos );
2838 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2839 ? listItems->viewport()->mapToGlobal( point )
2840 : mSymbolTreeView->viewport()->mapToGlobal( point );
2843 mGroupListMenu->clear();
2845 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2847 if ( !isReadOnly() )
2849 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
QgsStyleModel::TagRole ).toStringList() : QStringList();
2850 QAction *a =
nullptr;
2851 QStringList tags = mStyle->
tags();
2853 for (
const QString &tag : std::as_const( tags ) )
2855 a =
new QAction( tag, mGroupListMenu );
2857 if ( indices.count() == 1 )
2859 a->setCheckable(
true );
2860 a->setChecked( currentTags.contains( tag ) );
2864 mGroupListMenu->addAction( a );
2867 if ( tags.count() > 0 )
2869 mGroupListMenu->addSeparator();
2871 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2874 mGroupListMenu->addAction( a );
2877 const QList< ItemDetails > items = selectedItems();
2880 bool enablePaste =
false;
2888 mActionPasteItem->setEnabled( enablePaste );
2890 mGroupMenu->popup( globalPos );
2898 const QList< ItemDetails > items = selectedItems();
2899 for (
const ItemDetails &details : items )
2901 mStyle->
addFavorite( details.entityType, details.name );
2910 const QList< ItemDetails > items = selectedItems();
2911 for (
const ItemDetails &details : items )
2919 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2922 const QList< ItemDetails > items = selectedItems();
2932 tag = mStyle->
tag(
id );
2936 tag = selectedItem->data().toString();
2939 for (
const ItemDetails &details : items )
2941 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2951 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2955 const QList< ItemDetails > items = selectedItems();
2956 for (
const ItemDetails &details : items )
2958 mStyle->
detagSymbol( details.entityType, details.name );
2968 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2971 QModelIndex present = groupTree->currentIndex();
2972 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2975 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2976 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2979 QStandardItem *item = treeModel->itemFromIndex( present );
2987 if ( dlg.exec() == QDialog::Rejected )
2990 mBlockGroupUpdates++;
2993 mBlockGroupUpdates--;
2996 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
3000 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.
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...
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
T value(const QString &dynamicKeyPart=QString()) const
Returns 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.
QMap< int, QString > QgsSymbolGroupMap