36 #include <QFileDialog> 37 #include <QInputDialog> 38 #include <QMessageBox> 39 #include <QPushButton> 40 #include <QStandardItemModel> 52 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
57 setWindowModality( Qt::WindowModal );
62 restoreGeometry( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/geometry" ) ).toByteArray() );
63 mSplitter->setSizes( QList<int>() << 170 << 540 );
64 mSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).toByteArray() );
66 tabItemType->setDocumentMode(
true );
67 searchBox->setShowSearchIcon(
true );
68 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
74 connect( btnAddItem, &QPushButton::clicked,
this, [ = ](
bool ) {
addItem(); }
76 connect( btnEditItem, &QPushButton::clicked,
this, [ = ](
bool ) {
editItem(); }
78 connect( actnEditItem, &QAction::triggered,
this, [ = ](
bool ) {
editItem(); }
80 connect( btnRemoveItem, &QPushButton::clicked,
this, [ = ](
bool ) {
removeItem(); }
82 connect( actnRemoveItem, &QAction::triggered,
this, [ = ](
bool ) {
removeItem(); }
85 QMenu *shareMenu =
new QMenu( tr(
"Share Menu" ),
this );
86 QAction *exportAction =
new QAction( tr(
"Export Symbol(s)…" ),
this );
88 shareMenu->addAction( exportAction );
89 QAction *importAction =
new QAction( tr(
"Import Symbol(s)…" ),
this );
91 shareMenu->addAction( importAction );
92 shareMenu->addSeparator();
93 shareMenu->addAction( actnExportAsPNG );
94 shareMenu->addAction( actnExportAsSVG );
99 btnShare->setMenu( shareMenu );
104 QStandardItemModel *model =
new QStandardItemModel( listItems );
105 listItems->setModel( model );
106 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
109 connect( listItems->selectionModel(), &QItemSelectionModel::currentChanged,
111 connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
116 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
117 groupTree->setModel( groupModel );
118 groupTree->setHeaderHidden(
true );
120 groupTree->setCurrentIndex( groupTree->model()->index( 0, 0 ) );
122 connect( groupTree->selectionModel(), &QItemSelectionModel::currentChanged,
124 connect( groupModel, &QStandardItemModel::itemChanged,
127 QMenu *groupMenu =
new QMenu( tr(
"Group actions" ),
this );
129 groupMenu->addAction( actnTagSymbols );
131 actnFinishTagging->setVisible(
false );
132 groupMenu->addAction( actnFinishTagging );
133 groupMenu->addAction( actnEditSmartGroup );
134 btnManageGroups->setMenu( groupMenu );
139 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
140 connect( groupTree, &QWidget::customContextMenuRequested,
144 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
145 connect( listItems, &QWidget::customContextMenuRequested,
149 QStringList rampTypes;
150 rampTypes << tr(
"Gradient" ) << tr(
"Color presets" ) << tr(
"Random" ) << tr(
"Catalog: cpt-city" );
151 rampTypes << tr(
"Catalog: ColorBrewer" );
153 Q_FOREACH (
const QString &rampType, rampTypes )
164 mGroupMenu->addSeparator()->setParent(
this );
169 actnDetag->setData( 0 );
172 mGroupMenu->addSeparator()->setParent(
this );
175 mGroupMenu->addSeparator()->setParent(
this );
183 connect( actnAddTag, &QAction::triggered,
this, [ = ](
bool ) {
addTag(); }
186 connect( actnAddSmartgroup, &QAction::triggered,
this, [ = ](
bool ) {
addSmartgroup(); }
192 tabItemType_currentChanged( 0 );
204 settings.
setValue( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
211 int current = ( tabItemType->count() > 0 ? tabItemType->currentIndex() : 0 );
214 int markerCount = 0, lineCount = 0, fillCount = 0;
217 for (
int i = 0; i < symbolNames.count(); ++i )
231 Q_ASSERT( 0 &&
"unknown symbol type" );
236 cboItemType->clear();
237 cboItemType->addItem( tr(
"Marker symbol (%1)" ).arg( markerCount ), QVariant(
QgsSymbol::Marker ) );
238 cboItemType->addItem( tr(
"Line symbol (%1)" ).arg( lineCount ), QVariant(
QgsSymbol::Line ) );
239 cboItemType->addItem( tr(
"Fill symbol (%1)" ).arg( fillCount ), QVariant(
QgsSymbol::Fill ) );
244 cboItemType->setCurrentIndex( current );
248 void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
252 searchBox->setPlaceholderText( flag ? tr(
"Filter symbols…" ) : tr(
"Filter color ramps…" ) );
254 actnExportAsPNG->setVisible( flag );
255 actnExportAsSVG->setVisible( flag );
257 listItems->setIconSize( QSize( 100, 90 ) );
258 listItems->setGridSize( QSize( 120, 110 ) );
267 Q_ASSERT(
false &&
"not implemented" );
270 groupChanged( groupTree->selectionModel()->currentIndex() );
275 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
279 for (
int i = 0; i < symbolNames.count(); ++i )
281 QString name = symbolNames[i];
283 if ( symbol && symbol->
type() == type )
286 QStandardItem *item =
new QStandardItem( name );
288 item->setIcon( icon );
289 item->setData( name );
290 item->setCheckable( check );
291 item->setToolTip( QStringLiteral(
"<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( QStringLiteral(
", " ) ) : tr(
"Not tagged" ) ) );
293 model->appendRow( item );
304 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
307 for (
int i = 0; i < colorRamps.count(); ++i )
309 QString name = colorRamps[i];
312 QStandardItem *item =
new QStandardItem( name );
314 item->setIcon( icon );
315 item->setData( name );
316 item->setCheckable( check );
317 item->setToolTip( name );
318 model->appendRow( item );
326 switch ( tabItemType->currentIndex() )
343 QModelIndex index = listItems->selectionModel()->currentIndex();
344 if ( !index.isValid() )
346 return index.model()->data( index, 0 ).toString();
351 bool changed =
false;
362 Q_ASSERT(
false &&
"not implemented" );
376 QString name = tr(
"new symbol" );
381 name = tr(
"new marker" );
385 name = tr(
"new line" );
389 name = tr(
"new fill symbol" );
392 Q_ASSERT(
false &&
"unknown symbol type" );
402 if ( dlg.exec() == 0 )
409 if ( !saveDlg.exec() )
415 name = saveDlg.
name();
418 bool nameInvalid =
true;
419 while ( nameInvalid )
422 if ( name.isEmpty() )
424 QMessageBox::warning(
this, tr(
"Save Symbol" ),
425 tr(
"Cannot save symbol without name. Enter a name." ) );
429 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
430 tr(
"Symbol with name '%1' already exists. Overwrite?" )
432 QMessageBox::Yes | QMessageBox::No );
433 if ( res == QMessageBox::Yes )
447 name = QInputDialog::getText(
this, tr(
"Symbol Name" ),
448 tr(
"Please enter a name for new symbol:" ),
449 QLineEdit::Normal, name, &ok );
458 QStringList symbolTags = saveDlg.
tags().split(
',' );
473 if ( rampType.isEmpty() )
475 QStringList rampTypes;
476 rampTypes << tr(
"Gradient" ) << tr(
"Color presets" ) << tr(
"Random" ) << tr(
"Catalog: cpt-city" );
477 rampTypes << tr(
"Catalog: ColorBrewer" );
478 rampType = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ),
479 tr(
"Please select color ramp type:" ), rampTypes, 0,
false, &ok );
481 if ( !ok || rampType.isEmpty() )
484 QString name = tr(
"new ramp" );
486 std::unique_ptr< QgsColorRamp > ramp;
487 if ( rampType == tr(
"Gradient" ) )
495 name = tr(
"new gradient ramp" );
497 else if ( rampType == tr(
"Random" ) )
505 name = tr(
"new random ramp" );
507 else if ( rampType == tr(
"Catalog: ColorBrewer" ) )
517 else if ( rampType == tr(
"Color presets" ) )
525 name = tr(
"new preset ramp" );
527 else if ( rampType == tr(
"Catalog: cpt-city" ) )
554 if ( !saveDlg.exec() )
559 name = saveDlg.
name();
562 bool nameInvalid =
true;
563 while ( nameInvalid )
566 if ( name.isEmpty() )
568 QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
569 tr(
"Cannot save color ramp without name. Enter a name." ) );
573 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ),
574 tr(
"Color ramp with name '%1' already exists. Overwrite?" )
576 QMessageBox::Yes | QMessageBox::No );
577 if ( res == QMessageBox::Yes )
590 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ),
591 tr(
"Please enter a name for new color ramp:" ),
592 QLineEdit::Normal, name, &ok );
600 QStringList colorRampTags = saveDlg.
tags().split(
',' );
620 action ? action->text() : QString() );
621 if ( !rampName.isEmpty() )
633 bool changed =
false;
644 Q_ASSERT(
false &&
"not implemented" );
654 if ( symbolName.isEmpty() )
661 if ( dlg.exec() == 0 )
676 if ( name.isEmpty() )
681 if ( ramp->type() == QLatin1String(
"gradient" ) )
691 else if ( ramp->type() == QLatin1String(
"random" ) )
701 else if ( ramp->type() == QLatin1String(
"colorbrewer" ) )
711 else if ( ramp->type() == QLatin1String(
"preset" ) )
721 else if ( ramp->type() == QLatin1String(
"cpt-city" ) )
740 Q_ASSERT(
false &&
"invalid ramp type" );
751 bool changed =
false;
762 Q_ASSERT(
false &&
"not implemented" );
774 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
775 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ),
776 QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, indexes.count() ) ),
781 Q_FOREACH (
const QModelIndex &index, indexes )
783 QString symbolName = index.data().toString();
785 if ( !symbolName.isEmpty() )
794 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
795 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
796 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, indexes.count() ) ),
801 Q_FOREACH (
const QModelIndex &index, indexes )
803 QString rampName = index.data().toString();
805 if ( !rampName.isEmpty() )
815 QString oldName = item->data().toString();
817 bool changed =
false;
834 QMessageBox::critical(
this, tr(
"Save Item" ),
835 tr(
"Name is already taken by another item. Choose a different name." ) );
836 item->setText( oldName );
842 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
843 QDir::home().absolutePath(),
844 QFileDialog::ShowDirsOnly
845 | QFileDialog::DontResolveSymlinks );
851 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
852 QDir::home().absolutePath(),
853 QFileDialog::ShowDirsOnly
854 | QFileDialog::DontResolveSymlinks );
864 QModelIndexList indexes = listItems->selectionModel()->selection().indexes();
865 Q_FOREACH (
const QModelIndex &index, indexes )
867 QString name = index.data().toString();
868 QString path = dir +
'/' + name +
'.' + format;
890 QFont font = item->font();
891 font.setBold(
true );
892 item->setFont( font );
897 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
900 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
901 favoriteSymbols->setData(
"favorite" );
902 favoriteSymbols->setEditable(
false );
904 model->appendRow( favoriteSymbols );
906 QStandardItem *allSymbols =
new QStandardItem( tr(
"All Symbols" ) );
907 allSymbols->setData(
"all" );
908 allSymbols->setEditable(
false );
910 model->appendRow( allSymbols );
912 QStandardItem *taggroup =
new QStandardItem( QLatin1String(
"" ) );
913 taggroup->setData(
"tags" );
914 taggroup->setEditable(
false );
917 Q_FOREACH (
const QString &tag, tags )
919 QStandardItem *item =
new QStandardItem( tag );
921 taggroup->appendRow( item );
923 taggroup->setText( tr(
"Tags" ) );
925 model->appendRow( taggroup );
927 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
928 smart->setData(
"smartgroups" );
929 smart->setEditable(
false );
932 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
933 while ( i != sgMap.constEnd() )
935 QStandardItem *item =
new QStandardItem( i.value() );
936 item->setData( i.key() );
937 smart->appendRow( item );
940 model->appendRow( smart );
943 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
944 for (
int i = 0; i < rows; i++ )
946 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
952 QStringList symbolNames;
953 QStringList groupSymbols;
962 QString category = index.data( Qt::UserRole + 1 ).toString();
963 if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
966 if ( category == QLatin1String(
"tags" ) )
968 actnAddTag->setEnabled(
true );
969 actnAddSmartgroup->setEnabled(
false );
971 else if ( category == QLatin1String(
"smartgroups" ) )
973 actnAddTag->setEnabled(
false );
974 actnAddSmartgroup->setEnabled(
true );
978 else if ( category == QLatin1String(
"favorite" ) )
983 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
985 actnRemoveGroup->setEnabled(
true );
986 btnManageGroups->setEnabled(
true );
987 int groupId = index.data( Qt::UserRole + 1 ).toInt();
993 int tagId = index.data( Qt::UserRole + 1 ).toInt();
997 groupSymbols = symbolNames;
1017 actnEditSmartGroup->setVisible(
false );
1018 actnAddTag->setVisible(
false );
1019 actnAddSmartgroup->setVisible(
false );
1020 actnRemoveGroup->setVisible(
false );
1021 actnTagSymbols->setVisible(
false );
1022 actnFinishTagging->setVisible(
false );
1024 if ( index.parent().isValid() )
1026 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
1030 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
1036 actnRemoveGroup->setVisible(
true );
1038 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
1042 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
1050 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1052 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
1054 index = groupTree->model()->index( i, 0 );
1055 QString data = index.data( Qt::UserRole + 1 ).toString();
1056 if ( data == QLatin1String(
"tags" ) )
1065 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
1066 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
1067 if ( !ok || itemName.isEmpty() )
1073 QMessageBox::critical(
this, tr(
"Add Tag" ),
1074 tr(
"Tag name already exists in your symbol database." ) );
1080 QMessageBox::critical(
this, tr(
"Add Tag" ),
1081 tr(
"New tag could not be created.\n" 1082 "There was a problem with your symbol database." ) );
1086 QStandardItem *parentItem = model->itemFromIndex( index );
1087 QStandardItem *childItem =
new QStandardItem( itemName );
1088 childItem->setData(
id );
1089 parentItem->appendRow( childItem );
1096 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1098 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
1100 index = groupTree->model()->index( i, 0 );
1101 QString data = index.data( Qt::UserRole + 1 ).toString();
1102 if ( data == QLatin1String(
"smartgroups" ) )
1111 if ( dlg.exec() == QDialog::Rejected )
1118 QStandardItem *parentItem = model->itemFromIndex( index );
1119 QStandardItem *childItem =
new QStandardItem( itemName );
1120 childItem->setData(
id );
1121 parentItem->appendRow( childItem );
1128 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1129 QModelIndex index = groupTree->currentIndex();
1132 QString data = index.data( Qt::UserRole + 1 ).toString();
1133 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
1135 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
1136 tr(
"Invalid selection. Cannot delete system defined categories.\n" 1137 "Kindly select a group or smart group you might want to delete." ) );
1142 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
1143 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
1151 parentItem->removeRow( index.row() );
1156 QgsDebugMsg(
"Symbol group edited: data=" + item->data( Qt::UserRole + 1 ).toString() +
" text=" + item->text() );
1157 int id = item->data( Qt::UserRole + 1 ).toInt();
1158 QString name = item->text();
1159 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
1172 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1173 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
1178 actnTagSymbols->setVisible(
true );
1179 actnFinishTagging->setVisible(
false );
1181 disconnect( model, &QStandardItemModel::itemChanged,
1189 connect( treeModel, &QStandardItemModel::itemChanged,
1191 connect( model, &QStandardItemModel::itemChanged,
1194 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
1198 bool validGroup =
false;
1200 QModelIndex present = groupTree->currentIndex();
1201 while ( present.parent().isValid() )
1203 if ( present.parent().data() ==
"Tags" )
1208 present = present.parent();
1215 actnTagSymbols->setVisible(
false );
1216 actnFinishTagging->setVisible(
true );
1218 disconnect( treeModel, &QStandardItemModel::itemChanged,
1220 disconnect( model, &QStandardItemModel::itemChanged,
1226 btnManageGroups->setEnabled(
true );
1230 connect( model, &QStandardItemModel::itemChanged,
1234 listItems->setSelectionMode( QAbstractItemView::NoSelection );
1247 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1248 QString tag = treeModel->itemFromIndex( groupTree->currentIndex() )->text();
1250 QString symbolName = item->text();
1252 if ( item->checkState() == Qt::Checked )
1253 regrouped =
mStyle->
tagSymbol( type, symbolName, QStringList( tag ) );
1258 int er = QMessageBox::critical(
this, tr(
"Group Items" ),
1259 tr(
"There was a problem with the symbols database while regrouping." ) );
1268 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
1269 Q_FOREACH (
const QString &symbol, symbols )
1271 QList<QStandardItem *> items = model->findItems( symbol );
1272 Q_FOREACH ( QStandardItem *item, items )
1273 item->setCheckState( Qt::Checked );
1299 Q_UNUSED( selected );
1300 Q_UNUSED( deselected );
1301 bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
1302 actnRemoveItem->setDisabled( nothingSelected );
1303 actnAddFavorite->setDisabled( nothingSelected );
1304 actnRemoveFavorite->setDisabled( nothingSelected );
1306 actnDetag->setDisabled( nothingSelected );
1307 actnExportAsPNG->setDisabled( nothingSelected );
1308 actnExportAsSVG->setDisabled( nothingSelected );
1309 actnEditItem->setDisabled( nothingSelected );
1314 groupTree->setEnabled( enable );
1315 btnAddTag->setEnabled( enable );
1316 btnAddSmartgroup->setEnabled( enable );
1317 actnAddTag->setEnabled( enable );
1318 actnAddSmartgroup->setEnabled( enable );
1319 actnRemoveGroup->setEnabled( enable );
1321 searchBox->setEnabled( enable );
1326 actnRemoveGroup->setEnabled( enable );
1332 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1333 for (
int i = 0; i < treeModel->rowCount(); i++ )
1335 treeModel->item( i )->setEnabled( enable );
1337 if ( treeModel->item( i )->data() ==
"smartgroups" )
1339 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
1341 treeModel->item( i )->child( j )->setEnabled( enable );
1348 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
1350 QWidget *w = qobject_cast<QWidget *>( symbolBtnsLayout->itemAt( i )->widget() );
1352 w->setEnabled( enable );
1356 actnRemoveItem->setEnabled( enable );
1357 actnEditItem->setEnabled( enable );
1362 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
1364 QModelIndex index = groupTree->indexAt( point );
1365 QgsDebugMsg(
"Now you clicked: " + index.data().toString() );
1373 QPoint globalPos = listItems->viewport()->mapToGlobal( point );
1378 QAction *a =
nullptr;
1381 Q_FOREACH (
const QString &tag, tags )
1390 if ( tags.count() > 0 )
1411 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1412 Q_FOREACH (
const QModelIndex &index, indexes )
1428 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1429 Q_FOREACH (
const QModelIndex &index, indexes )
1438 QAction *selectedItem = qobject_cast<QAction *>( sender() );
1461 tag = selectedItem->data().toString();
1464 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1465 Q_FOREACH (
const QModelIndex &index, indexes )
1467 mStyle->
tagSymbol( type, index.data().toString(), QStringList( tag ) );
1471 QgsDebugMsg(
"Selected Action: " + selectedItem->text() );
1477 QAction *selectedItem = qobject_cast<QAction *>( sender() );
1487 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1488 Q_FOREACH (
const QModelIndex &index, indexes )
1494 QgsDebugMsg(
"Selected Action: " + selectedItem->text() );
1500 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1503 QModelIndex present = groupTree->currentIndex();
1504 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
1506 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
1507 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
1510 QStandardItem *item = treeModel->itemFromIndex( present );
1518 if ( dlg.exec() == QDialog::Rejected )
1525 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
1526 tr(
"There was some error while editing the smart group." ) );
1530 item->setData(
id );
1542 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/style_library.html#the-style-manager" ) );
void groupChanged(const QModelIndex &)
void tagSymbolsAction()
carry out symbol tagging using check boxes
QMenu * mGroupMenu
Context menu for the symbols/colorramps.
QString tags() const
returns the text value of the tags element
void populateTypes()
populate combo box with known style items (symbols, color ramps)
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
void setBold(QStandardItem *)
sets the text of the item with bold font
bool save(QString filename=QString())
Saves style into a file (will use current filename if empty string is passed)
bool mGrouppingMode
Mode to display the symbol list.
bool addSymbol()
add a new symbol to style
a dialog for setting properties of a newly saved style.
This class is a composition of two QSettings instances:
QStringList symbolsWithTag(StyleEntity type, int tagid) const
Returns the symbol names with which have the given tag.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
void populateList()
adds symbols of some type to list
void onFinished()
called when the dialog is going to be closed
QgsSmartConditionMap conditionMap()
returns the condition map
int addSmartgroup()
add a smartgroup
void setSymbolsChecked(const QStringList &)
to set symbols checked when in editing mode
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change.
void remove(StyleEntity type, int id)
Removes the specified entity from the db.
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
QString name() const
returns the text value of the name element
Abstract base class for color ramps.
QMap< int, QString > QgsSymbolGroupMap
QString schemeName() const
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
bool saveColorRamp(const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the DB.
void populateGroups()
populate the groups
bool tagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Tags the symbol with the tags in the list.
void filterSymbols(const QString &)
filter the symbols based on input search term
bool addColorRamp()
add a new color ramp to style
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp.
void populateSymbols(const QStringList &symbolNames, bool checkable=false)
populate list view with symbols of the current type with the given names
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
QString smartgroupName()
returns the value from mNameLineEdit
bool removeColorRamp(const QString &name)
Removes color ramp from style (and delete it)
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS=nullptr)
A dialog which allows users to modify the properties of a QgsPresetSchemeColorRamp.
A dialog which allows users to modify the properties of a QgsLimitedRandomColorRamp.
StyleEntity
Enum for Entities involved in a style.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
QString currentItemName()
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp.
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
bool renameSymbol(const QString &oldName, const QString &newName)
Changessymbol's name.
QMenu * mMenuBtnAddItemColorRamp
Menu for the "Add item" toolbutton when in colorramp mode.
void exportImage(const QString &path, const QString &format, QSize size)
export symbol as image format. PNG and SVG supported
int colors() const
Returns the number of colors in the ramp.
Constrained random color ramp, which returns random colors based on preset parameters.
static QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QString tag(int id) const
Returns the tag name for the given id.
const QgsSymbol * symbolRef(const QString &name) const
Returns a const pointer to a symbol (doesn't create new instance)
QStringList symbolNames()
Returns a list of names of symbols.
bool removeFavorite(StyleEntity type, const QString &name)
Removes the specified symbol from favorites.
QgsGradientColorRamp ramp
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp.
static QIcon colorRampPreviewIcon(QgsColorRamp *ramp, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QStringList findSymbols(StyleEntity type, const QString &qword)
Returns the names of the symbols which have a matching 'substring' in its definition.
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode.
void editSmartgroupAction()
edit the selected smart group
void exportSelectedItemsImages(const QString &dir, const QString &format, QSize size)
int addTag(const QString &tagName)
Adds a new tag and returns the tag's id.
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
QString smartgroupOperator(int id)
Returns the operator for the smartgroup clumsy implementation TODO create a class for smartgroups...
void grouptreeContextMenu(QPoint)
Context menu for the groupTree.
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, QString RampType=QString())
open add color ramp dialog, return color ramp's name if the ramp has been added
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites.
A scheme based color ramp consisting of a list of predefined colors.
void rename(StyleEntity type, int id, const QString &newName)
Renames the given entity with the specified id.
void itemChanged(QStandardItem *item)
QgsGradientColorRamp * cloneGradientRamp() const
QgsSmartConditionMap smartgroup(int id)
Returns the QgsSmartConditionMap for the given id.
QStringList colorRampNames()
Returns a list of names of color ramps.
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp.
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
Returns the symbols for the smartgroup.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
int tagId(const QString &tag)
Returns the DB id for the given tag name.
QString schemeName() const
Returns the name of the color brewer color scheme.
void addFavoriteSelectedSymbols()
Add selected symbols to favorites.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QStringList tags() const
Returns a list of all tags in the style database.
int addSmartgroup(const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
Adds a new smartgroup to the database and returns the id.
QMenu * mGroupTreeContextMenu
Context menu for the group tree.
void setOperator(const QString &)
sets the operator AND/OR
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
QgsPresetSchemeColorRamp ramp
void removeGroup()
remove a tag or smartgroup
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list )
Color ramp utilising "Color Brewer" preset color schemes.
bool isFavorite() const
returns whether the favorite element is checked
bool renameColorRamp(const QString &oldName, const QString &newName)
Changes ramp's name.
int colorRampCount()
Returns count of color ramps.
void setSmartgroupName(const QString &)
sets the smart group Name
void showHelp()
Open the associated help.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags.
void onClose()
Close the dialog.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.
QgsColorBrewerColorRamp ramp
void groupRenamed(QStandardItem *)
bool addFavorite(StyleEntity type, const QString &name)
Adds the specified symbol to favorites.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QgsLimitedRandomColorRamp ramp
void regrouped(QStandardItem *)
symbol changed from one group
void populateColorRamps(const QStringList &colorRamps, bool checkable=false)
populate list view with color ramps
QMenu * mGroupListMenu
Sub-menu of mGroupMenu, dynamically filled to show one entry for every group.
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap
QString variantName() const
bool detagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
Detags the symbol with the given list.
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp.
QgsSymbolGroupMap smartgroupsListMap()
Returns the smart groups map with id as key and name as value.
void detagSelectedSymbols()
Remove all tags from selected symbols.
QString conditionOperator()
returns the AND/OR condition
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.