QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 #include "qgssettings.h"
28 #include "qgsgui.h"
29 #include "qgsstylemodel.h"
30 
31 #include <QInputDialog>
32 #include <QCloseEvent>
33 #include <QFileDialog>
34 #include <QMessageBox>
35 #include <QProgressDialog>
36 #include <QPushButton>
37 #include <QStandardItemModel>
38 #include <QNetworkAccessManager>
39 #include <QNetworkReply>
40 
41 
43  : QDialog( parent )
44  , mDialogMode( mode )
45  , mStyle( style )
46 {
47  setupUi( this );
49 
50  // additional buttons
51  QPushButton *pb = nullptr;
52  pb = new QPushButton( tr( "Select All" ) );
53  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
54  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::selectAll );
55 
56  pb = new QPushButton( tr( "Clear Selection" ) );
57  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
58  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::clearSelection );
59 
60  mTempStyle = qgis::make_unique< QgsStyle >();
61  mTempStyle->createMemoryDatabase();
62 
63  // TODO validate
64  mProgressDlg = nullptr;
65  mGroupSelectionDlg = nullptr;
66  mTempFile = nullptr;
67  mNetManager = new QNetworkAccessManager( this );
68  mNetReply = nullptr;
69 
70  if ( mDialogMode == Import )
71  {
72  setWindowTitle( tr( "Import Item(s)" ) );
73  // populate the import types
74  importTypeCombo->addItem( tr( "File" ), ImportSource::File );
75  // importTypeCombo->addItem( "official QGIS repo online", ImportSource::Official );
76  importTypeCombo->addItem( tr( "URL" ), ImportSource::Url );
77  connect( importTypeCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsStyleExportImportDialog::importTypeChanged );
78  importTypeChanged( 0 );
79 
80  mSymbolTags->setText( QStringLiteral( "imported" ) );
81 
82  connect( mButtonFetch, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::fetch );
83 
84  mImportFileWidget->setStorageMode( QgsFileWidget::GetFile );
85  mImportFileWidget->setDialogTitle( tr( "Load Styles" ) );
86  mImportFileWidget->setFilter( tr( "XML files (*.xml *.XML)" ) );
87 
88  QgsSettings settings;
89  mImportFileWidget->setDefaultRoot( settings.value( QStringLiteral( "StyleManager/lastImportDir" ), QDir::homePath(), QgsSettings::Gui ).toString() );
90  connect( mImportFileWidget, &QgsFileWidget::fileChanged, this, &QgsStyleExportImportDialog::importFileChanged );
91 
92  label->setText( tr( "Select items to import" ) );
93  buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) );
94 
95  mModel = new QgsStyleModel( mTempStyle.get(), this );
96  listItems->setModel( mModel );
97  }
98  else
99  {
100  setWindowTitle( tr( "Export Item(s)" ) );
101  // hide import specific controls when exporting
102  mLocationStackedEdit->setHidden( true );
103  fromLabel->setHidden( true );
104  importTypeCombo->setHidden( true );
105  mLocationLabel->setHidden( true );
106 
107  mFavorite->setHidden( true );
108  mIgnoreXMLTags->setHidden( true );
109 
110  pb = new QPushButton( tr( "Select by Group" ) );
111  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
112  connect( pb, &QAbstractButton::clicked, this, &QgsStyleExportImportDialog::selectByGroup );
113  tagLabel->setHidden( true );
114  mSymbolTags->setHidden( true );
115  tagHintLabel->setHidden( true );
116 
117  buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );
118 
119  mModel = new QgsStyleModel( mStyle, this );
120  }
121 
122  double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 10;
123  listItems->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi
124 
125  mModel->addDesiredIconSize( listItems->iconSize() );
126  listItems->setModel( mModel );
127 
128  connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged,
129  this, &QgsStyleExportImportDialog::selectionChanged );
130 
131  // use Ok button for starting import and export operations
132  disconnect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
133  connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsStyleExportImportDialog::doExportImport );
134  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
135 
136  connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsStyleExportImportDialog::showHelp );
137 }
138 
140 {
141  QModelIndexList selection = listItems->selectionModel()->selectedIndexes();
142  if ( selection.isEmpty() )
143  {
144  QMessageBox::warning( this, tr( "Export/import Item(s)" ),
145  tr( "You should select at least one symbol/color ramp." ) );
146  return;
147  }
148 
149  if ( mDialogMode == Export )
150  {
151  QString fileName = QFileDialog::getSaveFileName( this, tr( "Save Styles" ), QDir::homePath(),
152  tr( "XML files (*.xml *.XML)" ) );
153  if ( fileName.isEmpty() )
154  {
155  return;
156  }
157 
158  // ensure the user never omitted the extension from the file name
159  if ( !fileName.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) )
160  {
161  fileName += QLatin1String( ".xml" );
162  }
163 
164  mFileName = fileName;
165 
166  mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
167  moveStyles( &selection, mStyle, mTempStyle.get() );
168  if ( !mTempStyle->exportXml( mFileName ) )
169  {
170  mCursorOverride.reset();
171  QMessageBox::warning( this, tr( "Export Symbols" ),
172  tr( "Error when saving selected symbols to file:\n%1" )
173  .arg( mTempStyle->errorString() ) );
174  return;
175  }
176  else
177  {
178  mCursorOverride.reset();
179  QMessageBox::information( this, tr( "Export Symbols" ),
180  tr( "The selected symbols were successfully exported to file:\n%1" )
181  .arg( mFileName ) );
182  }
183  }
184  else // import
185  {
186  mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
187  moveStyles( &selection, mTempStyle.get(), mStyle );
188 
189  accept();
190  mCursorOverride.reset();
191  }
192 
193  mFileName.clear();
194  mTempStyle->clear();
195 }
196 
197 bool QgsStyleExportImportDialog::populateStyles()
198 {
199  QgsTemporaryCursorOverride override( Qt::WaitCursor );
200 
201  // load symbols and color ramps from file
202  // NOTE mTempStyle is style here
203  mTempStyle->clear();
204  if ( !mTempStyle->importXml( mFileName ) )
205  {
206  override.release();
207  QMessageBox::warning( this, tr( "Import Symbols or Color Ramps" ),
208  tr( "An error occurred during import:\n%1" ).arg( mTempStyle->errorString() ) );
209  return false;
210  }
211  return true;
212 }
213 
214 void QgsStyleExportImportDialog::moveStyles( QModelIndexList *selection, QgsStyle *src, QgsStyle *dst )
215 {
216  QString symbolName;
217  QStringList symbolTags;
218  bool symbolFavorite;
219  QModelIndex index;
220  bool isSymbol = true;
221  bool prompt = true;
222  bool overwrite = true;
223 
224  QStringList importTags = mSymbolTags->text().split( ',' );
225 
226  QStringList favoriteSymbols = src->symbolsOfFavorite( QgsStyle::SymbolEntity );
227  QStringList favoriteColorramps = src->symbolsOfFavorite( QgsStyle::ColorrampEntity );
228 
229  for ( int i = 0; i < selection->size(); ++i )
230  {
231  index = selection->at( i );
232  symbolName = mModel->data( mModel->index( index.row(), QgsStyleModel::Name ), Qt::DisplayRole ).toString();
233  std::unique_ptr< QgsSymbol > symbol( src->symbol( symbolName ) );
234  std::unique_ptr< QgsColorRamp > ramp;
235 
236  if ( !mIgnoreXMLTags->isChecked() )
237  {
238  symbolTags = src->tagsOfSymbol( !symbol ? QgsStyle::ColorrampEntity : QgsStyle::SymbolEntity, symbolName );
239  }
240  else
241  {
242  symbolTags.clear();
243  }
244 
245  if ( mDialogMode == Import )
246  {
247  symbolTags << importTags;
248  symbolFavorite = mFavorite->isChecked();
249  }
250  else
251  {
252  symbolFavorite = !symbol ? favoriteColorramps.contains( symbolName ) : favoriteSymbols.contains( symbolName );
253  }
254 
255  if ( !symbol )
256  {
257  isSymbol = false;
258  ramp.reset( src->colorRamp( symbolName ) );
259  }
260 
261  if ( isSymbol )
262  {
263  if ( dst->symbolNames().contains( symbolName ) && prompt )
264  {
265  mCursorOverride.reset();
266  int res = QMessageBox::warning( this, tr( "Export/import Symbols" ),
267  tr( "Symbol with name '%1' already exists.\nOverwrite?" )
268  .arg( symbolName ),
269  QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
270  mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
271  switch ( res )
272  {
273  case QMessageBox::Cancel:
274  return;
275  case QMessageBox::No:
276  continue;
277  case QMessageBox::Yes:
278  {
279  QgsSymbol *newSymbol = symbol.get();
280  dst->addSymbol( symbolName, symbol.release() );
281  dst->saveSymbol( symbolName, newSymbol, symbolFavorite, symbolTags );
282  continue;
283  }
284  case QMessageBox::YesToAll:
285  prompt = false;
286  overwrite = true;
287  break;
288  case QMessageBox::NoToAll:
289  prompt = false;
290  overwrite = false;
291  break;
292  }
293  }
294 
295  if ( dst->symbolNames().contains( symbolName ) && overwrite )
296  {
297  QgsSymbol *newSymbol = symbol.get();
298  dst->addSymbol( symbolName, symbol.release() );
299  dst->saveSymbol( symbolName, newSymbol, symbolFavorite, symbolTags );
300  continue;
301  }
302  else if ( dst->symbolNames().contains( symbolName ) && !overwrite )
303  {
304  continue;
305  }
306  else
307  {
308  QgsSymbol *newSymbol = symbol.get();
309  dst->addSymbol( symbolName, symbol.release() );
310  dst->saveSymbol( symbolName, newSymbol, symbolFavorite, symbolTags );
311  continue;
312  }
313  }
314  else
315  {
316  if ( dst->colorRampNames().contains( symbolName ) && prompt )
317  {
318  mCursorOverride.reset();
319  int res = QMessageBox::warning( this, tr( "Export/import Color Ramps" ),
320  tr( "Color ramp with name '%1' already exists.\nOverwrite?" )
321  .arg( symbolName ),
322  QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
323  mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
324  switch ( res )
325  {
326  case QMessageBox::Cancel:
327  return;
328  case QMessageBox::No:
329  continue;
330  case QMessageBox::Yes:
331  {
332  QgsColorRamp *newRamp = ramp.get();
333  dst->addColorRamp( symbolName, ramp.release() );
334  dst->saveColorRamp( symbolName, newRamp, symbolFavorite, symbolTags );
335  continue;
336  }
337  case QMessageBox::YesToAll:
338  prompt = false;
339  overwrite = true;
340  break;
341  case QMessageBox::NoToAll:
342  prompt = false;
343  overwrite = false;
344  break;
345  }
346  }
347 
348  if ( dst->colorRampNames().contains( symbolName ) && overwrite )
349  {
350  QgsColorRamp *newRamp = ramp.get();
351  dst->addColorRamp( symbolName, ramp.release() );
352  dst->saveColorRamp( symbolName, newRamp, symbolFavorite, symbolTags );
353  continue;
354  }
355  else if ( dst->colorRampNames().contains( symbolName ) && !overwrite )
356  {
357  continue;
358  }
359  else
360  {
361  QgsColorRamp *newRamp = ramp.get();
362  dst->addColorRamp( symbolName, ramp.release() );
363  dst->saveColorRamp( symbolName, newRamp, symbolFavorite, symbolTags );
364  continue;
365  }
366  }
367  }
368 }
369 
371 {
372  delete mTempFile;
373  delete mGroupSelectionDlg;
374 }
375 
377 {
378  listItems->selectAll();
379 }
380 
382 {
383  listItems->clearSelection();
384 }
385 
386 void QgsStyleExportImportDialog::selectSymbols( const QStringList &symbolNames )
387 {
388  Q_FOREACH ( const QString &symbolName, symbolNames )
389  {
390  QModelIndexList indexes = listItems->model()->match( listItems->model()->index( 0, QgsStyleModel::Name ), Qt::DisplayRole, symbolName, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive );
391  Q_FOREACH ( const QModelIndex &index, indexes )
392  {
393  listItems->selectionModel()->select( index, QItemSelectionModel::Select );
394  }
395  }
396 }
397 
398 void QgsStyleExportImportDialog::deselectSymbols( const QStringList &symbolNames )
399 {
400  Q_FOREACH ( const QString &symbolName, symbolNames )
401  {
402  QModelIndexList indexes = listItems->model()->match( listItems->model()->index( 0, QgsStyleModel::Name ), Qt::DisplayRole, symbolName, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive );
403  Q_FOREACH ( const QModelIndex &index, indexes )
404  {
405  QItemSelection deselection( index, index );
406  listItems->selectionModel()->select( deselection, QItemSelectionModel::Deselect );
407  }
408  }
409 }
410 
411 void QgsStyleExportImportDialog::selectTag( const QString &tagName )
412 {
413  QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
414  selectSymbols( symbolNames );
415 }
416 
417 void QgsStyleExportImportDialog::deselectTag( const QString &tagName )
418 {
419  QStringList symbolNames = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, mStyle->tagId( tagName ) );
420  deselectSymbols( symbolNames );
421 }
422 
423 void QgsStyleExportImportDialog::selectSmartgroup( const QString &groupName )
424 {
425  QStringList symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mStyle->smartgroupId( groupName ) );
426  selectSymbols( symbolNames );
427  symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mStyle->smartgroupId( groupName ) );
428  selectSymbols( symbolNames );
429 }
430 
431 void QgsStyleExportImportDialog::deselectSmartgroup( const QString &groupName )
432 {
433  QStringList symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, mStyle->smartgroupId( groupName ) );
434  deselectSymbols( symbolNames );
435  symbolNames = mStyle->symbolsOfSmartgroup( QgsStyle::ColorrampEntity, mStyle->smartgroupId( groupName ) );
436  deselectSymbols( symbolNames );
437 }
438 
440 {
441  if ( ! mGroupSelectionDlg )
442  {
443  mGroupSelectionDlg = new QgsStyleGroupSelectionDialog( mStyle, this );
444  mGroupSelectionDlg->setWindowTitle( tr( "Select Item(s) by Group" ) );
451  }
452  mGroupSelectionDlg->show();
453  mGroupSelectionDlg->raise();
454  mGroupSelectionDlg->activateWindow();
455 }
456 
458 {
459  ImportSource source = static_cast< ImportSource >( importTypeCombo->itemData( index ).toInt() );
460 
461  switch ( source )
462  {
463  case ImportSource::File:
464  {
465  mLocationStackedEdit->setCurrentIndex( 0 );
466  mLocationLabel->setText( tr( "File" ) );
467  break;
468  }
469 #if 0
470  case ImportSource::Official:
471  {
472  btnBrowse->setText( QStringLiteral( "Fetch Items" ) );
473  locationLineEdit->setEnabled( false );
474  break;
475  }
476 #endif
477  case ImportSource::Url:
478  {
479  mLocationStackedEdit->setCurrentIndex( 1 );
480  mLocationLabel->setText( tr( "URL" ) );
481  break;
482  }
483  }
484 }
485 
486 void QgsStyleExportImportDialog::fetch()
487 {
488  downloadStyleXml( QUrl( mUrlLineEdit->text() ) );
489 }
490 
491 void QgsStyleExportImportDialog::importFileChanged( const QString &path )
492 {
493  if ( path.isEmpty() )
494  return;
495 
496  mFileName = path;
497  QFileInfo pathInfo( mFileName );
498  QString tag = pathInfo.fileName().remove( QStringLiteral( ".xml" ) );
499  mSymbolTags->setText( tag );
500  if ( QFileInfo::exists( mFileName ) )
501  {
502  mTempStyle->clear();
503  populateStyles();
504  mImportFileWidget->setDefaultRoot( pathInfo.absolutePath() );
505  QgsSettings settings;
506  settings.setValue( QStringLiteral( "StyleManager/lastImportDir" ), pathInfo.absolutePath(), QgsSettings::Gui );
507  }
508 }
509 
510 void QgsStyleExportImportDialog::downloadStyleXml( const QUrl &url )
511 {
512  // XXX Try to move this code to some core Network interface,
513  // HTTP downloading is a generic functionality that might be used elsewhere
514 
515  mTempFile = new QTemporaryFile();
516  if ( mTempFile->open() )
517  {
518  mFileName = mTempFile->fileName();
519 
520  if ( mProgressDlg )
521  {
522  QProgressDialog *dummy = mProgressDlg;
523  mProgressDlg = nullptr;
524  delete dummy;
525  }
526  mProgressDlg = new QProgressDialog();
527  mProgressDlg->setLabelText( tr( "Downloading style‚Ķ" ) );
528  mProgressDlg->setAutoClose( true );
529 
530  connect( mProgressDlg, &QProgressDialog::canceled, this, &QgsStyleExportImportDialog::downloadCanceled );
531 
532  // open the network connection and connect the respective slots
533  if ( mNetReply )
534  {
535  QNetworkReply *dummyReply = mNetReply;
536  mNetReply = nullptr;
537  delete dummyReply;
538  }
539  mNetReply = mNetManager->get( QNetworkRequest( url ) );
540 
541  connect( mNetReply, &QNetworkReply::finished, this, &QgsStyleExportImportDialog::httpFinished );
542  connect( mNetReply, &QIODevice::readyRead, this, &QgsStyleExportImportDialog::fileReadyRead );
543  connect( mNetReply, &QNetworkReply::downloadProgress, this, &QgsStyleExportImportDialog::updateProgress );
544  }
545 }
546 
547 void QgsStyleExportImportDialog::httpFinished()
548 {
549  if ( mNetReply->error() )
550  {
551  mTempFile->remove();
552  mFileName.clear();
553  mProgressDlg->hide();
554  QMessageBox::information( this, tr( "Import from URL" ),
555  tr( "HTTP Error! Download failed: %1." ).arg( mNetReply->errorString() ) );
556  return;
557  }
558  else
559  {
560  mTempFile->flush();
561  mTempFile->close();
562  mTempStyle->clear();
563  populateStyles();
564  }
565 }
566 
567 void QgsStyleExportImportDialog::fileReadyRead()
568 {
569  mTempFile->write( mNetReply->readAll() );
570 }
571 
572 void QgsStyleExportImportDialog::updateProgress( qint64 bytesRead, qint64 bytesTotal )
573 {
574  mProgressDlg->setMaximum( bytesTotal );
575  mProgressDlg->setValue( bytesRead );
576 }
577 
578 void QgsStyleExportImportDialog::downloadCanceled()
579 {
580  mNetReply->abort();
581  mTempFile->remove();
582  mFileName.clear();
583 }
584 
585 void QgsStyleExportImportDialog::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
586 {
587  Q_UNUSED( selected );
588  Q_UNUSED( deselected );
589  bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
590  buttonBox->button( QDialogButtonBox::Ok )->setDisabled( nothingSelected );
591 }
592 
593 void QgsStyleExportImportDialog::showHelp()
594 {
595  QgsHelp::openHelp( QStringLiteral( "working_with_vector/style_library.html#share-symbols" ) );
596 }
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
Definition: qgsstylemodel.h:41
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:186
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
Definition: qgsstyle.cpp:197
QgsStyleExportImportDialog(QgsStyle *style, QWidget *parent=nullptr, Mode mode=Export)
void fileChanged(const QString &)
emitted as soon as the current file or directory is changed
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:152
This class is a composition of two QSettings instances:
Definition: qgssettings.h:58
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:272
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
Definition: qgsstyle.cpp:1041
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:221
void tagSelected(const QString &tagName)
tag with tagName has been selected
void clearSelection()
clearSelection deselects all symbols
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void smartgroupSelected(const QString &groupName)
smartgroup with groupName has been selected
QStringList symbolsWithTag(StyleEntity type, int tagid) const
Returns the symbol names with which have the given tag.
Definition: qgsstyle.cpp:578
void selectSmartgroup(const QString &groupName)
selectSmartgroup selects all symbols from a smart group
void allDeselected()
all deselected
void deselectSymbols(const QStringList &symbolNames)
deselectSymbols deselect symbols by name
QStringList symbolNames()
Returns a list of names of symbols.
Definition: qgsstyle.cpp:191
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
Definition: qgsstyle.cpp:542
void allSelected()
all selected
QStringList colorRampNames()
Returns a list of names of color ramps.
Definition: qgsstyle.cpp:288
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
Returns the symbols for the smartgroup.
Definition: qgsstyle.cpp:1327
int smartgroupId(const QString &smartgroup)
Returns the DB id for the given smartgroup name.
Definition: qgsstyle.cpp:1221
int tagId(const QString &tag)
Returns the DB id for the given tag name.
Definition: qgsstyle.cpp:1216
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol&#39;s ownership.
Definition: qgsstyle.cpp:88
void addDesiredIconSize(QSize size)
Adds an additional icon size to generate for Qt::DecorationRole data.
Name column.
Definition: qgsstylemodel.h:50
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void selectTag(const QString &tagName)
Select the symbols belonging to the given tag.
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...
Definition: qgsgui.cpp:98
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.
void selectAll()
selectAll selects all symbols
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:175
QVariant data(const QModelIndex &index, int role) const override
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:112
void tagDeselected(const QString &tagName)
tag with tagName has been deselected