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