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() ) ),
783 Q_FOREACH (
const QModelIndex &index, indexes )
785 QString symbolName = index.data().toString();
787 if ( !symbolName.isEmpty() )
796 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
797 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ),
798 QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, indexes.count() ) ),
805 Q_FOREACH (
const QModelIndex &index, indexes )
807 QString rampName = index.data().toString();
809 if ( !rampName.isEmpty() )
819 QString oldName = item->data().toString();
821 bool changed =
false;
838 QMessageBox::critical(
this, tr(
"Save Item" ),
839 tr(
"Name is already taken by another item. Choose a different name." ) );
840 item->setText( oldName );
846 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ),
847 QDir::home().absolutePath(),
848 QFileDialog::ShowDirsOnly
849 | QFileDialog::DontResolveSymlinks );
855 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ),
856 QDir::home().absolutePath(),
857 QFileDialog::ShowDirsOnly
858 | QFileDialog::DontResolveSymlinks );
868 QModelIndexList indexes = listItems->selectionModel()->selection().indexes();
869 Q_FOREACH (
const QModelIndex &index, indexes )
871 QString name = index.data().toString();
872 QString path = dir +
'/' + name +
'.' + format;
894 QFont font = item->font();
895 font.setBold(
true );
896 item->setFont( font );
901 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
904 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
905 favoriteSymbols->setData(
"favorite" );
906 favoriteSymbols->setEditable(
false );
908 model->appendRow( favoriteSymbols );
910 QStandardItem *allSymbols =
new QStandardItem( tr(
"All Symbols" ) );
911 allSymbols->setData(
"all" );
912 allSymbols->setEditable(
false );
914 model->appendRow( allSymbols );
916 QStandardItem *taggroup =
new QStandardItem( QLatin1String(
"" ) );
917 taggroup->setData(
"tags" );
918 taggroup->setEditable(
false );
921 Q_FOREACH (
const QString &tag, tags )
923 QStandardItem *item =
new QStandardItem( tag );
925 taggroup->appendRow( item );
927 taggroup->setText( tr(
"Tags" ) );
929 model->appendRow( taggroup );
931 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
932 smart->setData(
"smartgroups" );
933 smart->setEditable(
false );
936 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
937 while ( i != sgMap.constEnd() )
939 QStandardItem *item =
new QStandardItem( i.value() );
940 item->setData( i.key() );
941 smart->appendRow( item );
944 model->appendRow( smart );
947 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
948 for (
int i = 0; i < rows; i++ )
950 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
956 QStringList symbolNames;
957 QStringList groupSymbols;
966 QString category = index.data( Qt::UserRole + 1 ).toString();
967 if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
970 if ( category == QLatin1String(
"tags" ) )
972 actnAddTag->setEnabled(
true );
973 actnAddSmartgroup->setEnabled(
false );
975 else if ( category == QLatin1String(
"smartgroups" ) )
977 actnAddTag->setEnabled(
false );
978 actnAddSmartgroup->setEnabled(
true );
982 else if ( category == QLatin1String(
"favorite" ) )
987 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
989 actnRemoveGroup->setEnabled(
true );
990 btnManageGroups->setEnabled(
true );
991 int groupId = index.data( Qt::UserRole + 1 ).toInt();
997 int tagId = index.data( Qt::UserRole + 1 ).toInt();
1001 groupSymbols = symbolNames;
1021 actnEditSmartGroup->setVisible(
false );
1022 actnAddTag->setVisible(
false );
1023 actnAddSmartgroup->setVisible(
false );
1024 actnRemoveGroup->setVisible(
false );
1025 actnTagSymbols->setVisible(
false );
1026 actnFinishTagging->setVisible(
false );
1028 if ( index.parent().isValid() )
1030 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
1034 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
1040 actnRemoveGroup->setVisible(
true );
1042 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
1046 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
1054 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1056 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
1058 index = groupTree->model()->index( i, 0 );
1059 QString data = index.data( Qt::UserRole + 1 ).toString();
1060 if ( data == QLatin1String(
"tags" ) )
1069 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ),
1070 tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
1071 if ( !ok || itemName.isEmpty() )
1077 QMessageBox::critical(
this, tr(
"Add Tag" ),
1078 tr(
"Tag name already exists in your symbol database." ) );
1084 QMessageBox::critical(
this, tr(
"Add Tag" ),
1085 tr(
"New tag could not be created.\n" 1086 "There was a problem with your symbol database." ) );
1090 QStandardItem *parentItem = model->itemFromIndex( index );
1091 QStandardItem *childItem =
new QStandardItem( itemName );
1092 childItem->setData(
id );
1093 parentItem->appendRow( childItem );
1100 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1102 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
1104 index = groupTree->model()->index( i, 0 );
1105 QString data = index.data( Qt::UserRole + 1 ).toString();
1106 if ( data == QLatin1String(
"smartgroups" ) )
1115 if ( dlg.exec() == QDialog::Rejected )
1122 QStandardItem *parentItem = model->itemFromIndex( index );
1123 QStandardItem *childItem =
new QStandardItem( itemName );
1124 childItem->setData(
id );
1125 parentItem->appendRow( childItem );
1132 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
1133 QModelIndex index = groupTree->currentIndex();
1136 QString data = index.data( Qt::UserRole + 1 ).toString();
1137 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
1139 int err = QMessageBox::critical(
this, tr(
"Remove Group" ),
1140 tr(
"Invalid selection. Cannot delete system defined categories.\n" 1141 "Kindly select a group or smart group you might want to delete." ) );
1146 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
1147 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
1155 parentItem->removeRow( index.row() );
1160 QgsDebugMsg(
"Symbol group edited: data=" + item->data( Qt::UserRole + 1 ).toString() +
" text=" + item->text() );
1161 int id = item->data( Qt::UserRole + 1 ).toInt();
1162 QString name = item->text();
1163 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
1176 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1177 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
1182 actnTagSymbols->setVisible(
true );
1183 actnFinishTagging->setVisible(
false );
1185 disconnect( model, &QStandardItemModel::itemChanged,
1193 connect( treeModel, &QStandardItemModel::itemChanged,
1195 connect( model, &QStandardItemModel::itemChanged,
1198 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
1202 bool validGroup =
false;
1204 QModelIndex present = groupTree->currentIndex();
1205 while ( present.parent().isValid() )
1207 if ( present.parent().data() ==
"Tags" )
1212 present = present.parent();
1219 actnTagSymbols->setVisible(
false );
1220 actnFinishTagging->setVisible(
true );
1222 disconnect( treeModel, &QStandardItemModel::itemChanged,
1224 disconnect( model, &QStandardItemModel::itemChanged,
1230 btnManageGroups->setEnabled(
true );
1234 connect( model, &QStandardItemModel::itemChanged,
1238 listItems->setSelectionMode( QAbstractItemView::NoSelection );
1251 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1252 QString tag = treeModel->itemFromIndex( groupTree->currentIndex() )->text();
1254 QString symbolName = item->text();
1256 if ( item->checkState() == Qt::Checked )
1257 regrouped =
mStyle->
tagSymbol( type, symbolName, QStringList( tag ) );
1262 int er = QMessageBox::critical(
this, tr(
"Group Items" ),
1263 tr(
"There was a problem with the symbols database while regrouping." ) );
1272 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
1273 Q_FOREACH (
const QString &symbol, symbols )
1275 QList<QStandardItem *> items = model->findItems( symbol );
1276 Q_FOREACH ( QStandardItem *item, items )
1277 item->setCheckState( Qt::Checked );
1303 Q_UNUSED( selected );
1304 Q_UNUSED( deselected );
1305 bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
1306 actnRemoveItem->setDisabled( nothingSelected );
1307 actnAddFavorite->setDisabled( nothingSelected );
1308 actnRemoveFavorite->setDisabled( nothingSelected );
1310 actnDetag->setDisabled( nothingSelected );
1311 actnExportAsPNG->setDisabled( nothingSelected );
1312 actnExportAsSVG->setDisabled( nothingSelected );
1313 actnEditItem->setDisabled( nothingSelected );
1318 groupTree->setEnabled( enable );
1319 btnAddTag->setEnabled( enable );
1320 btnAddSmartgroup->setEnabled( enable );
1321 actnAddTag->setEnabled( enable );
1322 actnAddSmartgroup->setEnabled( enable );
1323 actnRemoveGroup->setEnabled( enable );
1325 searchBox->setEnabled( enable );
1330 actnRemoveGroup->setEnabled( enable );
1336 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1337 for (
int i = 0; i < treeModel->rowCount(); i++ )
1339 treeModel->item( i )->setEnabled( enable );
1341 if ( treeModel->item( i )->data() ==
"smartgroups" )
1343 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
1345 treeModel->item( i )->child( j )->setEnabled( enable );
1352 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
1354 QWidget *w = qobject_cast<QWidget *>( symbolBtnsLayout->itemAt( i )->widget() );
1356 w->setEnabled( enable );
1360 actnRemoveItem->setEnabled( enable );
1361 actnEditItem->setEnabled( enable );
1366 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
1368 QModelIndex index = groupTree->indexAt( point );
1369 QgsDebugMsg(
"Now you clicked: " + index.data().toString() );
1377 QPoint globalPos = listItems->viewport()->mapToGlobal( point );
1382 QAction *a =
nullptr;
1385 Q_FOREACH (
const QString &tag, tags )
1394 if ( tags.count() > 0 )
1415 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1416 Q_FOREACH (
const QModelIndex &index, indexes )
1432 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1433 Q_FOREACH (
const QModelIndex &index, indexes )
1442 QAction *selectedItem = qobject_cast<QAction *>( sender() );
1465 tag = selectedItem->data().toString();
1468 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1469 Q_FOREACH (
const QModelIndex &index, indexes )
1471 mStyle->
tagSymbol( type, index.data().toString(), QStringList( tag ) );
1475 QgsDebugMsg(
"Selected Action: " + selectedItem->text() );
1481 QAction *selectedItem = qobject_cast<QAction *>( sender() );
1491 QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1492 Q_FOREACH (
const QModelIndex &index, indexes )
1498 QgsDebugMsg(
"Selected Action: " + selectedItem->text() );
1504 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
1507 QModelIndex present = groupTree->currentIndex();
1508 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
1510 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
1511 tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
1514 QStandardItem *item = treeModel->itemFromIndex( present );
1522 if ( dlg.exec() == QDialog::Rejected )
1529 QMessageBox::critical(
this, tr(
"Edit Smart Group" ),
1530 tr(
"There was some error while editing the smart group." ) );
1534 item->setData(
id );
1546 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)
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
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
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
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.
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 setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void setOperator(const QString &)
sets the operator AND/OR
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
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.