17#include "moc_qgsstylemanagerdialog.cpp"
54#include <QInputDialog>
57#include <QStandardItemModel>
60#include <QDesktopServices>
74QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
76 , mStyle( sourceModel->style() )
77 , mReadOnly( readOnly )
82QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
85 , mReadOnly( readOnly )
89void QgsCheckableStyleModel::setCheckable(
bool checkable )
91 if ( checkable == mCheckable )
94 mCheckable = checkable;
95 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
98void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
100 if ( tag == mCheckTag )
104 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector< int >() << Qt::CheckStateRole );
107Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
109 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
110 if ( !mReadOnly && mCheckable && index.column() == 0 )
111 f |= Qt::ItemIsUserCheckable;
114 f &= ~Qt::ItemIsEditable;
119QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
126 QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
131 case Qt::CheckStateRole:
133 if ( !mCheckable || index.column() != 0 )
137 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
144 return QgsStyleProxyModel::data( index, role );
147bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
149 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) ||
150 ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
156 if ( role == Qt::CheckStateRole )
158 if ( !mCheckable || mCheckTag.isEmpty() )
161 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
164 if ( value.toInt() == Qt::Checked )
165 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
167 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
169 return QgsStyleProxyModel::setData( i, value, role );
179QString QgsStyleManagerDialog::sPreviousTag;
182 : QDialog( parent, flags )
183 , mReadOnly( readOnly )
186 setCurrentStyle( style );
187 mStyleDatabaseWidget->hide();
191 : QDialog( parent, flags )
197 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
201 connect( mComboBoxStyleDatabase, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ]()
203 if ( mBlockStyleDatabaseChanges )
206 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
210 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
false ); } );
211 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [ = ] { addStyleDatabase(
true ); } );
214void QgsStyleManagerDialog::init()
218 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
222 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
223 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
225 connect( downloadButton, &QPushButton::clicked,
this, [ = ]
227 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://plugins.qgis.org/styles" ) ) );
231 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
232 mVerticalLayout->insertWidget( 0, mMessageBar );
235 setWindowModality( Qt::WindowModal );
240 mSplitter->setSizes( QList<int>() << 170 << 540 );
241 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
243 tabItemType->setDocumentMode(
true );
244 searchBox->setShowSearchIcon(
true );
245 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
249 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
251 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
255 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool )
258 if ( !btnAddItem->menu() )
265 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
267 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
270 mShareMenu =
new QMenu( tr(
"Share Menu" ),
this );
271 mExportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
273 mShareMenu->addAction( mExportAction );
275 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
277 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
278 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
279 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
280 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
282 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
283 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
284 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
285 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
286 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
288 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
291 mShareMenu->addSeparator();
292 mShareMenu->addAction( actnExportAsPNG );
293 mShareMenu->addAction( actnExportAsSVG );
298 btnShare->setMenu( mShareMenu );
300 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
302 mSymbolTreeView->setIconSize( QSize(
static_cast< int >( treeIconSize ),
static_cast< int >( treeIconSize ) ) );
304 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
305 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
306 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
308 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
309 groupTree->setModel( groupModel );
310 groupTree->setHeaderHidden(
true );
312 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
316 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
318 groupMenu->addAction( actnTagSymbols );
320 actnFinishTagging->setVisible(
false );
321 groupMenu->addAction( actnFinishTagging );
322 groupMenu->addAction( actnEditSmartGroup );
323 btnManageGroups->setMenu( groupMenu );
328 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
329 connect( groupTree, &QWidget::customContextMenuRequested,
333 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
334 connect( listItems, &QWidget::customContextMenuRequested,
336 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
337 connect( mSymbolTreeView, &QWidget::customContextMenuRequested,
340 mMenuBtnAddItemAll =
new QMenu(
this );
341 mMenuBtnAddItemColorRamp =
new QMenu(
this );
342 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
343 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
344 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
348 mMenuBtnAddItemAll->addAction( item );
351 mMenuBtnAddItemAll->addAction( item );
354 mMenuBtnAddItemAll->addAction( item );
355 mMenuBtnAddItemAll->addSeparator();
358 for (
const QPair< QString, QString > &rampType : rampTypes )
360 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
361 connect( item, &QAction::triggered,
this, [ = ](
bool ) {
addColorRamp( rampType.first ); } );
362 mMenuBtnAddItemAll->addAction( item );
363 mMenuBtnAddItemColorRamp->addAction( item );
365 mMenuBtnAddItemAll->addSeparator();
367 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addTextFormat(); } );
368 mMenuBtnAddItemAll->addAction( item );
369 mMenuBtnAddItemAll->addSeparator();
372 mMenuBtnAddItemAll->addAction( item );
373 mMenuBtnAddItemLabelSettings->addAction( item );
376 mMenuBtnAddItemAll->addAction( item );
377 mMenuBtnAddItemLabelSettings->addAction( item );
380 mMenuBtnAddItemAll->addAction( item );
381 mMenuBtnAddItemLabelSettings->addAction( item );
383 mMenuBtnAddItemAll->addSeparator();
386 mMenuBtnAddItemAll->addAction( item );
387 mMenuBtnAddItemLegendPatchShape->addAction( item );
389 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
390 mMenuBtnAddItemAll->addAction( item );
391 mMenuBtnAddItemLegendPatchShape->addAction( item );
393 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
394 mMenuBtnAddItemAll->addAction( item );
395 mMenuBtnAddItemLegendPatchShape->addAction( item );
397 mMenuBtnAddItemAll->addSeparator();
399 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"point" ) ); } );
400 mMenuBtnAddItemAll->addAction( item );
401 mMenuBtnAddItemSymbol3D->addAction( item );
403 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
404 mMenuBtnAddItemAll->addAction( item );
405 mMenuBtnAddItemSymbol3D->addAction( item );
407 connect( item, &QAction::triggered,
this, [ = ](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
408 mMenuBtnAddItemAll->addAction( item );
409 mMenuBtnAddItemSymbol3D->addAction( item );
412 mGroupMenu =
new QMenu(
this );
413 mGroupListMenu =
new QMenu( mGroupMenu );
414 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
415 mGroupListMenu->setEnabled(
false );
422 mGroupTreeContextMenu =
new QMenu(
this );
424 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); } );
425 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); } );
428 tabItemType_currentChanged( 0 );
430 connect( mButtonIconView, &QToolButton::toggled,
this, [ = ](
bool active )
434 mSymbolViewStackedWidget->setCurrentIndex( 0 );
439 connect( mButtonListView, &QToolButton::toggled,
this, [ = ](
bool active )
444 mSymbolViewStackedWidget->setCurrentIndex( 1 );
448 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
449 if ( currentView == 0 )
450 mButtonIconView->setChecked(
true );
452 mButtonListView->setChecked(
true );
454 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
455 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this]
458 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
461 const int thumbnailSize = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), 0,
QgsSettings::Gui ).toInt();
462 mSliderIconSize->setValue( thumbnailSize );
463 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
464 setThumbnailSize( thumbnailSize );
467void QgsStyleManagerDialog::setCurrentStyle(
QgsStyle *style )
469 if ( mStyle == style )
479 QgsCheckableStyleModel *oldModel = mModel;
482 const bool readOnly = isReadOnly();
485 if ( !mActionCopyToDefault )
487 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
488 mShareMenu->insertAction( mActionCopyItem, mActionCopyToDefault );
489 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
491 mCopyToDefaultButton->show();
492 mModel =
new QgsCheckableStyleModel( mStyle,
this, readOnly );
496 mCopyToDefaultButton->hide();
497 if ( mActionCopyToDefault )
499 mActionCopyToDefault->deleteLater();
500 mActionCopyToDefault =
nullptr;
504 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
505 mModel->addDesiredIconSize( listItems->iconSize() );
508 mModel->setFilterString( searchBox->text() );
510 listItems->setModel( mModel );
511 mSymbolTreeView->setModel( mModel );
513 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
515 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
517 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
522 oldModel->deleteLater();
530 if ( mProjectStyleModel )
532 const QModelIndex styleIndex = mProjectStyleModel->
indexFromStyle( mStyle );
533 mBlockStyleDatabaseChanges++;
534 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
535 mBlockStyleDatabaseChanges--;
540 btnAddTag->setEnabled(
false );
541 btnAddSmartgroup->setEnabled(
false );
542 btnManageGroups->setEnabled(
false );
544 btnAddItem->setVisible(
false );
545 btnRemoveItem->setVisible(
false );
546 btnEditItem->setVisible(
false );
547 btnAddSmartgroup->setVisible(
false );
548 btnAddTag->setVisible(
false );
549 btnManageGroups->setVisible(
false );
551 delete mImportAction;
552 mImportAction =
nullptr;
554 mGroupTreeContextMenu->clear();
556 mGroupMenu->addAction( mActionCopyItem );
560 btnAddTag->setEnabled(
true );
561 btnAddSmartgroup->setEnabled(
true );
562 btnManageGroups->setEnabled(
true );
564 btnAddItem->setVisible(
true );
565 btnRemoveItem->setVisible(
true );
566 btnEditItem->setVisible(
true );
567 btnAddSmartgroup->setVisible(
true );
568 btnAddTag->setVisible(
true );
569 btnManageGroups->setVisible(
true );
571 if ( !mImportAction )
573 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
575 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
579 mGroupTreeContextMenu->clear();
580 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
581 mGroupTreeContextMenu->addAction( actnAddTag );
582 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
583 mGroupTreeContextMenu->addAction( actnRemoveGroup );
586 mGroupMenu->addAction( actnAddFavorite );
587 mGroupMenu->addAction( actnRemoveFavorite );
588 mGroupMenu->addSeparator()->setParent(
this );
589 mGroupMenu->addMenu( mGroupListMenu );
590 mGroupMenu->addAction( actnDetag );
591 mGroupMenu->addSeparator()->setParent(
this );
592 mGroupMenu->addAction( actnRemoveItem );
593 mGroupMenu->addAction( actnEditItem );
594 mGroupMenu->addAction( mActionCopyItem );
595 mGroupMenu->addAction( mActionPasteItem );
596 mGroupMenu->addSeparator()->setParent(
this );
599 if ( mActionCopyToDefault )
601 mGroupMenu->addAction( mActionCopyToDefault );
603 mGroupMenu->addAction( actnExportAsPNG );
604 mGroupMenu->addAction( actnExportAsSVG );
607 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
608 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
611 tabItemType_currentChanged( tabItemType->currentIndex() );
617void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
628 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
635void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
644 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) :
645 isColorRamp ? tr(
"Filter color ramps…" ) :
646 isTextFormat ? tr(
"Filter text symbols…" ) :
647 isLabelSettings ? tr(
"Filter label settings…" ) :
648 isLegendPatchShape ? tr(
"Filter legend patch shapes…" ) : tr(
"Filter 3D symbols…" ) );
650 const bool readOnly = isReadOnly();
651 if ( !readOnly && isColorRamp )
653 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
655 else if ( !readOnly && isLegendPatchShape )
657 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
659 else if ( !readOnly && isSymbol3D )
661 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
663 else if ( !readOnly && isLabelSettings )
665 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
667 else if ( !readOnly && !isSymbol && !isColorRamp )
669 btnAddItem->setMenu(
nullptr );
671 else if ( !readOnly && tabItemType->currentIndex() == 0 )
673 btnAddItem->setMenu( mMenuBtnAddItemAll );
677 btnAddItem->setMenu(
nullptr );
680 actnExportAsPNG->setVisible( isSymbol );
681 actnExportAsSVG->setVisible( isSymbol );
686 mModel->setEntityFilterEnabled( !allTypesSelected() );
687 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
688 if ( isSymbol && !allTypesSelected() )
695void QgsStyleManagerDialog::copyItemsToDefault()
697 const QList< ItemDetails > items = selectedItems();
698 if ( !items.empty() )
702 if ( !mBaseName.isEmpty() )
703 options.append( mBaseName );
706 defaultTags.sort( Qt::CaseInsensitive );
707 options.append( defaultTags );
708 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ),
709 tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0, true, &ok );
713 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
714 QStringList additionalTags;
715 additionalTags.reserve( parts.count() );
716 for (
const QString &tag : parts )
717 additionalTags << tag.trimmed();
719 auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
720 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
721 cursorOverride.reset();
724 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
729void QgsStyleManagerDialog::copyItem()
731 const QList< ItemDetails > items = selectedItems();
735 ItemDetails details = items.at( 0 );
736 switch ( details.entityType )
740 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( details.name ) );
750 QApplication::clipboard()->setMimeData( format.toMimeData() );
757 QApplication::clipboard()->setMimeData( format.toMimeData() );
771void QgsStyleManagerDialog::pasteItem()
773 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
778 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
779 saveDlg.setDefaultTags( defaultTag );
780 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
783 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
785 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ),
786 tr(
"A symbol with the name '%1' already exists. Overwrite?" )
787 .arg( saveDlg.name() ),
788 QMessageBox::Yes | QMessageBox::No );
789 if ( res != QMessageBox::Yes )
796 QStringList symbolTags = saveDlg.tags().split(
',' );
798 mStyle->
addSymbol( saveDlg.name(), tempSymbol.release() );
800 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
809 saveDlg.setDefaultTags( defaultTag );
810 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
811 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
816 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ),
817 tr(
"A format with the name '%1' already exists. Overwrite?" )
818 .arg( saveDlg.name() ),
819 QMessageBox::Yes | QMessageBox::No );
820 if ( res != QMessageBox::Yes )
827 QStringList symbolTags = saveDlg.tags().split(
',' );
830 mStyle->
saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
835void QgsStyleManagerDialog::setThumbnailSize(
int value )
840 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
843 listItems->setIconSize( QSize(
static_cast< int >( iconSize ),
static_cast< int >( iconSize * 0.9 ) ) );
844 listItems->setGridSize( QSize(
static_cast< int >( spacing ),
static_cast< int >( verticalSpacing ) ) );
847 mModel->addDesiredIconSize( listItems->iconSize() );
853int QgsStyleManagerDialog::selectedItemType()
855 QModelIndex index = listItems->selectionModel()->currentIndex();
856 if ( !index.isValid() )
874bool QgsStyleManagerDialog::allTypesSelected()
const
876 return tabItemType->currentIndex() == 0;
879bool QgsStyleManagerDialog::isReadOnly()
const
881 return mReadOnly || ( mStyle && mStyle->
isReadOnly() );
884QList< QgsStyleManagerDialog::ItemDetails > QgsStyleManagerDialog::selectedItems()
886 QList<QgsStyleManagerDialog::ItemDetails > res;
887 QModelIndexList indices = listItems->selectionModel()->selectedRows();
888 for (
const QModelIndex &index : indices )
890 if ( !index.isValid() )
897 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
904int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget,
905 std::unique_ptr< QgsTemporaryCursorOverride > &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
908 bool overwriteAll =
true;
918 for (
auto &details : items )
920 QStringList symbolTags;
921 if ( !ignoreSourceTags )
923 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
926 bool addItemToFavorites =
false;
929 symbolTags << importTags;
930 addItemToFavorites = addToFavorites;
933 switch ( details.entityType )
937 std::unique_ptr< QgsSymbol > symbol( src->
symbol( details.name ) );
941 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
942 bool overwriteThis =
false;
944 addItemToFavorites = favoriteSymbols.contains( details.name );
946 if ( hasDuplicateName && prompt )
948 cursorOverride.reset();
949 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
950 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" )
951 .arg( details.name ),
952 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
953 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
956 case QMessageBox::Cancel:
959 case QMessageBox::No:
962 case QMessageBox::Yes:
963 overwriteThis =
true;
966 case QMessageBox::YesToAll:
971 case QMessageBox::NoToAll:
973 overwriteAll =
false;
978 if ( !hasDuplicateName || overwriteAll || overwriteThis )
981 dst->
addSymbol( details.name, symbol.release() );
982 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
990 std::unique_ptr< QgsColorRamp > ramp( src->
colorRamp( details.name ) );
994 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
995 bool overwriteThis =
false;
997 addItemToFavorites = favoriteColorramps.contains( details.name );
999 if ( hasDuplicateName && prompt )
1001 cursorOverride.reset();
1002 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1003 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" )
1004 .arg( details.name ),
1005 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1006 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1009 case QMessageBox::Cancel:
1012 case QMessageBox::No:
1015 case QMessageBox::Yes:
1016 overwriteThis =
true;
1019 case QMessageBox::YesToAll:
1021 overwriteAll =
true;
1024 case QMessageBox::NoToAll:
1026 overwriteAll =
false;
1031 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1035 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1045 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1046 bool overwriteThis =
false;
1048 addItemToFavorites = favoriteTextFormats.contains( details.name );
1050 if ( hasDuplicateName && prompt )
1052 cursorOverride.reset();
1053 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1054 tr(
"A text format with the name “%1” already exists.\nOverwrite?" )
1055 .arg( details.name ),
1056 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1057 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1060 case QMessageBox::Cancel:
1063 case QMessageBox::No:
1066 case QMessageBox::Yes:
1067 overwriteThis =
true;
1070 case QMessageBox::YesToAll:
1072 overwriteAll =
true;
1075 case QMessageBox::NoToAll:
1077 overwriteAll =
false;
1082 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1085 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1096 bool overwriteThis =
false;
1098 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1100 if ( hasDuplicateName && prompt )
1102 cursorOverride.reset();
1103 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1104 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" )
1105 .arg( details.name ),
1106 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1107 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1110 case QMessageBox::Cancel:
1113 case QMessageBox::No:
1116 case QMessageBox::Yes:
1117 overwriteThis =
true;
1120 case QMessageBox::YesToAll:
1122 overwriteAll =
true;
1125 case QMessageBox::NoToAll:
1127 overwriteAll =
false;
1132 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1135 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1146 bool overwriteThis =
false;
1148 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1150 if ( hasDuplicateName && prompt )
1152 cursorOverride.reset();
1153 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1154 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" )
1155 .arg( details.name ),
1156 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1157 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1160 case QMessageBox::Cancel:
1163 case QMessageBox::No:
1166 case QMessageBox::Yes:
1167 overwriteThis =
true;
1170 case QMessageBox::YesToAll:
1172 overwriteAll =
true;
1175 case QMessageBox::NoToAll:
1177 overwriteAll =
false;
1182 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1193 std::unique_ptr< QgsAbstract3DSymbol > symbol( src->
symbol3D( details.name ) );
1197 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1198 bool overwriteThis =
false;
1200 addItemToFavorites = favorite3dSymbols.contains( details.name );
1202 if ( hasDuplicateName && prompt )
1204 cursorOverride.reset();
1205 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1206 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" )
1207 .arg( details.name ),
1208 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1209 cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
1212 case QMessageBox::Cancel:
1215 case QMessageBox::No:
1218 case QMessageBox::Yes:
1219 overwriteThis =
true;
1222 case QMessageBox::YesToAll:
1224 overwriteAll =
true;
1227 case QMessageBox::NoToAll:
1229 overwriteAll =
false;
1234 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1237 dst->
addSymbol3D( details.name, symbol.release() );
1238 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1253bool QgsStyleManagerDialog::addTextFormat()
1257 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1258 if ( !formatDlg.exec() )
1260 format = formatDlg.format();
1263 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1264 saveDlg.setDefaultTags( defaultTag );
1265 if ( !saveDlg.exec() )
1267 QString name = saveDlg.name();
1270 bool nameInvalid =
true;
1271 while ( nameInvalid )
1274 if ( name.isEmpty() )
1276 QMessageBox::warning(
this, tr(
"Save Text Format" ),
1277 tr(
"Cannot save text format without name. Enter a name." ) );
1281 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1282 tr(
"Text format with name '%1' already exists. Overwrite?" )
1284 QMessageBox::Yes | QMessageBox::No );
1285 if ( res == QMessageBox::Yes )
1288 nameInvalid =
false;
1294 nameInvalid =
false;
1299 name = QInputDialog::getText(
this, tr(
"Text Format Name" ),
1300 tr(
"Please enter a name for new text format:" ),
1301 QLineEdit::Normal, name, &ok );
1309 QStringList symbolTags = saveDlg.tags().split(
',' );
1313 mStyle->
saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1321 groupChanged( groupTree->selectionModel()->currentIndex() );
1334 switch ( tabItemType->currentIndex() )
1359 QModelIndex index = listItems->selectionModel()->currentIndex();
1360 if ( !index.isValid() )
1363 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1368 bool changed =
false;
1379 changed = addTextFormat();
1398 Q_ASSERT(
false &&
"not implemented" );
1411 QString name = tr(
"new symbol" );
1412 QString dialogTitle;
1417 name = tr(
"new marker" );
1418 dialogTitle = tr(
"New Marker Symbol" );
1422 name = tr(
"new line" );
1423 dialogTitle = tr(
"New Line Symbol" );
1427 name = tr(
"new fill symbol" );
1428 dialogTitle = tr(
"New Fill Symbol" );
1431 Q_ASSERT(
false &&
"unknown symbol type" );
1441 dlg.setWindowTitle( dialogTitle );
1442 if ( dlg.exec() == 0 )
1449 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1451 if ( !saveDlg.exec() )
1457 name = saveDlg.
name();
1460 bool nameInvalid =
true;
1461 while ( nameInvalid )
1464 if ( name.isEmpty() )
1466 QMessageBox::warning(
this, tr(
"Save Symbol" ),
1467 tr(
"Cannot save symbol without name. Enter a name." ) );
1469 else if ( mStyle->
symbolNames().contains( name ) )
1471 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
1472 tr(
"Symbol with name '%1' already exists. Overwrite?" )
1474 QMessageBox::Yes | QMessageBox::No );
1475 if ( res == QMessageBox::Yes )
1478 nameInvalid =
false;
1484 nameInvalid =
false;
1489 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
1490 tr(
"Please enter a name for new symbol:" ),
1491 QLineEdit::Normal, name, &ok );
1500 QStringList symbolTags = saveDlg.
tags().split(
',' );
1513 QString rampType = type;
1515 if ( rampType.isEmpty() )
1520 QStringList rampTypeNames;
1521 rampTypeNames.reserve( rampTypes.size() );
1522 for (
const QPair< QString, QString > &type : rampTypes )
1523 rampTypeNames << type.second;
1524 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
1525 tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1526 if ( !ok || selectedRampTypeName.isEmpty() )
1529 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1532 QString name = tr(
"new ramp" );
1534 std::unique_ptr< QgsColorRamp > ramp;
1538 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1544 name = tr(
"new gradient ramp" );
1549 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1555 name = tr(
"new random ramp" );
1560 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1571 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1577 name = tr(
"new preset ramp" );
1582 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1602 QgsDebugError( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1607 if ( !saveDlg.exec() )
1612 name = saveDlg.
name();
1615 bool nameInvalid =
true;
1616 while ( nameInvalid )
1619 if ( name.isEmpty() )
1621 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1622 tr(
"Cannot save color ramp without name. Enter a name." ) );
1626 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
1627 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
1629 QMessageBox::Yes | QMessageBox::No );
1630 if ( res == QMessageBox::Yes )
1632 nameInvalid =
false;
1638 nameInvalid =
false;
1643 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
1644 tr(
"Please enter a name for new color ramp:" ),
1645 QLineEdit::Normal, name, &ok );
1653 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1665 mFavoritesGroupVisible = show;
1671 mSmartGroupVisible = show;
1683 setWindowState( windowState() & ~Qt::WindowMinimized );
1691 if ( !rampName.isEmpty() )
1703 if ( selectedItemType() < 3 )
1707 else if ( selectedItemType() == 3 )
1711 else if ( selectedItemType() == 4 )
1715 else if ( selectedItemType() == 5 )
1717 editLabelSettings();
1719 else if ( selectedItemType() == 6 )
1721 editLegendPatchShape();
1723 else if ( selectedItemType() == 7 )
1729 Q_ASSERT(
false &&
"not implemented" );
1736 if ( symbolName.isEmpty() )
1739 std::unique_ptr< QgsSymbol > symbol( mStyle->
symbol( symbolName ) );
1743 dlg.setWindowTitle( symbolName );
1745 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1751 mStyle->
addSymbol( symbolName, symbol.release(),
true );
1759 if ( name.isEmpty() )
1762 std::unique_ptr< QgsColorRamp > ramp( mStyle->
colorRamp( name ) );
1768 dlg.setWindowTitle( name );
1770 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1782 dlg.setWindowTitle( name );
1784 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1796 dlg.setWindowTitle( name );
1798 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1810 dlg.setWindowTitle( name );
1812 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1824 dlg.setWindowTitle( name );
1826 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1843 Q_ASSERT(
false &&
"invalid ramp type" );
1851bool QgsStyleManagerDialog::editTextFormat()
1854 if ( formatName.isEmpty() )
1861 dlg.setWindowTitle( formatName );
1863 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1877 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1878 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1880 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1882 if ( !settingsDlg.exec() )
1885 settings = settingsDlg.settings();
1889 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1890 saveDlg.setDefaultTags( defaultTag );
1891 if ( !saveDlg.exec() )
1893 QString name = saveDlg.name();
1896 bool nameInvalid =
true;
1897 while ( nameInvalid )
1900 if ( name.isEmpty() )
1902 QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1903 tr(
"Cannot save label settings without a name. Enter a name." ) );
1907 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
1908 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
1910 QMessageBox::Yes | QMessageBox::No );
1911 if ( res == QMessageBox::Yes )
1914 nameInvalid =
false;
1920 nameInvalid =
false;
1925 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ),
1926 tr(
"Please enter a name for the new label settings:" ),
1927 QLineEdit::Normal, name, &ok );
1935 QStringList symbolTags = saveDlg.tags().split(
',' );
1945bool QgsStyleManagerDialog::editLabelSettings()
1948 if ( formatName.isEmpty() )
1955 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1956 dlg.setWindowTitle( formatName );
1960 settings = dlg.settings();
1973 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1975 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1977 if ( !dialog.exec() )
1980 shape = dialog.shape();
1983 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1984 saveDlg.setDefaultTags( defaultTag );
1985 if ( !saveDlg.exec() )
1987 QString name = saveDlg.name();
1990 bool nameInvalid =
true;
1991 while ( nameInvalid )
1994 if ( name.isEmpty() )
1996 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
1997 tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
2001 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
2002 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
2004 QMessageBox::Yes | QMessageBox::No );
2005 if ( res == QMessageBox::Yes )
2008 nameInvalid =
false;
2014 nameInvalid =
false;
2019 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ),
2020 tr(
"Please enter a name for the new legend patch shape:" ),
2021 QLineEdit::Normal, name, &ok );
2029 QStringList symbolTags = saveDlg.tags().split(
',' );
2039bool QgsStyleManagerDialog::editLegendPatchShape()
2042 if ( shapeName.isEmpty() )
2051 dlg.setWindowTitle( shapeName );
2055 shape = dlg.shape();
2063bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2070 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2072 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2074 if ( !dialog.exec() )
2077 symbol.reset( dialog.symbol() );
2082 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2083 saveDlg.setDefaultTags( defaultTag );
2084 if ( !saveDlg.exec() )
2086 QString name = saveDlg.name();
2089 bool nameInvalid =
true;
2090 while ( nameInvalid )
2093 if ( name.isEmpty() )
2095 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2096 tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2100 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ),
2101 tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" )
2103 QMessageBox::Yes | QMessageBox::No );
2104 if ( res == QMessageBox::Yes )
2107 nameInvalid =
false;
2113 nameInvalid =
false;
2118 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ),
2119 tr(
"Please enter a name for the new 3D symbol:" ),
2120 QLineEdit::Normal, name, &ok );
2128 QStringList symbolTags = saveDlg.tags().split(
',' );
2133 mStyle->
saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2139bool QgsStyleManagerDialog::editSymbol3D()
2142 if ( symbolName.isEmpty() )
2145 std::unique_ptr< QgsAbstract3DSymbol > symbol( mStyle->
symbol3D( symbolName ) );
2151 dlg.setWindowTitle( symbolName );
2155 symbol.reset( dlg.symbol() );
2160 mStyle->
addSymbol3D( symbolName, symbol.release(),
true );
2165void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2168 if ( initialFolder.isEmpty() )
2169 initialFolder = QDir::homePath();
2171 QString databasePath = createNew
2172 ? QFileDialog::getSaveFileName(
2174 tr(
"Create Style Database" ),
2176 tr(
"Style databases" ) +
" (*.db)" )
2177 : QFileDialog::getOpenFileName(
2179 tr(
"Add Style Database" ),
2181 tr(
"Style databases" ) +
" (*.db *.xml)" );
2185 if ( ! databasePath.isEmpty() )
2192 if ( QFile::exists( databasePath ) )
2194 QFile::remove( databasePath );
2199 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2211 const QList< ItemDetails > items = selectedItems();
2213 if ( allTypesSelected() )
2215 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ),
2216 QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ),
2225 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
2226 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ),
2233 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
2234 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ),
2241 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ),
2242 QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ),
2249 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ),
2250 QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ),
2257 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ),
2258 QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ),
2265 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ),
2266 QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ),
2275 for (
const ItemDetails &details : items )
2277 if ( details.name.isEmpty() )
2302 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
2303 QDir::home().absolutePath(),
2304 QFileDialog::DontResolveSymlinks );
2310 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
2311 QDir::home().absolutePath(),
2312 QFileDialog::DontResolveSymlinks );
2319 if ( dir.isEmpty() )
2322 const QList< ItemDetails > items = selectedItems();
2323 for (
const ItemDetails &details : items )
2328 QString path = dir +
'/' + details.name +
'.' + format;
2329 std::unique_ptr< QgsSymbol > sym( mStyle->
symbol( details.name ) );
2331 sym->exportImage( path, format, size );
2351 QFont font = item->font();
2352 font.setBold(
true );
2353 item->setFont( font );
2358 if ( mBlockGroupUpdates )
2361 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2364 const bool readOnly = isReadOnly();
2366 if ( mFavoritesGroupVisible )
2368 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2369 favoriteSymbols->setData(
"favorite" );
2370 favoriteSymbols->setEditable(
false );
2372 model->appendRow( favoriteSymbols );
2375 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2376 allSymbols->setData(
"all" );
2377 allSymbols->setEditable(
false );
2379 model->appendRow( allSymbols );
2381 QStandardItem *taggroup =
new QStandardItem( QString() );
2382 taggroup->setData(
"tags" );
2383 taggroup->setEditable(
false );
2384 QStringList tags = mStyle->
tags();
2386 for (
const QString &tag : std::as_const( tags ) )
2388 QStandardItem *item =
new QStandardItem( tag );
2389 item->setData( mStyle->
tagId( tag ) );
2390 item->setData( tag, GroupModelRoles::TagName );
2391 item->setEditable( !readOnly );
2392 taggroup->appendRow( item );
2394 taggroup->setText( tr(
"Tags" ) );
2396 model->appendRow( taggroup );
2398 if ( mSmartGroupVisible )
2400 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2401 smart->setData(
"smartgroups" );
2402 smart->setEditable(
false );
2405 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2406 while ( i != sgMap.constEnd() )
2408 QStandardItem *item =
new QStandardItem( i.value() );
2409 item->setData( i.key() );
2410 item->setEditable( !readOnly );
2411 smart->appendRow( item );
2414 model->appendRow( smart );
2418 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2419 for (
int i = 0; i < rows; i++ )
2421 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2427 const QString category = index.data( Qt::UserRole + 1 ).toString();
2428 sPreviousTag = category;
2430 const bool readOnly = isReadOnly();
2432 if ( mGroupingMode && mModel )
2434 mModel->setTagId( -1 );
2435 mModel->setSmartGroupId( -1 );
2436 mModel->setFavoritesOnly(
false );
2437 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2439 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2442 if ( category == QLatin1String(
"tags" ) )
2444 actnAddTag->setEnabled( !readOnly );
2445 actnAddSmartgroup->setEnabled(
false );
2447 else if ( category == QLatin1String(
"smartgroups" ) )
2449 actnAddTag->setEnabled(
false );
2450 actnAddSmartgroup->setEnabled( !readOnly );
2455 mModel->setTagId( -1 );
2456 mModel->setSmartGroupId( -1 );
2457 mModel->setFavoritesOnly(
false );
2460 else if ( category == QLatin1String(
"favorite" ) )
2463 mModel->setTagId( -1 );
2464 mModel->setSmartGroupId( -1 );
2465 mModel->setFavoritesOnly(
true );
2467 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2469 actnRemoveGroup->setEnabled( !readOnly );
2470 btnManageGroups->setEnabled( !readOnly );
2471 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2474 mModel->setTagId( -1 );
2475 mModel->setSmartGroupId( groupId );
2476 mModel->setFavoritesOnly(
false );
2482 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2485 mModel->setTagId( tagId );
2486 mModel->setSmartGroupId( -1 );
2487 mModel->setFavoritesOnly(
false );
2491 actnEditSmartGroup->setVisible(
false );
2492 actnAddTag->setVisible(
false );
2493 actnAddSmartgroup->setVisible(
false );
2494 actnRemoveGroup->setVisible(
false );
2495 actnTagSymbols->setVisible(
false );
2496 actnFinishTagging->setVisible(
false );
2498 if ( index.parent().isValid() )
2500 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2502 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2504 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2506 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2507 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2508 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2510 actnRemoveGroup->setVisible( !readOnly );
2512 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2514 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2516 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2518 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2527 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2529 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2531 index = groupTree->model()->index( i, 0 );
2532 QString data = index.data( Qt::UserRole + 1 ).toString();
2533 if ( data == QLatin1String(
"tags" ) )
2542 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
2543 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2544 if ( !ok || itemName.isEmpty() )
2547 int check = mStyle->
tagId( itemName );
2550 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2556 mBlockGroupUpdates++;
2557 id = mStyle->
addTag( itemName );
2558 mBlockGroupUpdates--;
2562 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2566 QStandardItem *parentItem = model->itemFromIndex( index );
2567 QStandardItem *childItem =
new QStandardItem( itemName );
2568 childItem->setData(
id );
2569 childItem->setData( itemName, GroupModelRoles::TagName );
2570 parentItem->appendRow( childItem );
2580 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2582 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2584 index = groupTree->model()->index( i, 0 );
2585 QString data = index.data( Qt::UserRole + 1 ).toString();
2586 if ( data == QLatin1String(
"smartgroups" ) )
2595 if ( dlg.exec() == QDialog::Rejected )
2600 mBlockGroupUpdates++;
2602 mBlockGroupUpdates--;
2608 QStandardItem *parentItem = model->itemFromIndex( index );
2609 QStandardItem *childItem =
new QStandardItem( itemName );
2610 childItem->setData(
id );
2611 parentItem->appendRow( childItem );
2621 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2622 QModelIndex index = groupTree->currentIndex();
2625 QString data = index.data( Qt::UserRole + 1 ).toString();
2626 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2629 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
2630 tr(
"Invalid selection. Cannot delete system defined categories.\n"
2631 "Kindly select a group or smart group you might want to delete." ) );
2636 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2640 mBlockGroupUpdates++;
2642 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2651 mBlockGroupUpdates--;
2652 parentItem->removeRow( index.row() );
2660 QgsDebugMsgLevel( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2661 int id = item->data( Qt::UserRole + 1 ).toInt();
2662 QString name = item->text();
2663 mBlockGroupUpdates++;
2664 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2672 mBlockGroupUpdates--;
2680 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2682 if ( mGroupingMode )
2684 mGroupingMode =
false;
2685 mModel->setCheckable(
false );
2686 actnTagSymbols->setVisible(
true );
2687 actnFinishTagging->setVisible(
false );
2695 connect( treeModel, &QStandardItemModel::itemChanged,
2699 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2700 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2704 bool validGroup =
false;
2706 QModelIndex present = groupTree->currentIndex();
2707 while ( present.parent().isValid() )
2709 if ( present.parent().data() ==
"Tags" )
2714 present = present.parent();
2719 mGroupingMode =
true;
2721 actnTagSymbols->setVisible(
false );
2722 actnFinishTagging->setVisible(
true );
2724 disconnect( treeModel, &QStandardItemModel::itemChanged,
2730 btnManageGroups->setEnabled(
true );
2732 mModel->setCheckable(
true );
2735 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2736 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2750 mModel->setFilterString( qword );
2755 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2760 Q_UNUSED( selected )
2761 Q_UNUSED( deselected )
2762 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2763 const bool readOnly = isReadOnly();
2764 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2765 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2766 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2767 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2768 actnDetag->setDisabled( nothingSelected || readOnly );
2769 actnExportAsPNG->setDisabled( nothingSelected );
2770 actnExportAsSVG->setDisabled( nothingSelected );
2771 if ( mActionCopyToDefault )
2772 mActionCopyToDefault->setDisabled( nothingSelected );
2773 mCopyToDefaultButton->setDisabled( nothingSelected );
2774 actnEditItem->setDisabled( nothingSelected || readOnly );
2779 const bool readOnly = isReadOnly();
2780 groupTree->setEnabled( enable );
2781 btnAddTag->setEnabled( enable && !readOnly );
2782 btnAddSmartgroup->setEnabled( enable && !readOnly );
2783 actnAddTag->setEnabled( enable && !readOnly );
2784 actnAddSmartgroup->setEnabled( enable && !readOnly );
2785 actnRemoveGroup->setEnabled( enable && !readOnly );
2786 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2787 searchBox->setEnabled( enable );
2792 const bool readOnly = isReadOnly();
2793 actnRemoveGroup->setEnabled( enable && !readOnly );
2794 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2799 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2800 for (
int i = 0; i < treeModel->rowCount(); i++ )
2802 treeModel->item( i )->setEnabled( enable );
2804 if ( treeModel->item( i )->data() ==
"smartgroups" )
2806 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2808 treeModel->item( i )->child( j )->setEnabled( enable );
2815 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2817 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2819 w->setEnabled( enable );
2823 actnRemoveItem->setEnabled( enable );
2824 actnEditItem->setEnabled( enable );
2825 mActionCopyItem->setEnabled( enable );
2826 mActionPasteItem->setEnabled( enable );
2831 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2833 QModelIndex index = groupTree->indexAt( point );
2834 if ( index.isValid() && !mGroupingMode )
2835 mGroupTreeContextMenu->popup( globalPos );
2840 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2841 ? listItems->viewport()->mapToGlobal( point )
2842 : mSymbolTreeView->viewport()->mapToGlobal( point );
2845 mGroupListMenu->clear();
2847 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2849 if ( !isReadOnly() )
2851 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
static_cast< int >(
QgsStyleModel::CustomRole::Tag ) ).toStringList() : QStringList();
2852 QAction *a =
nullptr;
2853 QStringList tags = mStyle->
tags();
2855 for (
const QString &tag : std::as_const( tags ) )
2857 a =
new QAction( tag, mGroupListMenu );
2859 if ( indices.count() == 1 )
2861 a->setCheckable(
true );
2862 a->setChecked( currentTags.contains( tag ) );
2866 mGroupListMenu->addAction( a );
2869 if ( tags.count() > 0 )
2871 mGroupListMenu->addSeparator();
2873 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2876 mGroupListMenu->addAction( a );
2879 const QList< ItemDetails > items = selectedItems();
2882 bool enablePaste =
false;
2890 mActionPasteItem->setEnabled( enablePaste );
2892 mGroupMenu->popup( globalPos );
2900 const QList< ItemDetails > items = selectedItems();
2901 for (
const ItemDetails &details : items )
2903 mStyle->
addFavorite( details.entityType, details.name );
2912 const QList< ItemDetails > items = selectedItems();
2913 for (
const ItemDetails &details : items )
2921 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2924 const QList< ItemDetails > items = selectedItems();
2934 tag = mStyle->
tag(
id );
2938 tag = selectedItem->data().toString();
2941 for (
const ItemDetails &details : items )
2943 mStyle->
tagSymbol( details.entityType, details.name, QStringList( tag ) );
2953 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2957 const QList< ItemDetails > items = selectedItems();
2958 for (
const ItemDetails &details : items )
2960 mStyle->
detagSymbol( details.entityType, details.name );
2970 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2973 QModelIndex present = groupTree->currentIndex();
2974 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2977 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
2978 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2981 QStandardItem *item = treeModel->itemFromIndex( present );
2989 if ( dlg.exec() == QDialog::Rejected )
2992 mBlockGroupUpdates++;
2995 mBlockGroupUpdates--;
2998 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
3002 item->setData(
id );
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
static const double UI_SCALE_FACTOR
UI scaling factor.
A dialog for configuring a 3D symbol.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp.
QgsColorBrewerColorRamp ramp
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Color ramp utilising "Color Brewer" preset color schemes.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
Abstract base class for color ramps.
static QList< QPair< QString, QString > > rampTypes()
Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type(...
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
A color ramp from the CPT City collection.
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
QgsGradientColorRamp * cloneGradientRamp() const
QString schemeName() const
QString variantName() const
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsGradientColorRamp ramp
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconPoint()
Returns an icon representing point geometries.
A dialog for configuring a custom legend patch shape.
Represents a patch shape for use in map legends.
bool isNull() const
Returns true if the patch shape is a null QgsLegendPatchShape, which indicates that the default legen...
A dialog which allows users to modify the properties of a QgsLimitedRandomColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsLimitedRandomColorRamp ramp
Constrained random color ramp, which returns random colors based on preset parameters.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
A bar for displaying non-blocking messages to the user.
Contains settings for how a map layer will be labeled.
Qgis::GeometryType layerType
Geometry type of layers associated with these settings.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
A dialog which allows users to modify the properties of a QgsPresetSchemeColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsPresetSchemeColorRamp ramp
A scheme based color ramp consisting of a list of predefined colors.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp.
List model representing the style databases associated with a QgsProject.
void setShowDefaultStyle(bool show)
Sets whether the default style should also be included in the model.
QModelIndex indexFromStyle(QgsStyle *style) const
Returns the model index corresponding to a style.
QgsStyle * styleFromIndex(const QModelIndex &index) const
Returns the style at the corresponding index.
void addStyleDatabasePath(const QString &path)
Adds a style database path to the project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
Stores properties relating to a screen.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap
QgsSmartConditionMap conditionMap()
returns the condition map
QString smartgroupName()
returns the value from mNameLineEdit
void setSmartgroupName(const QString &)
sets the smart group Name
void setOperator(const QString &)
sets the operator AND/OR
QString conditionOperator()
returns the AND/OR condition
@ Export
Export existing symbols mode.
@ Import
Import xml file mode.
Q_DECL_DEPRECATED bool removeSymbol()
void onClose()
Closes the dialog.
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed.
static const QgsSettingsEntryString * settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
void addFavoriteSelectedSymbols()
Add selected symbols to favorites.
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change.
void removeGroup()
Removes the selected tag or smartgroup.
void exportItems()
Triggers the dialog to export items.
void setFavoritesGroupVisible(bool show)
Sets whether the favorites group should be shown.
void grouptreeContextMenu(QPoint)
Context menu for the groupTree.
void setBold(QStandardItem *)
sets the text of the item with bold font
void filterSymbols(const QString &filter)
Sets the filter string to filter symbols by.
void addItem()
Triggers the dialog for adding a new item, based on the currently selected item type tab.
void tagSymbolsAction()
Toggles the interactive item tagging mode.
void editSmartgroupAction()
Triggers the dialog for editing the selected smart group.
void showHelp()
Opens the associated help.
void detagSelectedSymbols()
Remove all tags from selected symbols.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
bool addSymbol(int symbolType=-1)
add a new symbol to style
Q_DECL_DEPRECATED void populateTypes()
Populate combo box with known style items (symbols, color ramps).
void populateList()
Refreshes the list of items.
void removeItem()
Removes the current selected item.
void groupChanged(const QModelIndex &)
Triggered when the current group (or tag) is changed.
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), bool readOnly=false)
Constructor for QgsStyleManagerDialog, with the specified parent widget and window flags.
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.
int addTag()
Triggers the dialog to add a new tag.
void exportItemsSVG()
Triggers the dialog to export selected items as SVG files.
Q_DECL_DEPRECATED void populateSymbols(const QStringList &symbolNames, bool checkable=false)
Populates the list view with symbols of the current type with the given names.
void populateGroups()
populate the groups
Q_DECL_DEPRECATED bool removeColorRamp()
void importItems()
Triggers the dialog to import items.
void setBaseStyleName(const QString &name)
Sets the base name for the style, which is used by the dialog to reflect the original style/XML file ...
Q_DECL_DEPRECATED void regrouped(QStandardItem *)
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item)
void exportItemsPNG()
Triggers the dialog to export selected items as PNG files.
void activate()
Raises, unminimizes and activates this window.
bool addColorRamp(const QString &type=QString())
Triggers adding a new color ramp.
void exportSelectedItemsImages(const QString &dir, const QString &format, QSize size)
Triggers the dialog to export selected items as images of the specified format and size.
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode.
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &)
void onFinished()
Called when the dialog is going to be closed.
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list )
void setSmartGroupsVisible(bool show)
Sets whether smart groups should be shown.
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, const QString &RampType=QString())
Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added.
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
void editItem()
Triggers the dialog for editing the current item.
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites.
int addSmartgroup()
Triggers the dialog to add a new smart group.
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection.
QString currentItemName()
Q_DECL_DEPRECATED void populateColorRamps(const QStringList &colorRamps, bool checkable=false)
Populates the list view with color ramps of the current type with the given names.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ SymbolType
Symbol type (for symbol or legend patch shape entities)
@ Type
Style entity type, see QgsStyle::StyleEntity.
@ Tag
String list of tags.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
a dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
bool saveColorRamp(const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the database.
bool detagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Detags the symbol with the given list.
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QgsLegendPatchShape defaultPatch(Qgis::SymbolType type, QSizeF size) const
Returns the default legend patch shape for the given symbol type.
bool remove(StyleEntity type, int id)
Removes the specified entity from the database.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
bool removeLabelSettings(const QString &name)
Removes label settings from the style.
QStringList tags() const
Returns a list of all tags in the style database.
QString tag(int id) const
Returns the tag name for the given id.
QgsSmartConditionMap smartgroup(int id)
Returns the QgsSmartConditionMap for the given id.
QStringList symbol3DNames() const
Returns a list of names of 3d symbols in the style.
bool tagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Tags the symbol with the tags in the list.
bool saveLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
Adds label settings to the database.
void symbolSaved(const QString &name, QgsSymbol *symbol)
Emitted every time a new symbol has been added to the database.
void aboutToBeDestroyed()
Emitted just before the style object is destroyed.
bool createDatabase(const QString &filename)
Creates an on-disk database.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape.
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
int addSmartgroup(const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
Adds a new smartgroup to the database and returns the id.
QStringList colorRampNames() const
Returns a list of names of color ramps.
bool addSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool update=false)
Adds a 3d symbol with the specified name to the style.
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the style.
bool removeEntityByName(StyleEntity type, const QString &name)
Removes the entry of the specified type with matching name from the database.
int tagId(const QString &tag)
Returns the database id for the given tag name.
bool isReadOnly() const
Returns true if the style is considered a read-only library.
bool addLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool update=false)
Adds a legend patch shape with the specified name to the style.
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style.
bool rename(StyleEntity type, int id, const QString &newName)
Renames the given entity with the specified id.
bool removeFavorite(StyleEntity type, const QString &name)
Removes the specified symbol from favorites.
QgsSymbolGroupMap smartgroupsListMap()
Returns the smart groups map with id as key and name as value.
bool saveLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
Adds a legend patch shape to the database.
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
bool saveSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool favorite, const QStringList &tags)
Adds a 3d symbol to the database.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
QgsAbstract3DSymbol * symbol3D(const QString &name) const
Returns a new copy of the 3D symbol with the specified name.
int addTag(const QString &tagName)
Adds a new tag and returns the tag's id.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QgsLegendPatchShape legendPatchShape(const QString &name) const
Returns the legend patch shape with the specified name.
QStringList symbolNames() const
Returns a list of names of symbols.
bool addFavorite(StyleEntity type, const QString &name)
Adds the specified symbol to favorites.
QString smartgroupOperator(int id)
Returns the operator for the smartgroup.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
bool addLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool update=false)
Adds label settings with the specified name to the style.
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
A dialog that can be used to select and build a symbol.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Abstract base class for all rendered symbols.
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
A simple dialog for customizing text formatting settings.
Container for all settings relating to text rendering.
static QgsTextFormat fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsTextFormat.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QMap< int, QString > QgsSymbolGroupMap