51#include <QInputDialog>
54#include <QStandardItemModel>
57#include <QDesktopServices>
69QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
71 , mStyle( sourceModel->style() )
72 , mReadOnly( readOnly )
77QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
80 , mReadOnly( readOnly )
84void QgsCheckableStyleModel::setCheckable(
bool checkable )
86 if ( checkable == mCheckable )
89 mCheckable = checkable;
90 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
93void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
95 if ( tag == mCheckTag )
99 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
102Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
104 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
105 if ( !mReadOnly && mCheckable && index.column() == 0 )
106 f |= Qt::ItemIsUserCheckable;
109 f &= ~Qt::ItemIsEditable;
114QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
121 QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
126 case Qt::CheckStateRole:
128 if ( !mCheckable || index.column() != 0 )
132 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
139 return QgsStyleProxyModel::data( index, role );
142bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
144 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) ||
145 ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
151 if ( role == Qt::CheckStateRole )
153 if ( !mCheckable || mCheckTag.isEmpty() )
156 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
159 if ( value.toInt() == Qt::Checked )
160 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
162 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
164 return QgsStyleProxyModel::setData( i, value, role );
174QString QgsStyleManagerDialog::sPreviousTag;
177 : QDialog( parent, flags )
178 , mReadOnly( readOnly )
181 setCurrentStyle( style );
182 mStyleDatabaseWidget->hide();
186 : QDialog( parent, flags )
192 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
196 connect( mComboBoxStyleDatabase, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ]()
198 if ( mBlockStyleDatabaseChanges )
201 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
205 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
false ); } );
206 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
true ); } );
209void QgsStyleManagerDialog::init()
213 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
217 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
218 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
220 connect( downloadButton, &QPushButton::clicked,
this, [ = ]
222 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://plugins.qgis.org/styles" ) ) );
226 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
227 mVerticalLayout->insertWidget( 0, mMessageBar );
230 setWindowModality( Qt::WindowModal );
235 mSplitter->setSizes( QList<int>() << 170 << 540 );
236 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
238 tabItemType->setDocumentMode(
true );
239 searchBox->setShowSearchIcon(
true );
240 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
244 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
246 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
250 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool )
253 if ( !btnAddItem->menu() )
260 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
262 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
265 mShareMenu =
new QMenu( tr(
"Share Menu" ),
this );
266 mExportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
268 mShareMenu->addAction( mExportAction );
270 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
272 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
273 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
274 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
275 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
277 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
278 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
279 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
280 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
281 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
283 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
286 mShareMenu->addSeparator();
287 mShareMenu->addAction( actnExportAsPNG );
288 mShareMenu->addAction( actnExportAsSVG );
293 btnShare->setMenu( mShareMenu );
295 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
297 mSymbolTreeView->setIconSize( QSize(
static_cast< int >( treeIconSize ),
static_cast< int >( treeIconSize ) ) );
299 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
300 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
301 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
303 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
304 groupTree->setModel( groupModel );
305 groupTree->setHeaderHidden(
true );
307 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
311 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
313 groupMenu->addAction( actnTagSymbols );
315 actnFinishTagging->setVisible(
false );
316 groupMenu->addAction( actnFinishTagging );
317 groupMenu->addAction( actnEditSmartGroup );
318 btnManageGroups->setMenu( groupMenu );
323 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
324 connect( groupTree, &QWidget::customContextMenuRequested,
328 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
329 connect( listItems, &QWidget::customContextMenuRequested,
331 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
332 connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
335 mMenuBtnAddItemAll =
new QMenu(
this );
336 mMenuBtnAddItemColorRamp =
new QMenu(
this );
337 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
338 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
339 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
343 mMenuBtnAddItemAll->addAction( item );
346 mMenuBtnAddItemAll->addAction( item );
349 mMenuBtnAddItemAll->addAction( item );
350 mMenuBtnAddItemAll->addSeparator();
353 for (
const QPair< QString, QString > &rampType : rampTypes )
355 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
356 connect( item, &QAction::triggered,
this, [ = ](
bool ) {
addColorRamp( rampType.first ); } );
357 mMenuBtnAddItemAll->addAction( item );
358 mMenuBtnAddItemColorRamp->addAction( item );
360 mMenuBtnAddItemAll->addSeparator();
362 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addTextFormat(); } );
363 mMenuBtnAddItemAll->addAction( item );
364 mMenuBtnAddItemAll->addSeparator();
367 mMenuBtnAddItemAll->addAction( item );
368 mMenuBtnAddItemLabelSettings->addAction( item );
371 mMenuBtnAddItemAll->addAction( item );
372 mMenuBtnAddItemLabelSettings->addAction( item );
375 mMenuBtnAddItemAll->addAction( item );
376 mMenuBtnAddItemLabelSettings->addAction( item );
378 mMenuBtnAddItemAll->addSeparator();
381 mMenuBtnAddItemAll->addAction( item );
382 mMenuBtnAddItemLegendPatchShape->addAction( item );
384 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
385 mMenuBtnAddItemAll->addAction( item );
386 mMenuBtnAddItemLegendPatchShape->addAction( item );
388 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
389 mMenuBtnAddItemAll->addAction( item );
390 mMenuBtnAddItemLegendPatchShape->addAction( item );
392 mMenuBtnAddItemAll->addSeparator();
394 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"point" ) ); } );
395 mMenuBtnAddItemAll->addAction( item );
396 mMenuBtnAddItemSymbol3D->addAction( item );
398 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
399 mMenuBtnAddItemAll->addAction( item );
400 mMenuBtnAddItemSymbol3D->addAction( item );
402 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
403 mMenuBtnAddItemAll->addAction( item );
404 mMenuBtnAddItemSymbol3D->addAction( item );
407 mGroupMenu =
new QMenu(
this );
408 mGroupListMenu =
new QMenu( mGroupMenu );
409 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
410 mGroupListMenu->setEnabled(
false );
417 mGroupTreeContextMenu =
new QMenu(
this );
419 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); } );
420 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); } );
423 tabItemType_currentChanged( 0 );
425 connect( mButtonIconView, &QToolButton::toggled,
this, [ = ](
bool active )
429 mSymbolViewStackedWidget->setCurrentIndex( 0 );
434 connect( mButtonListView, &QToolButton::toggled,
this, [ = ](
bool active )
439 mSymbolViewStackedWidget->setCurrentIndex( 1 );
443 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
444 if ( currentView == 0 )
445 mButtonIconView->setChecked(
true );
447 mButtonListView->setChecked(
true );
449 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
450 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this]
453 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
456 const int thumbnailSize = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), 0,
QgsSettings::Gui ).toInt();
457 mSliderIconSize->setValue( thumbnailSize );
458 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
459 setThumbnailSize( thumbnailSize );
462void QgsStyleManagerDialog::setCurrentStyle(
QgsStyle *style )
464 if ( mStyle == style )
474 QgsCheckableStyleModel *oldModel = mModel;
477 const bool readOnly = isReadOnly();
480 if ( !mActionCopyToDefault )
482 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
483 mShareMenu->insertAction( mActionCopyItem, mActionCopyToDefault );
484 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
486 mCopyToDefaultButton->show();
487 mModel =
new QgsCheckableStyleModel( mStyle,
this, readOnly );
491 mCopyToDefaultButton->hide();
492 if ( mActionCopyToDefault )
494 mActionCopyToDefault->deleteLater();
495 mActionCopyToDefault =
nullptr;
499 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
500 mModel->addDesiredIconSize( listItems->iconSize() );
501 mModel->setFilterString( searchBox->text() );
503 listItems->setModel( mModel );
504 mSymbolTreeView->setModel( mModel );
506 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
508 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
510 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
515 oldModel->deleteLater();
523 if ( mProjectStyleModel )
525 const QModelIndex styleIndex = mProjectStyleModel->
indexFromStyle( mStyle );
526 mBlockStyleDatabaseChanges++;
527 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
528 mBlockStyleDatabaseChanges--;
533 btnAddTag->setEnabled(
false );
534 btnAddSmartgroup->setEnabled(
false );
535 btnManageGroups->setEnabled(
false );
537 btnAddItem->setVisible(
false );
538 btnRemoveItem->setVisible(
false );
539 btnEditItem->setVisible(
false );
540 btnAddSmartgroup->setVisible(
false );
541 btnAddTag->setVisible(
false );
542 btnManageGroups->setVisible(
false );
544 delete mImportAction;
545 mImportAction =
nullptr;
547 mGroupTreeContextMenu->clear();
549 mGroupMenu->addAction( mActionCopyItem );
553 btnAddTag->setEnabled(
true );
554 btnAddSmartgroup->setEnabled(
true );
555 btnManageGroups->setEnabled(
true );
557 btnAddItem->setVisible(
true );
558 btnRemoveItem->setVisible(
true );
559 btnEditItem->setVisible(
true );
560 btnAddSmartgroup->setVisible(
true );
561 btnAddTag->setVisible(
true );
562 btnManageGroups->setVisible(
true );
564 if ( !mImportAction )
566 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
568 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
572 mGroupTreeContextMenu->clear();
573 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
574 mGroupTreeContextMenu->addAction( actnAddTag );
575 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
576 mGroupTreeContextMenu->addAction( actnRemoveGroup );
579 mGroupMenu->addAction( actnAddFavorite );
580 mGroupMenu->addAction( actnRemoveFavorite );
581 mGroupMenu->addSeparator()->setParent(
this );
582 mGroupMenu->addMenu( mGroupListMenu );
583 mGroupMenu->addAction( actnDetag );
584 mGroupMenu->addSeparator()->setParent(
this );
585 mGroupMenu->addAction( actnRemoveItem );
586 mGroupMenu->addAction( actnEditItem );
587 mGroupMenu->addAction( mActionCopyItem );
588 mGroupMenu->addAction( mActionPasteItem );
589 mGroupMenu->addSeparator()->setParent(
this );
592 if ( mActionCopyToDefault )
594 mGroupMenu->addAction( mActionCopyToDefault );
596 mGroupMenu->addAction( actnExportAsPNG );
597 mGroupMenu->addAction( actnExportAsSVG );
600 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
601 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
604 tabItemType_currentChanged( tabItemType->currentIndex() );
610void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
621 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
628void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
637 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
638 isColorRamp ? tr(
"Filter color ramps…" ) :
639 isTextFormat ? tr(
"Filter text symbols…" ) :
640 isLabelSettings ? tr(
"Filter label settings…" ) :
641 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
643 const bool readOnly = isReadOnly();
644 if ( !readOnly && isColorRamp )
646 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
648 else if ( !readOnly && isLegendPatchShape )
650 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
652 else if ( !readOnly && isSymbol3D )
654 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
656 else if ( !readOnly && isLabelSettings )
658 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
660 else if ( !readOnly && !isSymbol && !isColorRamp )
662 btnAddItem->setMenu(
nullptr );
664 else if ( !readOnly && tabItemType->currentIndex() == 0 )
666 btnAddItem->setMenu( mMenuBtnAddItemAll );
670 btnAddItem->setMenu(
nullptr );
673 actnExportAsPNG->setVisible( isSymbol );
674 actnExportAsSVG->setVisible( isSymbol );
679 mModel->setEntityFilterEnabled( !allTypesSelected() );
680 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
681 if ( isSymbol && !allTypesSelected() )
688void QgsStyleManagerDialog::copyItemsToDefault()
690 const QList< ItemDetails > items = selectedItems();
691 if ( !items.empty() )
695 if ( !mBaseName.isEmpty() )
696 options.append( mBaseName );
699 defaultTags.sort( Qt::CaseInsensitive );
700 options.append( defaultTags );
701 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
702 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
706#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
707 const QStringList parts = tags.split(
',', QString::SkipEmptyParts );
709 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
711 QStringList additionalTags;
712 additionalTags.reserve( parts.count() );
713 for (
const QString &tag : parts )
714 additionalTags << tag.trimmed();
716 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
717 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
718 cursorOverride.reset();
721 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
726void QgsStyleManagerDialog::copyItem()
728 const QList< ItemDetails > items = selectedItems();
732 ItemDetails details = items.at( 0 );
733 switch ( details.entityType )
737 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
747 QApplication::clipboard()->setMimeData( format.toMimeData() );
754 QApplication::clipboard()->setMimeData( format.toMimeData() );
768void QgsStyleManagerDialog::pasteItem()
770 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
775 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
776 saveDlg.setDefaultTags( defaultTag );
777 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
780 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
782 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
783 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
784 .arg( saveDlg.name() ),
785 QMessageBox::Yes | QMessageBox::No );
786 if ( res != QMessageBox::Yes )
793 QStringList symbolTags = saveDlg.tags().split(
',' );
795 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
797 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
806 saveDlg.setDefaultTags( defaultTag );
807 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
808 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
813 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
814 tr(
"A format with the name '%1' already exists. Overwrite?" )
815 .arg( saveDlg.name() ),
816 QMessageBox::Yes | QMessageBox::No );
817 if ( res != QMessageBox::Yes )
824 QStringList symbolTags = saveDlg.tags().split(
',' );
827 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
832void QgsStyleManagerDialog::setThumbnailSize(
int value )
837 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
840 listItems->setIconSize( QSize(
static_cast< int >(
iconSize ),
static_cast< int >(
iconSize * 0.9 ) ) );
841 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
844 mModel->addDesiredIconSize( listItems->iconSize() );
850int QgsStyleManagerDialog::selectedItemType()
852 QModelIndex index = listItems->selectionModel()->currentIndex();
853 if ( !index.isValid() )
871bool QgsStyleManagerDialog::allTypesSelected()
const
873 return tabItemType->currentIndex() == 0;
876bool QgsStyleManagerDialog::isReadOnly()
const
878 return mReadOnly || ( mStyle && mStyle->
isReadOnly() );
881QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
883 QList<QgsStyleManagerDialog::ItemDetails > res;
884 QModelIndexList indices = listItems->selectionModel()->selectedRows();
885 for (
const QModelIndex &index : indices )
887 if ( !index.isValid() )
894 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
901int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
902 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
905 bool overwriteAll =
true;
915 for (
auto &details : items )
917 QStringList symbolTags;
918 if ( !ignoreSourceTags )
920 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
923 bool addItemToFavorites =
false;
926 symbolTags << importTags;
927 addItemToFavorites = addToFavorites;
930 switch ( details.entityType )
934 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
938 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
939 bool overwriteThis =
false;
941 addItemToFavorites = favoriteSymbols.contains( details.name );
943 if ( hasDuplicateName && prompt )
945 cursorOverride.reset();
946 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
947 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
948 .arg( details.name ),
949 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
950 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
953 case QMessageBox::Cancel:
956 case QMessageBox::No:
959 case QMessageBox::Yes:
960 overwriteThis =
true;
963 case QMessageBox::YesToAll:
968 case QMessageBox::NoToAll:
970 overwriteAll =
false;
975 if ( !hasDuplicateName || overwriteAll || overwriteThis )
978 dst->
addSymbol( details.name, symbol.release() );
979 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
987 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
991 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
992 bool overwriteThis =
false;
994 addItemToFavorites = favoriteColorramps.contains( details.name );
996 if ( hasDuplicateName && prompt )
998 cursorOverride.reset();
999 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1000 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
1001 .arg( details.name ),
1002 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1003 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1006 case QMessageBox::Cancel:
1009 case QMessageBox::No:
1012 case QMessageBox::Yes:
1013 overwriteThis =
true;
1016 case QMessageBox::YesToAll:
1018 overwriteAll =
true;
1021 case QMessageBox::NoToAll:
1023 overwriteAll =
false;
1028 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1032 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1042 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1043 bool overwriteThis =
false;
1045 addItemToFavorites = favoriteTextFormats.contains( details.name );
1047 if ( hasDuplicateName && prompt )
1049 cursorOverride.reset();
1050 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1051 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
1052 .arg( details.name ),
1053 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1054 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1057 case QMessageBox::Cancel:
1060 case QMessageBox::No:
1063 case QMessageBox::Yes:
1064 overwriteThis =
true;
1067 case QMessageBox::YesToAll:
1069 overwriteAll =
true;
1072 case QMessageBox::NoToAll:
1074 overwriteAll =
false;
1079 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1082 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1093 bool overwriteThis =
false;
1095 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1097 if ( hasDuplicateName && prompt )
1099 cursorOverride.reset();
1100 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1101 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1102 .arg( details.name ),
1103 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1104 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1107 case QMessageBox::Cancel:
1110 case QMessageBox::No:
1113 case QMessageBox::Yes:
1114 overwriteThis =
true;
1117 case QMessageBox::YesToAll:
1119 overwriteAll =
true;
1122 case QMessageBox::NoToAll:
1124 overwriteAll =
false;
1129 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1132 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1143 bool overwriteThis =
false;
1145 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1147 if ( hasDuplicateName && prompt )
1149 cursorOverride.reset();
1150 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1151 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1152 .arg( details.name ),
1153 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1154 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1157 case QMessageBox::Cancel:
1160 case QMessageBox::No:
1163 case QMessageBox::Yes:
1164 overwriteThis =
true;
1167 case QMessageBox::YesToAll:
1169 overwriteAll =
true;
1172 case QMessageBox::NoToAll:
1174 overwriteAll =
false;
1179 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1190 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1194 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1195 bool overwriteThis =
false;
1197 addItemToFavorites = favorite3dSymbols.contains( details.name );
1199 if ( hasDuplicateName && prompt )
1201 cursorOverride.reset();
1202 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1203 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1204 .arg( details.name ),
1205 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1206 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1209 case QMessageBox::Cancel:
1212 case QMessageBox::No:
1215 case QMessageBox::Yes:
1216 overwriteThis =
true;
1219 case QMessageBox::YesToAll:
1221 overwriteAll =
true;
1224 case QMessageBox::NoToAll:
1226 overwriteAll =
false;
1231 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1234 dst->
addSymbol3D( details.name, symbol.release() );
1235 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1250bool QgsStyleManagerDialog::addTextFormat()
1254 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1255 if ( !formatDlg.exec() )
1257 format = formatDlg.format();
1260 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1261 saveDlg.setDefaultTags( defaultTag );
1262 if ( !saveDlg.exec() )
1264 QString name = saveDlg.name();
1267 bool nameInvalid =
true;
1268 while ( nameInvalid )
1271 if ( name.isEmpty() )
1273 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1274 tr(
"Cannot save text format without name. Enter a name." ) );
1278 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1279 tr(
"Text format with name '%1' already exists. Overwrite?" )
1281 QMessageBox::Yes | QMessageBox::No );
1282 if ( res == QMessageBox::Yes )
1285 nameInvalid =
false;
1291 nameInvalid =
false;
1296 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1297 tr(
"Please enter a name for new text format:" ),
1298 QLineEdit::Normal, name, &ok );
1306 QStringList symbolTags = saveDlg.tags().split(
',' );
1310 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1318 groupChanged( groupTree->selectionModel()->currentIndex() );
1331 switch ( tabItemType->currentIndex() )
1356 QModelIndex index = listItems->selectionModel()->currentIndex();
1357 if ( !index.isValid() )
1360 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1365 bool changed =
false;
1376 changed = addTextFormat();
1395 Q_ASSERT(
false &&
"not implemented" );
1408 QString name = tr(
"new symbol" );
1409 QString dialogTitle;
1414 name = tr(
"new marker" );
1415 dialogTitle = tr(
"New Marker Symbol" );
1419 name = tr(
"new line" );
1420 dialogTitle = tr(
"New Line Symbol" );
1424 name = tr(
"new fill symbol" );
1425 dialogTitle = tr(
"New Fill Symbol" );
1428 Q_ASSERT(
false &&
"unknown symbol type" );
1438 dlg.setWindowTitle( dialogTitle );
1439 if ( dlg.exec() == 0 )
1446 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1448 if ( !saveDlg.exec() )
1454 name = saveDlg.
name();
1457 bool nameInvalid =
true;
1458 while ( nameInvalid )
1461 if ( name.isEmpty() )
1463 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1464 tr(
"Cannot save symbol without name. Enter a name." ) );
1466 else if ( mStyle->
symbolNames().contains( name ) )
1468 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1469 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1471 QMessageBox::Yes | QMessageBox::No );
1472 if ( res == QMessageBox::Yes )
1475 nameInvalid =
false;
1481 nameInvalid =
false;
1486 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1487 tr(
"Please enter a name for new symbol:" ),
1488 QLineEdit::Normal, name, &ok );
1497 QStringList symbolTags = saveDlg.
tags().split(
',' );
1510 QString rampType = type;
1512 if ( rampType.isEmpty() )
1517 QStringList rampTypeNames;
1518 rampTypeNames.reserve( rampTypes.size() );
1519 for (
const QPair< QString, QString > &type : rampTypes )
1520 rampTypeNames << type.second;
1521 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1522 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1523 if ( !ok || selectedRampTypeName.isEmpty() )
1526 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1529 QString name = tr(
"new ramp" );
1531 std::unique_ptr< QgsColorRamp > ramp;
1535 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1541 name = tr(
"new gradient ramp" );
1546 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1552 name = tr(
"new random ramp" );
1557 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1568 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1574 name = tr(
"new preset ramp" );
1579 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1599 QgsDebugMsg( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1604 if ( !saveDlg.exec() )
1609 name = saveDlg.
name();
1612 bool nameInvalid =
true;
1613 while ( nameInvalid )
1616 if ( name.isEmpty() )
1618 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1619 tr(
"Cannot save color ramp without name. Enter a name." ) );
1623 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1624 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1626 QMessageBox::Yes | QMessageBox::No );
1627 if ( res == QMessageBox::Yes )
1629 nameInvalid =
false;
1635 nameInvalid =
false;
1640 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1641 tr(
"Please enter a name for new color ramp:" ),
1642 QLineEdit::Normal, name, &ok );
1650 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1662 mFavoritesGroupVisible = show;
1668 mSmartGroupVisible = show;
1680 setWindowState( windowState() & ~Qt::WindowMinimized );
1688 if ( !rampName.isEmpty() )
1700 if ( selectedItemType() < 3 )
1704 else if ( selectedItemType() == 3 )
1708 else if ( selectedItemType() == 4 )
1712 else if ( selectedItemType() == 5 )
1714 editLabelSettings();
1716 else if ( selectedItemType() == 6 )
1718 editLegendPatchShape();
1720 else if ( selectedItemType() == 7 )
1726 Q_ASSERT(
false &&
"not implemented" );
1733 if ( symbolName.isEmpty() )
1736 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1740 dlg.setWindowTitle( symbolName );
1742 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1748 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1756 if ( name.isEmpty() )
1759 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1765 dlg.setWindowTitle( name );
1767 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1779 dlg.setWindowTitle( name );
1781 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1793 dlg.setWindowTitle( name );
1795 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1807 dlg.setWindowTitle( name );
1809 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1821 dlg.setWindowTitle( name );
1823 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1840 Q_ASSERT(
false &&
"invalid ramp type" );
1848bool QgsStyleManagerDialog::editTextFormat()
1851 if ( formatName.isEmpty() )
1858 dlg.setWindowTitle( formatName );
1860 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1874 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1875 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1877 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1879 if ( !settingsDlg.exec() )
1882 settings = settingsDlg.settings();
1886 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1887 saveDlg.setDefaultTags( defaultTag );
1888 if ( !saveDlg.exec() )
1890 QString name = saveDlg.name();
1893 bool nameInvalid =
true;
1894 while ( nameInvalid )
1897 if ( name.isEmpty() )
1899 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1900 tr(
"Cannot save label settings without a name. Enter a name." ) );
1904 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1905 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1907 QMessageBox::Yes | QMessageBox::No );
1908 if ( res == QMessageBox::Yes )
1911 nameInvalid =
false;
1917 nameInvalid =
false;
1922 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1923 tr(
"Please enter a name for the new label settings:" ),
1924 QLineEdit::Normal, name, &ok );
1932 QStringList symbolTags = saveDlg.tags().split(
',' );
1942bool QgsStyleManagerDialog::editLabelSettings()
1945 if ( formatName.isEmpty() )
1952 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1953 dlg.setWindowTitle( formatName );
1957 settings = dlg.settings();
1970 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1972 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1974 if ( !dialog.exec() )
1977 shape = dialog.shape();
1980 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
1981 saveDlg.setDefaultTags( defaultTag );
1982 if ( !saveDlg.exec() )
1984 QString name = saveDlg.name();
1987 bool nameInvalid =
true;
1988 while ( nameInvalid )
1991 if ( name.isEmpty() )
1993 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1994 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1998 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1999 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
2001 QMessageBox::Yes | QMessageBox::No );
2002 if ( res == QMessageBox::Yes )
2005 nameInvalid =
false;
2011 nameInvalid =
false;
2016 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
2017 tr(
"Please enter a name for the new legend patch shape:" ),
2018 QLineEdit::Normal, name, &ok );
2026 QStringList symbolTags = saveDlg.tags().split(
',' );
2036bool QgsStyleManagerDialog::editLegendPatchShape()
2039 if ( shapeName.isEmpty() )
2048 dlg.setWindowTitle( shapeName );
2052 shape = dlg.shape();
2060bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2067 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2069 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2071 if ( !dialog.exec() )
2074 symbol.reset( dialog.symbol() );
2079 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data(
GroupModelRoles::TagName ).toString() : QString();
2080 saveDlg.setDefaultTags( defaultTag );
2081 if ( !saveDlg.exec() )
2083 QString name = saveDlg.name();
2086 bool nameInvalid =
true;
2087 while ( nameInvalid )
2090 if ( name.isEmpty() )
2092 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2093 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2097 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2098 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2100 QMessageBox::Yes | QMessageBox::No );
2101 if ( res == QMessageBox::Yes )
2104 nameInvalid =
false;
2110 nameInvalid =
false;
2115 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2116 tr(
"Please enter a name for the new 3D symbol:" ),
2117 QLineEdit::Normal, name, &ok );
2125 QStringList symbolTags = saveDlg.tags().split(
',' );
2130 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2136bool QgsStyleManagerDialog::editSymbol3D()
2139 if ( symbolName.isEmpty() )
2142 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2148 dlg.setWindowTitle( symbolName );
2152 symbol.reset( dlg.symbol() );
2157 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2162void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2165 if ( initialFolder.isEmpty() )
2166 initialFolder = QDir::homePath();
2168 QString databasePath = createNew
2169 ? QFileDialog::getSaveFileName(
2171 tr(
"Create Style Database" ),
2173 tr(
"Style databases" ) +
" (*.db)" )
2174 : QFileDialog::getOpenFileName(
2176 tr(
"Add Style Database" ),
2178 tr(
"Style databases" ) +
" (*.db *.xml)" );
2179 if ( ! databasePath.isEmpty() )
2186 if ( QFile::exists( databasePath ) )
2188 QFile::remove( databasePath );
2193 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2205 const QList< ItemDetails > items = selectedItems();
2207 if ( allTypesSelected() )
2209 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2210 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2219 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2220 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2227 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2228 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2235 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2236 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2243 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2244 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2251 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2252 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2259 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2260 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2269 for (
const ItemDetails &details : items )
2271 if ( details.name.isEmpty() )
2296 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2297 QDir::home().absolutePath(),
2298 QFileDialog::DontResolveSymlinks );
2304 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2305 QDir::home().absolutePath(),
2306 QFileDialog::DontResolveSymlinks );
2313 if ( dir.isEmpty() )
2316 const QList< ItemDetails > items = selectedItems();
2317 for (
const ItemDetails &details : items )
2322 QString path = dir +
'/' + details.name +
'.' + format;
2323 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2325 sym->exportImage( path, format, size );
2345 QFont font = item->font();
2346 font.setBold(
true );
2347 item->setFont( font );
2352 if ( mBlockGroupUpdates )
2355 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2358 const bool readOnly = isReadOnly();
2360 if ( mFavoritesGroupVisible )
2362 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2363 favoriteSymbols->setData(
"favorite" );
2364 favoriteSymbols->setEditable(
false );
2366 model->appendRow( favoriteSymbols );
2369 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2370 allSymbols->setData(
"all" );
2371 allSymbols->setEditable(
false );
2373 model->appendRow( allSymbols );
2375 QStandardItem *taggroup =
new QStandardItem( QString() );
2376 taggroup->setData(
"tags" );
2377 taggroup->setEditable(
false );
2378 QStringList tags = mStyle->
tags();
2380 for (
const QString &tag : std::as_const( tags ) )
2382 QStandardItem *item =
new QStandardItem( tag );
2383 item->setData( mStyle->
tagId( tag ) );
2385 item->setEditable( !readOnly );
2386 taggroup->appendRow( item );
2388 taggroup->setText( tr(
"Tags" ) );
2390 model->appendRow( taggroup );
2392 if ( mSmartGroupVisible )
2394 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2395 smart->setData(
"smartgroups" );
2396 smart->setEditable(
false );
2399 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2400 while ( i != sgMap.constEnd() )
2402 QStandardItem *item =
new QStandardItem( i.value() );
2403 item->setData( i.key() );
2404 item->setEditable( !readOnly );
2405 smart->appendRow( item );
2408 model->appendRow( smart );
2412 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2413 for (
int i = 0; i < rows; i++ )
2415 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2421 QStringList groupSymbols;
2423 const QString category = index.data( Qt::UserRole + 1 ).toString();
2424 sPreviousTag = category;
2426 const bool readOnly = isReadOnly();
2428 if ( mGroupingMode && mModel )
2430 mModel->setTagId( -1 );
2431 mModel->setSmartGroupId( -1 );
2432 mModel->setFavoritesOnly(
false );
2433 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2435 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2438 if ( category == QLatin1String(
"tags" ) )
2440 actnAddTag->setEnabled( !readOnly );
2441 actnAddSmartgroup->setEnabled(
false );
2443 else if ( category == QLatin1String(
"smartgroups" ) )
2445 actnAddTag->setEnabled(
false );
2446 actnAddSmartgroup->setEnabled( !readOnly );
2451 mModel->setTagId( -1 );
2452 mModel->setSmartGroupId( -1 );
2453 mModel->setFavoritesOnly(
false );
2456 else if ( category == QLatin1String(
"favorite" ) )
2459 mModel->setTagId( -1 );
2460 mModel->setSmartGroupId( -1 );
2461 mModel->setFavoritesOnly(
true );
2463 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2465 actnRemoveGroup->setEnabled( !readOnly );
2466 btnManageGroups->setEnabled( !readOnly );
2467 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2470 mModel->setTagId( -1 );
2471 mModel->setSmartGroupId( groupId );
2472 mModel->setFavoritesOnly(
false );
2478 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2481 mModel->setTagId( tagId );
2482 mModel->setSmartGroupId( -1 );
2483 mModel->setFavoritesOnly(
false );
2487 actnEditSmartGroup->setVisible(
false );
2488 actnAddTag->setVisible(
false );
2489 actnAddSmartgroup->setVisible(
false );
2490 actnRemoveGroup->setVisible(
false );
2491 actnTagSymbols->setVisible(
false );
2492 actnFinishTagging->setVisible(
false );
2494 if ( index.parent().isValid() )
2496 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2498 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2500 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2502 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2503 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2504 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2506 actnRemoveGroup->setVisible( !readOnly );
2508 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2510 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2512 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2514 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2523 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2525 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2527 index = groupTree->model()->index( i, 0 );
2528 QString data = index.data( Qt::UserRole + 1 ).toString();
2529 if ( data == QLatin1String(
"tags" ) )
2538 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2539 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2540 if ( !ok || itemName.isEmpty() )
2543 int check = mStyle->
tagId( itemName );
2546 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2552 mBlockGroupUpdates++;
2553 id = mStyle->
addTag( itemName );
2554 mBlockGroupUpdates--;
2558 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2562 QStandardItem *parentItem = model->itemFromIndex( index );
2563 QStandardItem *childItem =
new QStandardItem( itemName );
2564 childItem->setData(
id );
2566 parentItem->appendRow( childItem );
2576 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2578 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2580 index = groupTree->model()->index( i, 0 );
2581 QString data = index.data( Qt::UserRole + 1 ).toString();
2582 if ( data == QLatin1String(
"smartgroups" ) )
2591 if ( dlg.exec() == QDialog::Rejected )
2596 mBlockGroupUpdates++;
2598 mBlockGroupUpdates--;
2604 QStandardItem *parentItem = model->itemFromIndex( index );
2605 QStandardItem *childItem =
new QStandardItem( itemName );
2606 childItem->setData(
id );
2607 parentItem->appendRow( childItem );
2617 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2618 QModelIndex index = groupTree->currentIndex();
2621 QString data = index.data( Qt::UserRole + 1 ).toString();
2622 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2625 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2626 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2627 "Kindly select a group or smart group you might want to delete." ) );
2632 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2636 mBlockGroupUpdates++;
2638 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2647 mBlockGroupUpdates--;
2648 parentItem->removeRow( index.row() );
2656 QgsDebugMsg( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ) );
2657 int id = item->data( Qt::UserRole + 1 ).toInt();
2658 QString name = item->text();
2659 mBlockGroupUpdates++;
2660 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2668 mBlockGroupUpdates--;
2676 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2678 if ( mGroupingMode )
2680 mGroupingMode =
false;
2681 mModel->setCheckable(
false );
2682 actnTagSymbols->setVisible(
true );
2683 actnFinishTagging->setVisible(
false );
2691 connect( treeModel, &QStandardItemModel::itemChanged,
2695 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2696 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2700 bool validGroup =
false;
2702 QModelIndex present = groupTree->currentIndex();
2703 while ( present.parent().isValid() )
2705 if ( present.parent().data() ==
"Tags" )
2710 present = present.parent();
2715 mGroupingMode =
true;
2717 actnTagSymbols->setVisible(
false );
2718 actnFinishTagging->setVisible(
true );
2720 disconnect( treeModel, &QStandardItemModel::itemChanged,
2726 btnManageGroups->setEnabled(
true );
2728 mModel->setCheckable(
true );
2731 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2732 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2746 mModel->setFilterString( qword );
2751 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2756 Q_UNUSED( selected )
2757 Q_UNUSED( deselected )
2758 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2759 const bool readOnly = isReadOnly();
2760 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2761 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2762 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2763 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2764 actnDetag->setDisabled( nothingSelected || readOnly );
2765 actnExportAsPNG->setDisabled( nothingSelected );
2766 actnExportAsSVG->setDisabled( nothingSelected );
2767 if ( mActionCopyToDefault )
2768 mActionCopyToDefault->setDisabled( nothingSelected );
2769 mCopyToDefaultButton->setDisabled( nothingSelected );
2770 actnEditItem->setDisabled( nothingSelected || readOnly );
2775 const bool readOnly = isReadOnly();
2776 groupTree->setEnabled( enable );
2777 btnAddTag->setEnabled( enable && !readOnly );
2778 btnAddSmartgroup->setEnabled( enable && !readOnly );
2779 actnAddTag->setEnabled( enable && !readOnly );
2780 actnAddSmartgroup->setEnabled( enable && !readOnly );
2781 actnRemoveGroup->setEnabled( enable && !readOnly );
2782 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2783 searchBox->setEnabled( enable );
2788 const bool readOnly = isReadOnly();
2789 actnRemoveGroup->setEnabled( enable && !readOnly );
2790 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2795 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2796 for (
int i = 0; i < treeModel->rowCount(); i++ )
2798 treeModel->item( i )->setEnabled( enable );
2800 if ( treeModel->item( i )->data() ==
"smartgroups" )
2802 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2804 treeModel->item( i )->child( j )->setEnabled( enable );
2811 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2813 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2815 w->setEnabled( enable );
2819 actnRemoveItem->setEnabled( enable );
2820 actnEditItem->setEnabled( enable );
2821 mActionCopyItem->setEnabled( enable );
2822 mActionPasteItem->setEnabled( enable );
2827 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2829 QModelIndex index = groupTree->indexAt( point );
2830 if ( index.isValid() && !mGroupingMode )
2831 mGroupTreeContextMenu->popup( globalPos );
2836 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2837 ? listItems->viewport()->mapToGlobal( point )
2838 : mSymbolTreeView->viewport()->mapToGlobal( point );
2841 mGroupListMenu->clear();
2843 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2845 if ( !isReadOnly() )
2847 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
QgsStyleModel::TagRole ).toStringList() : QStringList();
2848 QAction *a =
nullptr;
2849 QStringList tags = mStyle->
tags();
2851 for (
const QString &tag : std::as_const( tags ) )
2853 a =
new QAction( tag, mGroupListMenu );
2855 if ( indices.count() == 1 )
2857 a->setCheckable(
true );
2858 a->setChecked( currentTags.contains( tag ) );
2862 mGroupListMenu->addAction( a );
2865 if ( tags.count() > 0 )
2867 mGroupListMenu->addSeparator();
2869 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2872 mGroupListMenu->addAction( a );
2875 const QList< ItemDetails > items = selectedItems();
2878 bool enablePaste =
false;
2886 mActionPasteItem->setEnabled( enablePaste );
2888 mGroupMenu->popup( globalPos );
2896 const QList< ItemDetails > items = selectedItems();
2897 for (
const ItemDetails &details : items )
2899 mStyle->
addFavorite( details.entityType, details.name );
2908 const QList< ItemDetails > items = selectedItems();
2909 for (
const ItemDetails &details : items )
2917 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2920 const QList< ItemDetails > items = selectedItems();
2930 tag = mStyle->
tag(
id );
2934 tag = selectedItem->data().toString();
2937 for (
const ItemDetails &details : items )
2939 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2949 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2953 const QList< ItemDetails > items = selectedItems();
2954 for (
const ItemDetails &details : items )
2956 mStyle->
detagSymbol( details.entityType, details.name );
2966 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2969 QModelIndex present = groupTree->currentIndex();
2970 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2973 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2974 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2977 QStandardItem *item = treeModel->itemFromIndex( present );
2985 if ( dlg.exec() == QDialog::Rejected )
2988 mBlockGroupUpdates++;
2991 mBlockGroupUpdates--;
2994 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2998 item->setData(
id );
static const double UI_SCALE_FACTOR
UI scaling factor.
A dialog for configuring a 3D symbol.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp.
QgsColorBrewerColorRamp ramp
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Color ramp utilising "Color Brewer" preset color schemes.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
Abstract base class for color ramps.
static QList< QPair< QString, QString > > rampTypes()
Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type(...
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
QgsGradientColorRamp * cloneGradientRamp() const
QString schemeName() const
QString variantName() const
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.
QgsWkbTypes::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.
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.
static const QgsSettingsEntryString settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
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.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
QMap< int, QString > QgsSymbolGroupMap