QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsstyleexportimportdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsstyleexportimportdialog.cpp
3  ---------------------
4  begin : Jan 2011
5  copyright : (C) 2011 by Alexander Bruy
6  email : alexander dot bruy at gmail dot com
7 
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
18 #include "ui_qgsstyleexportimportdialogbase.h"
19 
20 #include "qgsstyle.h"
21 #include "qgssymbol.h"
22 #include "qgssymbollayerutils.h"
23 #include "qgscolorramp.h"
24 #include "qgslogger.h"
26 #include "qgsguiutils.h"
27 
28 #include <QInputDialog>
29 #include <QCloseEvent>
30 #include <QFileDialog>
31 #include <QMessageBox>
32 #include <QPushButton>
33 #include <QStandardItemModel>
34 
35 
37  : QDialog( parent )
38  , mDialogMode( mode )
39  , mStyle( style )
40 {
41  setupUi( this );
42 
43  // additional buttons
44  QPushButton *pb = nullptr;
45  pb = new QPushButton( tr( "Select all" ) );
46  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
47  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::selectAll );
48 
49  pb = new QPushButton( tr( "Clear selection" ) );
50  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
51  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::clearSelection );
52 
53  QStandardItemModel *model = new QStandardItemModel( listItems );
54  listItems->setModel( model );
55  connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
56  this, &QgsStyleExportImportDialog::selectionChanged );
57 
58  mTempStyle = new QgsStyle();
59  mTempStyle->createMemoryDatabase();
60 
61  // TODO validate
62  mProgressDlg = nullptr;
63  mGroupSelectionDlg = nullptr;
64  mTempFile = nullptr;
65  mNetManager = new QNetworkAccessManager( this );
66  mNetReply = nullptr;
67 
68  if ( mDialogMode == Import )
69  {
70  setWindowTitle( tr( "Import Symbol(s)" ) );
71  // populate the import types
72  importTypeCombo->addItem( tr( "file specified below" ), QVariant( "file" ) );
73  // importTypeCombo->addItem( "official QGIS repo online", QVariant( "official" ) );
74  importTypeCombo->addItem( tr( "URL specified below" ), QVariant( "url" ) );
75  connect( importTypeCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsStyleExportImportDialog::importTypeChanged );
76 
77  mSymbolTags->setText( QStringLiteral( "imported" ) );
78 
79  btnBrowse->setText( QStringLiteral( "Browse" ) );
80  connect( btnBrowse, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::browse );
81 
82  label->setText( tr( "Select symbols to import" ) );
83  buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) );
84  }
85  else
86  {
87  setWindowTitle( tr( "Export Symbol(s)" ) );
88  // hide import specific controls when exporting
89  btnBrowse->setHidden( true );
90  fromLabel->setHidden( true );
91  importTypeCombo->setHidden( true );
92  locationLabel->setHidden( true );
93  locationLineEdit->setHidden( true );
94 
95  mFavorite->setHidden( true );
96  mIgnoreXMLTags->setHidden( true );
97 
98  pb = new QPushButton( tr( "Select by group" ) );
99  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
100  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::selectByGroup );
101  tagLabel->setHidden( true );
102  mSymbolTags->setHidden( true );
103  tagHintLabel->setHidden( true );
104 
105  buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );
106  if ( !populateStyles( mStyle ) )
107  {
108  QApplication::postEvent( this, new QCloseEvent() );
109  }
110 
111  }
112  // use Ok button for starting import and export operations
113  disconnect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
114  connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsStyleExportImportDialog::doExportImport );
115  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
116 
117  connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsStyleExportImportDialog::showHelp );
118 }
119 
121 {
122  QModelIndexList selection = listItems->selectionModel()->selectedIndexes();
123  if ( selection.isEmpty() )
124  {
125  QMessageBox::warning( this, tr( "Export/import Symbols or Color Ramps" ),
126  tr( "You should select at least one symbol/color ramp." ) );
127  return;
128  }
129 
130  if ( mDialogMode == Export )
131  {
132  QString fileName = QFileDialog::getSaveFileName( this, tr( "Save Styles" ), QDir::homePath(),
133  tr( "XML files (*.xml *.XML)" ) );
134  if ( fileName.isEmpty() )
135  {
136  return;
137  }
138 
139  // ensure the user never omitted the extension from the file name
140  if ( !fileName.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) )
141  {
142  fileName += QLatin1String( ".xml" );
143  }
144 
145  mFileName = fileName;
146 
147  QgsTemporaryCursorOverride override( Qt::WaitCursor );
148  moveStyles( &selection, mStyle, mTempStyle );
149  if ( !mTempStyle->exportXml( mFileName ) )
150  {
151  override.release();
152  QMessageBox::warning( this, tr( "Export Symbols" ),
153  tr( "Error when saving selected symbols to file:\n%1" )
154  .arg( mTempStyle->errorString() ) );
155  return;
156  }
157  else
158  {
159  override.release();
160  QMessageBox::information( this, tr( "Export Symbols" ),
161  tr( "The selected symbols were successfully exported to file:\n%1" )
162  .arg( mFileName ) );
163  }
164  }
165  else // import
166  {
167  QgsTemporaryCursorOverride override( Qt::WaitCursor );
168  moveStyles( &selection, mTempStyle, mStyle );
169 
170  // clear model
171  QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
172  model->clear();
173  accept();
174  }
175 
176  mFileName.clear();
177  mTempStyle->clear();
178 }
179 
180 bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style )
181 {
182  QgsTemporaryCursorOverride override( Qt::WaitCursor );
183 
184  // load symbols and color ramps from file
185  if ( mDialogMode == Import )
186  {
187  // NOTE mTempStyle is style here
188  if ( !style->importXml( mFileName ) )
189  {
190  override.release();
191  QMessageBox::warning( this, tr( "Import Symbols or Color Ramps" ),
192  tr( "An error occurred during import:\n%1" ).arg( style->errorString() ) );
193  return false;
194  }
195  }
196 
197  QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
198  model->clear();
199 
200  // populate symbols
201  QStringList styleNames = style->symbolNames();
202  QString name;
203 
204  for ( int i = 0; i < styleNames.count(); ++i )
205  {
206  name = styleNames[i];
207  QStringList tags = style->tagsOfSymbol( QgsStyle::SymbolEntity, name );
208  QgsSymbol *symbol = style->symbol( name );
209  QStandardItem *item = new QStandardItem( name );
210  QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 );
211  item->setIcon( icon );
212  item->setToolTip( QStringLiteral( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( QStringLiteral( ", " ) ) : tr( "Not tagged" ) ) );
213  // Set font to 10points to show reasonable text
214  QFont itemFont = item->font();
215  itemFont.setPointSize( 10 );
216  item->setFont( itemFont );
217  model->appendRow( item );
218  delete symbol;
219  }
220 
221  // and color ramps
222  styleNames = style->colorRampNames();
223 
224  for ( int i = 0; i < styleNames.count(); ++i )
225  {
226  name = styleNames[i];
227  std::unique_ptr< QgsColorRamp > ramp( style->colorRamp( name ) );
228 
229  QStandardItem *item = new QStandardItem( name );
230  QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 15 );
231  item->setIcon( icon );
232  model->appendRow( item );
233  }
234  return true;
235 }
236 
237 void QgsStyleExportImportDialog::moveStyles( QModelIndexList *selection, QgsStyle *src, QgsStyle *dst )
238 {
239  QString symbolName;
240  QgsSymbol *symbol = nullptr;
241  QStringList symbolTags;
242  bool symbolFavorite;
243  QgsColorRamp *ramp = nullptr;
244  QModelIndex index;
245  bool isSymbol = true;
246  bool prompt = true;
247  bool overwrite = true;
248 
249  QStringList importTags = mSymbolTags->text().split( ',' );
250 
251  QStringList favoriteSymbols = src->symbolsOfFavorite( QgsStyle::SymbolEntity );
252  QStringList favoriteColorramps = src->symbolsOfFavorite( QgsStyle::ColorrampEntity );
253 
254  for ( int i = 0; i < selection->size(); ++i )
255  {
256  index = selection->at( i );
257  symbolName = index.model()->data( index, 0 ).toString();
258  symbol = src->symbol( symbolName );
259 
260  if ( !mIgnoreXMLTags->isChecked() )
261  {
262  symbolTags = src->tagsOfSymbol( !symbol ? QgsStyle::ColorrampEntity : QgsStyle::SymbolEntity, symbolName );
263  }
264  else
265  {
266  symbolTags.clear();
267  }
268 
269  if ( mDialogMode == Import )
270  {
271  symbolTags << importTags;
272  symbolFavorite = mFavorite->isChecked();
273  }
274  else
275  {
276  symbolFavorite = !symbol ? favoriteColorramps.contains( symbolName ) : favoriteSymbols.contains( symbolName );
277  }
278 
279  if ( !symbol )
280  {
281  isSymbol = false;
282  ramp = src->colorRamp( symbolName );
283  }
284 
285  if ( isSymbol )
286  {
287  if ( dst->symbolNames().contains( symbolName ) && prompt )
288  {
289  int res = QMessageBox::warning( this, tr( "Export/import Symbols" ),
290  tr( "Symbol with name '%1' already exists.\nOverwrite?" )
291  .arg( symbolName ),
292  QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
293  switch ( res )
294  {
295  case QMessageBox::Cancel:
296  return;
297  case QMessageBox::No:
298  continue;
299  case QMessageBox::Yes:
300  dst->addSymbol( symbolName, symbol );
301  dst->saveSymbol( symbolName, symbol, symbolFavorite, symbolTags );
302  continue;
303  case QMessageBox::YesToAll:
304  prompt = false;
305  overwrite = true;
306  break;
307  case QMessageBox::NoToAll:
308  prompt = false;
309  overwrite = false;
310  break;
311  }
312  }
313 
314  if ( dst->symbolNames().contains( symbolName ) && overwrite )
315  {
316  dst->addSymbol( symbolName, symbol );
317  dst->saveSymbol( symbolName, symbol, symbolFavorite, symbolTags );
318  }
319  else if ( dst->symbolNames().contains( symbolName ) && !overwrite )
320  {
321  continue;
322  }
323  else
324  {
325  dst->addSymbol( symbolName, symbol );
326  dst->saveSymbol( symbolName, symbol, symbolFavorite, symbolTags );
327  }
328  }
329  else
330  {
331  if ( dst->colorRampNames().contains( symbolName ) && prompt )
332  {
333  int res = QMessageBox::warning( this, tr( "Export/import Color Ramps" ),
334  tr( "Color ramp with name '%1' already exists.\nOverwrite?" )
335  .arg( symbolName ),
336  QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
337  switch ( res )
338  {
339  case QMessageBox::Cancel:
340  return;
341  case QMessageBox::No:
342  continue;
343  case QMessageBox::Yes:
344  dst->addColorRamp( symbolName, ramp );
345  dst->saveColorRamp( symbolName, ramp, symbolFavorite, symbolTags );
346  continue;
347  case QMessageBox::YesToAll:
348  prompt = false;
349  overwrite = true;
350  break;
351  case QMessageBox::NoToAll:
352  prompt = false;
353  overwrite = false;
354  break;
355  }
356  }
357 
358  if ( dst->colorRampNames().contains( symbolName ) && overwrite )
359  {
360  dst->addColorRamp( symbolName, ramp );
361  dst->saveColorRamp( symbolName, ramp, symbolFavorite, symbolTags );
362  }
363  else if ( dst->colorRampNames().contains( symbolName ) && !overwrite )
364  {
365  continue;
366  }
367  else
368  {
369  dst->addColorRamp( symbolName, ramp );
370  dst->saveColorRamp( symbolName, ramp, symbolFavorite, symbolTags );
371  }
372  }
373  }
374 }
375 
377 {
378  delete mTempFile;
379  delete mTempStyle;
380  delete mGroupSelectionDlg;
381 }
382 
384 {
385  listItems->selectAll();
386 }
387 
389 {
390  listItems->clearSelection();
391 }
392 
393 void QgsStyleExportImportDialog::selectSymbols( const QStringList &symbolNames )
394 {
395  Q_FOREACH ( const QString &symbolName, symbolNames )
396  {
397  QModelIndexList indexes = listItems->model()->match( listItems->model()->index( 0, 0 ), Qt::DisplayRole, symbolName, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive );
398  Q_FOREACH ( const QModelIndex &index, indexes )
399  {
400  listItems->selectionModel()->select( index, QItemSelectionModel::Select );
401  }
402  }
403 }
404 
405 void QgsStyleExportImportDialog::deselectSymbols( const QStringList &symbolNames )
406 {
407  Q_FOREACH ( const QString &symbolName, symbolNames )
408  {
409  QModelIndexList indexes = listItems->model()->match( listItems->model()->index( 0, 0 ), Qt::DisplayRole, symbolName, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive );
410  Q_FOREACH ( const QModelIndex &index, indexes )
411  {
412  QItemSelection deselection( index, index );
413  listItems->selectionModel()->select( deselection, QItemSelectionModel::Deselect );
414  }
415  }
416 }
417 
418 void QgsStyleExportImportDialog::selectTag( const QString &tagName )
419 {
420  QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
421  selectSymbols( symbolNames );
422 }
423 
424 void QgsStyleExportImportDialog::deselectTag( const QString &tagName )
425 {
426  QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
427  deselectSymbols( symbolNames );
428 }
429 
430 void QgsStyleExportImportDialog::selectSmartgroup( const QString &groupName )
431 {
432  QStringList symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mStyle->smartgroupId( groupName ) );
433  selectSymbols( symbolNames );
434  symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mStyle->smartgroupId( groupName ) );
435  selectSymbols( symbolNames );
436 }
437 
438 void QgsStyleExportImportDialog::deselectSmartgroup( const QString &groupName )
439 {
440  QStringList symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mStyle->smartgroupId( groupName ) );
441  deselectSymbols( symbolNames );
442  symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mStyle->smartgroupId( groupName ) );
443  deselectSymbols( symbolNames );
444 }
445 
447 {
448  if ( ! mGroupSelectionDlg )
449  {
450  mGroupSelectionDlg = new QgsStyleGroupSelectionDialog( mStyle, this );
451  mGroupSelectionDlg->setWindowTitle( tr( "Select Symbols by Group" ) );
458  }
459  mGroupSelectionDlg->show();
460  mGroupSelectionDlg->raise();
461  mGroupSelectionDlg->activateWindow();
462 }
463 
465 {
466  QString type = importTypeCombo->itemData( index ).toString();
467 
468  locationLineEdit->clear();
469 
470  if ( type == QLatin1String( "file" ) )
471  {
472  locationLineEdit->setEnabled( true );
473  btnBrowse->setText( QStringLiteral( "Browse" ) );
474  }
475  else if ( type == QLatin1String( "official" ) )
476  {
477  btnBrowse->setText( QStringLiteral( "Fetch Symbols" ) );
478  locationLineEdit->setEnabled( false );
479  }
480  else
481  {
482  btnBrowse->setText( QStringLiteral( "Fetch Symbols" ) );
483  locationLineEdit->setEnabled( true );
484  }
485 }
486 
488 {
489  QString type = importTypeCombo->currentData().toString();
490 
491  if ( type == QLatin1String( "file" ) )
492  {
493  mFileName = QFileDialog::getOpenFileName( this, tr( "Load Styles" ), QDir::homePath(),
494  tr( "XML files (*.xml *XML)" ) );
495  if ( mFileName.isEmpty() )
496  {
497  return;
498  }
499  QFileInfo pathInfo( mFileName );
500  QString tag = pathInfo.fileName().remove( QStringLiteral( ".xml" ) );
501  mSymbolTags->setText( tag );
502  locationLineEdit->setText( mFileName );
503  populateStyles( mTempStyle );
504  }
505  else if ( type == QLatin1String( "official" ) )
506  {
507  // TODO set URL
508  // downloadStyleXML( QUrl( "http://...." ) );
509  }
510  else
511  {
512  downloadStyleXml( QUrl( locationLineEdit->text() ) );
513  }
514 }
515 
516 void QgsStyleExportImportDialog::downloadStyleXml( const QUrl &url )
517 {
518  // XXX Try to move this code to some core Network interface,
519  // HTTP downloading is a generic functionality that might be used elsewhere
520 
521  mTempFile = new QTemporaryFile();
522  if ( mTempFile->open() )
523  {
524  mFileName = mTempFile->fileName();
525 
526  if ( mProgressDlg )
527  {
528  QProgressDialog *dummy = mProgressDlg;
529  mProgressDlg = nullptr;
530  delete dummy;
531  }
532  mProgressDlg = new QProgressDialog();
533  mProgressDlg->setLabelText( tr( "Downloading style…" ) );
534  mProgressDlg->setAutoClose( true );
535 
536  connect( mProgressDlg, &QProgressDialog::canceled, this, &QgsStyleExportImportDialog::downloadCanceled );
537 
538  // open the network connection and connect the respective slots
539  if ( mNetReply )
540  {
541  QNetworkReply *dummyReply = mNetReply;
542  mNetReply = nullptr;
543  delete dummyReply;
544  }
545  mNetReply = mNetManager->get( QNetworkRequest( url ) );
546 
547  connect( mNetReply, &QNetworkReply::finished, this, &QgsStyleExportImportDialog::httpFinished );
548  connect( mNetReply, &QIODevice::readyRead, this, &QgsStyleExportImportDialog::fileReadyRead );
549  connect( mNetReply, &QNetworkReply::downloadProgress, this, &QgsStyleExportImportDialog::updateProgress );
550  }
551 }
552 
553 void QgsStyleExportImportDialog::httpFinished()
554 {
555  if ( mNetReply->error() )
556  {
557  mTempFile->remove();
558  mFileName.clear();
559  mProgressDlg->hide();
560  QMessageBox::information( this, tr( "Import from URL" ),
561  tr( "HTTP Error! Download failed: %1." ).arg( mNetReply->errorString() ) );
562  return;
563  }
564  else
565  {
566  mTempFile->flush();
567  mTempFile->close();
568  populateStyles( mTempStyle );
569  }
570 }
571 
572 void QgsStyleExportImportDialog::fileReadyRead()
573 {
574  mTempFile->write( mNetReply->readAll() );
575 }
576 
577 void QgsStyleExportImportDialog::updateProgress( qint64 bytesRead, qint64 bytesTotal )
578 {
579  mProgressDlg->setMaximum( bytesTotal );
580  mProgressDlg->setValue( bytesRead );
581 }
582 
583 void QgsStyleExportImportDialog::downloadCanceled()
584 {
585  mNetReply->abort();
586  mTempFile->remove();
587  mFileName.clear();
588 }
589 
590 void QgsStyleExportImportDialog::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
591 {
592  Q_UNUSED( selected );
593  Q_UNUSED( deselected );
594  bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
595  buttonBox->button( QDialogButtonBox::Ok )->setDisabled( nothingSelected );
596 }
597 
598 void QgsStyleExportImportDialog::showHelp()
599 {
600  QgsHelp::openHelp( QStringLiteral( "working_with_vector/style_library.html#share-symbols" ) );
601 }
bool exportXml(const QString &filename)
Exports the style as a XML file.
Definition: qgsstyle.cpp:1402
void clear()
Removes all contents of the style.
Definition: qgsstyle.cpp:77
void selectByGroup()
selectByGroup open select by group dialog
void deselectSmartgroup(const QString &groupName)
deselectSmartgroup deselects all symbols from a smart group
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:175
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
Definition: qgsstyle.cpp:191
QgsStyleExportImportDialog(QgsStyle *style, QWidget *parent=nullptr, Mode mode=Export)
QStringList symbolsWithTag(StyleEntity type, int tagid) const
Returns the symbol names with which have the given tag.
Definition: qgsstyle.cpp:561
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
Definition: qgsstyle.cpp:991
Abstract base class for color ramps.
Definition: qgscolorramp.h:31
bool saveColorRamp(const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the DB.
Definition: qgsstyle.cpp:215
void tagSelected(const QString &tagName)
tag with tagName has been selected
void clearSelection()
clearSelection deselects all symbols
void smartgroupSelected(const QString &groupName)
smartgroup with groupName has been selected
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:262
void selectSmartgroup(const QString &groupName)
selectSmartgroup selects all symbols from a smart group
void allDeselected()
all deselected
static QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
bool importXml(const QString &filename)
Imports the symbols and colorramps into the default style database from the given XML file...
Definition: qgsstyle.cpp:1474
void deselectSymbols(const QStringList &symbolNames)
deselectSymbols deselect symbols by name
QStringList symbolNames()
Returns a list of names of symbols.
Definition: qgsstyle.cpp:185
static QIcon colorRampPreviewIcon(QgsColorRamp *ramp, QSize size, int padding=0)
Returns an icon preview for a color ramp.
void allSelected()
all selected
QStringList colorRampNames()
Returns a list of names of color ramps.
Definition: qgsstyle.cpp:278
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
Returns the symbols for the smartgroup.
Definition: qgsstyle.cpp:1236
int smartgroupId(const QString &smartgroup)
Returns the DB id for the given smartgroup name.
Definition: qgsstyle.cpp:1138
int tagId(const QString &tag)
Returns the DB id for the given tag name.
Definition: qgsstyle.cpp:1133
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol&#39;s ownership.
Definition: qgsstyle.cpp:86
void release()
Releases the cursor override early (i.e.
void selectTag(const QString &tagName)
Select the symbols belonging to the given tag.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:35
void selectSymbols(const QStringList &symbolNames)
selectSymbols select symbols by name
void deselectTag(const QString &tagName)
Deselect the symbols belonging to the given tag.
QString errorString()
Returns last error from load/save operation.
Definition: qgsstyle.h:357
void selectAll()
selectAll selects all symbols
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:169
void smartgroupDeselected(const QString &groupName)
smart group with groupName has been deselected
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags.
Definition: qgsstyle.cpp:110
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
Definition: qgsstyle.cpp:525
void tagDeselected(const QString &tagName)
tag with tagName has been deselected