QGIS API Documentation  2.12.0-Lyon
qgssymbolv2selectordialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolv2selectordialog.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgsstylev2.h"
19 #include "qgssymbolv2.h"
20 #include "qgssymbollayerv2.h"
21 #include "qgssymbollayerv2utils.h"
23 #include "qgsdatadefined.h"
24 
25 // the widgets
26 #include "qgssymbolslistwidget.h"
28 #include "qgssymbollayerv2widget.h"
31 
32 #include "qgslogger.h"
33 #include "qgsapplication.h"
34 
35 #include <QColorDialog>
36 #include <QPainter>
37 #include <QStandardItemModel>
38 #include <QInputDialog>
39 #include <QMessageBox>
40 #include <QKeyEvent>
41 #include <QMenu>
42 
43 #include <QWidget>
44 #include <QFile>
45 #include <QStandardItem>
46 
47 static const int SymbolLayerItemType = QStandardItem::UserType + 1;
48 
50  : mMarker( NULL )
51  , mMarkerSymbolLayer( NULL )
52  , mLine( NULL )
53  , mLineSymbolLayer( NULL )
54 {
55  if ( symbolLayer->type() == QgsSymbolV2::Marker && symbol->type() == QgsSymbolV2::Marker )
56  {
57  Q_ASSERT( symbol->type() == QgsSymbolV2::Marker );
58  mMarker = static_cast<QgsMarkerSymbolV2*>( symbol );
59  mMarkerSymbolLayer = static_cast<const QgsMarkerSymbolLayerV2*>( symbolLayer );
60  mDDSize = mMarker->dataDefinedSize();
61  mDDAngle = mMarker->dataDefinedAngle();
62  // check if restore is actually needed
63  if ( mDDSize == QgsDataDefined() && mDDAngle == QgsDataDefined() )
64  mMarker = NULL;
65  }
66  else if ( symbolLayer->type() == QgsSymbolV2::Line && symbol->type() == QgsSymbolV2::Line )
67  {
68  mLine = static_cast<QgsLineSymbolV2*>( symbol );
69  mLineSymbolLayer = static_cast<const QgsLineSymbolLayerV2*>( symbolLayer );
70  mDDWidth = mLine->dataDefinedWidth();
71  // check if restore is actually needed
72  if ( mDDWidth == QgsDataDefined() )
73  mLine = NULL;
74  }
75  save();
76 }
77 
78 void DataDefinedRestorer::save()
79 {
80  if ( mMarker )
81  {
82  mSize = mMarkerSymbolLayer->size();
83  mAngle = mMarkerSymbolLayer->angle();
84  mMarkerOffset = mMarkerSymbolLayer->offset();
85  }
86  else if ( mLine )
87  {
88  mWidth = mLineSymbolLayer->width();
89  mLineOffset = mLineSymbolLayer->offset();
90  }
91 }
92 
94 {
95  if ( mMarker )
96  {
97  if ( mDDSize != QgsDataDefined() &&
98  ( mSize != mMarkerSymbolLayer->size() || mMarkerOffset != mMarkerSymbolLayer->offset() ) )
99  mMarker->setDataDefinedSize( mDDSize );
100  if ( mDDAngle != QgsDataDefined() &&
101  mAngle != mMarkerSymbolLayer->angle() )
102  mMarker->setDataDefinedAngle( mDDAngle );
103  }
104  else if ( mLine )
105  {
106  if ( mDDWidth != QgsDataDefined() &&
107  ( mWidth != mLineSymbolLayer->width() || mLineOffset != mLineSymbolLayer->offset() ) )
108  mLine->setDataDefinedWidth( mDDWidth );
109  }
110  save();
111 }
112 
113 // Hybrid item which may represent a symbol or a layer
114 // Check using item->isLayer()
116 {
117  public:
119  {
120  setLayer( layer );
121  }
122 
124  {
125  setSymbol( symbol );
126  }
127 
129  {
130  mLayer = layer;
131  mIsLayer = true;
132  mSymbol = NULL;
133  updatePreview();
134  }
135 
137  {
138  mSymbol = symbol;
139  mIsLayer = false;
140  mLayer = NULL;
141  updatePreview();
142  }
143 
145  {
146  QIcon icon;
147  if ( mIsLayer )
148  icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( mLayer, QgsSymbolV2::MM, QSize( 16, 16 ) ); //todo: make unit a parameter
149  else
151  setIcon( icon );
152 
153  if ( parent() )
154  static_cast<SymbolLayerItem*>( parent() )->updatePreview();
155  }
156 
157  int type() const override { return SymbolLayerItemType; }
158  bool isLayer() { return mIsLayer; }
159 
160  // returns the symbol pointer; helpful in determining a layer's parent symbol
162  {
163  if ( mIsLayer )
164  return NULL;
165  return mSymbol;
166  }
167 
169  {
170  if ( mIsLayer )
171  return mLayer;
172  return NULL;
173  }
174 
175  QVariant data( int role ) const override
176  {
177  if ( role == Qt::DisplayRole || role == Qt::EditRole )
178  {
179  if ( mIsLayer )
181  else
182  {
183  switch ( mSymbol->type() )
184  {
185  case QgsSymbolV2::Marker : return "Marker";
186  case QgsSymbolV2::Fill : return "Fill";
187  case QgsSymbolV2::Line : return "Line";
188  default: return "Symbol";
189  }
190  }
191  }
192  if ( role == Qt::SizeHintRole )
193  return QVariant( QSize( 32, 32 ) );
194  if ( role == Qt::CheckStateRole )
195  return QVariant(); // could be true/false
196  return QStandardItem::data( role );
197  }
198 
199  protected:
202  bool mIsLayer;
203 };
204 
206 
208  : QDialog( parent )
209  , mAdvancedMenu( NULL )
210  , mVectorLayer( vl )
211  , mMapCanvas( 0 )
212 {
213 #ifdef Q_OS_MAC
214  setWindowModality( Qt::WindowModal );
215 #endif
216  mStyle = style;
217  mSymbol = symbol;
218  mPresentWidget = NULL;
219 
220  setupUi( this );
221 
222  QSettings settings;
223  restoreGeometry( settings.value( "/Windows/SymbolSelectorDialog/geometry" ).toByteArray() );
224 
225  // can be embedded in renderer properties dialog
226  if ( embedded )
227  {
228  buttonBox->hide();
229  layout()->setContentsMargins( 0, 0, 0, 0 );
230  }
231  // setup icons
232  btnAddLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
233  btnRemoveLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) );
234  QIcon iconLock;
235  iconLock.addFile( QgsApplication::iconPath( "locked.svg" ), QSize(), QIcon::Normal, QIcon::On );
236  iconLock.addFile( QgsApplication::iconPath( "unlocked.svg" ), QSize(), QIcon::Normal, QIcon::Off );
237  btnLock->setIcon( iconLock );
238  btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) );
239  btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) );
240 
241  model = new QStandardItemModel( layersTree );
242  // Set the symbol
243  layersTree->setModel( model );
244  layersTree->setHeaderHidden( true );
245 
246  QItemSelectionModel* selModel = layersTree->selectionModel();
247  connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
248 
249  loadSymbol( symbol, static_cast<SymbolLayerItem*>( model->invisibleRootItem() ) );
250  updatePreview();
251 
252  connect( btnUp, SIGNAL( clicked() ), this, SLOT( moveLayerUp() ) );
253  connect( btnDown, SIGNAL( clicked() ), this, SLOT( moveLayerDown() ) );
254  connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) );
255  connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
256  connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
257  connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
258 
259  updateUi();
260 
261  // set symbol as active item in the tree
262  QModelIndex newIndex = layersTree->model()->index( 0, 0 );
263  layersTree->setCurrentIndex( newIndex );
264 }
265 
267 {
268  QSettings settings;
269  settings.setValue( "/Windows/SymbolSelectorDialog/geometry", saveGeometry() );
270 }
271 
273 {
274  // Ignore the ESC key to avoid close the dialog without the properties window
275  if ( !isWindow() && e->key() == Qt::Key_Escape )
276  {
277  e->ignore();
278  }
279  else
280  {
282  }
283 }
284 
286 {
287  if ( mAdvancedMenu == NULL )
288  {
289  mAdvancedMenu = new QMenu( this );
290  // Brute force method to activate the Advanced menu
291  layerChanged();
292  }
293  return mAdvancedMenu;
294 }
295 
297 {
298  mPresetExpressionContext.reset( context );
299  layerChanged();
300  updatePreview();
301 }
302 
304 {
305  mMapCanvas = canvas;
306 
307  QWidget* widget = stackedWidget->currentWidget();
308  QgsLayerPropertiesWidget* layerProp = dynamic_cast< QgsLayerPropertiesWidget* >( widget );
309  QgsSymbolsListWidget* listWidget = dynamic_cast< QgsSymbolsListWidget* >( widget );
310 
311  if ( layerProp )
312  layerProp->setMapCanvas( canvas );
313  if ( listWidget )
314  listWidget->setMapCanvas( canvas );
315 }
316 
318 {
319  SymbolLayerItem* symbolItem = new SymbolLayerItem( symbol );
320  QFont boldFont = symbolItem->font();
321  boldFont.setBold( true );
322  symbolItem->setFont( boldFont );
323  parent->appendRow( symbolItem );
324 
325  int count = symbol->symbolLayerCount();
326  for ( int i = count - 1; i >= 0; i-- )
327  {
328  SymbolLayerItem *layerItem = new SymbolLayerItem( symbol->symbolLayer( i ) );
329  layerItem->setEditable( false );
330  symbolItem->appendRow( layerItem );
331  if ( symbol->symbolLayer( i )->subSymbol() )
332  {
333  loadSymbol( symbol->symbolLayer( i )->subSymbol(), layerItem );
334  }
335  }
336  layersTree->setExpanded( symbolItem->index(), true );
337 }
338 
339 
341 {
342  model->clear();
343  loadSymbol( mSymbol, static_cast<SymbolLayerItem*>( model->invisibleRootItem() ) );
344 }
345 
347 {
348  QModelIndex currentIdx = layersTree->currentIndex();
349  if ( !currentIdx.isValid() )
350  return;
351 
352  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( currentIdx ) );
353  if ( !item->isLayer() )
354  {
355  btnUp->setEnabled( false );
356  btnDown->setEnabled( false );
357  btnRemoveLayer->setEnabled( false );
358  btnLock->setEnabled( false );
359  return;
360  }
361 
362  int rowCount = item->parent()->rowCount();
363  int currentRow = item->row();
364 
365  btnUp->setEnabled( currentRow > 0 );
366  btnDown->setEnabled( currentRow < rowCount - 1 );
367  btnRemoveLayer->setEnabled( rowCount > 1 );
368  btnLock->setEnabled( true );
369 }
370 
372 {
373  QImage preview = mSymbol->bigSymbolPreviewImage( mPresetExpressionContext.data() );
374  lblPreview->setPixmap( QPixmap::fromImage( preview ) );
375  // Hope this is a appropriate place
376  emit symbolModified();
377 }
378 
380 {
381  // get current layer item and update its icon
383  if ( item )
384  item->updatePreview();
385  // update also preview of the whole symbol
386  updatePreview();
387 }
388 
390 {
391  QModelIndex idx = layersTree->currentIndex();
392  if ( !idx.isValid() )
393  return NULL;
394 
395  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
396  if ( !item->isLayer() )
397  return NULL;
398 
399  return item;
400 }
401 
403 {
404  QModelIndex idx = layersTree->currentIndex();
405  if ( !idx.isValid() )
406  return NULL;
407 
408  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
409  if ( item->isLayer() )
410  return item->layer();
411 
412  return NULL;
413 }
414 
416 {
417  updateUi();
418 
419  SymbolLayerItem *currentItem = static_cast<SymbolLayerItem*>( model->itemFromIndex( layersTree->currentIndex() ) );
420  if ( currentItem == NULL )
421  return;
422 
423  if ( currentItem->isLayer() )
424  {
425  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( currentItem->parent() );
426  mDataDefineRestorer.reset( new DataDefinedRestorer( parent->symbol(), currentItem->layer() ) );
427  QgsLayerPropertiesWidget *layerProp = new QgsLayerPropertiesWidget( currentItem->layer(), parent->symbol(), mVectorLayer );
428  layerProp->setExpressionContext( mPresetExpressionContext.data() );
429  layerProp->setMapCanvas( mMapCanvas );
430  setWidget( layerProp );
431  connect( layerProp, SIGNAL( changed() ), mDataDefineRestorer.data(), SLOT( restore() ) );
432  connect( layerProp, SIGNAL( changed() ), this, SLOT( updateLayerPreview() ) );
433  // This connection when layer type is changed
434  connect( layerProp, SIGNAL( changeLayer( QgsSymbolLayerV2* ) ), this, SLOT( changeLayer( QgsSymbolLayerV2* ) ) );
435  }
436  else
437  {
438  mDataDefineRestorer.reset();
439  // then it must be a symbol
440  currentItem->symbol()->setLayer( mVectorLayer );
441  // Now populate symbols of that type using the symbols list widget:
442  QgsSymbolsListWidget *symbolsList = new QgsSymbolsListWidget( currentItem->symbol(), mStyle, mAdvancedMenu, this, mVectorLayer );
443  symbolsList->setExpressionContext( mPresetExpressionContext.data() );
444  symbolsList->setMapCanvas( mMapCanvas );
445 
446  setWidget( symbolsList );
447  connect( symbolsList, SIGNAL( changed() ), this, SLOT( symbolChanged() ) );
448  }
450 }
451 
453 {
454  SymbolLayerItem *currentItem = static_cast<SymbolLayerItem*>( model->itemFromIndex( layersTree->currentIndex() ) );
455  if ( currentItem == NULL || currentItem->isLayer() )
456  return;
457  // disconnect to avoid recreating widget
458  disconnect( layersTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
459  if ( currentItem->parent() )
460  {
461  // it is a sub-symbol
462  QgsSymbolV2* symbol = currentItem->symbol();
463  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( currentItem->parent() );
464  parent->removeRow( 0 );
465  loadSymbol( symbol, parent );
466  layersTree->setCurrentIndex( parent->child( 0 )->index() );
467  parent->updatePreview();
468  }
469  else
470  {
471  //it is the symbol itself
472  loadSymbol();
473  QModelIndex newIndex = layersTree->model()->index( 0, 0 );
474  layersTree->setCurrentIndex( newIndex );
475  }
476  updatePreview();
477  // connect it back once things are set
478  connect( layersTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
479 }
480 
482 {
483  int index = stackedWidget->addWidget( widget );
484  stackedWidget->setCurrentIndex( index );
485  if ( mPresentWidget )
487  mPresentWidget = widget;
488 }
489 
491 {
492  QgsSymbolLayerV2* layer = currentLayer();
493  if ( !layer )
494  return;
495  btnLock->setChecked( layer->isLocked() );
496 }
497 
499 {
500  QModelIndex idx = layersTree->currentIndex();
501  if ( !idx.isValid() )
502  return;
503 
504  int insertIdx = -1;
505  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
506  if ( item->isLayer() )
507  {
508  insertIdx = item->row();
509  item = static_cast<SymbolLayerItem*>( item->parent() );
510  }
511 
512  QgsSymbolV2* parentSymbol = item->symbol();
513 
514  // save data-defined values at marker level
515  QgsDataDefined ddSize = parentSymbol->type() == QgsSymbolV2::Marker
516  ? static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->dataDefinedSize()
517  : QgsDataDefined();
518  QgsDataDefined ddAngle = parentSymbol->type() == QgsSymbolV2::Marker
519  ? static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->dataDefinedAngle()
520  : QgsDataDefined();
521  QgsDataDefined ddWidth = parentSymbol->type() == QgsSymbolV2::Line
522  ? static_cast<QgsLineSymbolV2 *>( parentSymbol )->dataDefinedWidth()
523  : QgsDataDefined() ;
524 
526  if ( insertIdx == -1 )
527  parentSymbol->appendSymbolLayer( newLayer );
528  else
529  parentSymbol->insertSymbolLayer( item->rowCount() - insertIdx, newLayer );
530 
531  // restore data-defined values at marker level
532  if ( ddSize != QgsDataDefined() )
533  static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->setDataDefinedSize( ddSize );
534  if ( ddAngle != QgsDataDefined() )
535  static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->setDataDefinedAngle( ddAngle );
536  if ( ddWidth != QgsDataDefined() )
537  static_cast<QgsLineSymbolV2 *>( parentSymbol )->setDataDefinedWidth( ddWidth );
538 
539  SymbolLayerItem *newLayerItem = new SymbolLayerItem( newLayer );
540  item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
541  item->updatePreview();
542 
543  layersTree->setCurrentIndex( model->indexFromItem( newLayerItem ) );
544  updateUi();
545  updatePreview();
546 }
547 
549 {
551  int row = item->row();
552  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( item->parent() );
553 
554  int layerIdx = parent->rowCount() - row - 1; // IMPORTANT
555  QgsSymbolV2* parentSymbol = parent->symbol();
556  QgsSymbolLayerV2 *tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
557 
558  parent->removeRow( row );
559  parent->updatePreview();
560 
561  QModelIndex newIdx = parent->child( 0 )->index();
562  layersTree->setCurrentIndex( newIdx );
563 
564  updateUi();
565  updatePreview();
566  //finally delete the removed layer pointer
567  delete tmpLayer;
568 }
569 
571 {
572  moveLayerByOffset( + 1 );
573 }
574 
576 {
577  moveLayerByOffset( -1 );
578 }
579 
581 {
583  if ( item == NULL )
584  return;
585  int row = item->row();
586 
587  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( item->parent() );
588  QgsSymbolV2* parentSymbol = parent->symbol();
589 
590  int layerIdx = parent->rowCount() - row - 1;
591  // switch layers
592  QgsSymbolLayerV2* tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
593  parentSymbol->insertSymbolLayer( layerIdx - offset, tmpLayer );
594 
595  QList<QStandardItem*> rowItems = parent->takeRow( row );
596  parent->insertRows( row + offset, rowItems );
597  parent->updatePreview();
598 
599  QModelIndex newIdx = rowItems[ 0 ]->index();
600  layersTree->setCurrentIndex( newIdx );
601 
602  updatePreview();
603  updateUi();
604 }
605 
607 {
608  QgsSymbolLayerV2* layer = currentLayer();
609  if ( !layer )
610  return;
611  layer->setLocked( btnLock->isChecked() );
612 }
613 
615 {
616  bool ok;
617  QString name = QInputDialog::getText( this, tr( "Symbol name" ),
618  tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
619  if ( !ok || name.isEmpty() )
620  return;
621 
622  // check if there is no symbol with same name
623  if ( mStyle->symbolNames().contains( name ) )
624  {
625  int res = QMessageBox::warning( this, tr( "Save symbol" ),
626  tr( "Symbol with name '%1' already exists. Overwrite?" )
627  .arg( name ),
628  QMessageBox::Yes | QMessageBox::No );
629  if ( res != QMessageBox::Yes )
630  {
631  return;
632  }
633  }
634 
635  // add new symbol to style and re-populate the list
636  mStyle->addSymbol( name, mSymbol->clone() );
637 
638  // make sure the symbol is stored
639  mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
640 }
641 
643 {
645  QgsSymbolLayerV2* layer = item->layer();
646 
647  if ( layer->subSymbol() )
648  {
649  item->removeRow( 0 );
650  }
651  // update symbol layer item
652  item->setLayer( newLayer );
653  // When it is a marker symbol
654  if ( newLayer->subSymbol() )
655  {
656  loadSymbol( newLayer->subSymbol(), item );
657  layersTree->setExpanded( item->index(), true );
658  }
659 
660  // Change the symbol at last to avoid deleting item's layer
661  QgsSymbolV2* symbol = static_cast<SymbolLayerItem*>( item->parent() )->symbol();
662  int layerIdx = item->parent()->rowCount() - item->row() - 1;
663  symbol->changeSymbolLayer( layerIdx, newLayer );
664 
665  item->updatePreview();
666  updatePreview();
667  // Important: This lets the layer to have its own layer properties widget
668  layerChanged();
669 }
QLayout * layout() const
void setLocked(bool locked)
QByteArray toByteArray() const
int type() const override
QgsSymbolLayerV2 * layer()
static unsigned index
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
void setContentsMargins(int left, int top, int right, int bottom)
void setupUi(QWidget *widget)
static QgsSymbolLayerV2 * defaultSymbolLayer(QgsSymbolV2::SymbolType type)
create a new instance of symbol layer for specified symbol type with default settings ...
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
void setIcon(const QIcon &icon)
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
virtual double width() const
QVariant data(int role) const override
QStandardItem * invisibleRootItem() const
QList< QStandardItem * > takeRow(int row)
SymbolType type() const
Definition: qgssymbolv2.h:95
bool addSymbol(const QString &name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
Definition: qgsstylev2.cpp:83
void setWindowModality(Qt::WindowModality windowModality)
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
virtual QgsSymbolV2 * clone() const =0
QStyle * style() const
SymbolLayerItem(QgsSymbolV2 *symbol)
void symbolChanged()
Slot to update tree when a new symbol from style.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
bool changeSymbolLayer(int index, QgsSymbolLayerV2 *layer)
delete layer at specified index and set a new one
void removeRow(int row)
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
Line symbol.
Definition: qgssymbolv2.h:71
static QgsSymbolLayerV2Registry * instance()
return the single instance of this class (instantiate it if not exists)
SymbolLayerItem(QgsSymbolLayerV2 *layer)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
const QgsVectorLayer * mVectorLayer
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:107
Marker symbol.
Definition: qgssymbolv2.h:70
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
void reset(T *other)
void setBold(bool enable)
void setValue(const QString &key, const QVariant &value)
DataDefinedRestorer(QgsSymbolV2 *symbol, const QgsSymbolLayerV2 *symbolLayer)
const char * name() const
bool isValid() const
The output shall be in millimeters.
Definition: qgssymbolv2.h:57
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
void ignore()
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
Append symbol layer at the end of the list Ownership will be transferred.
bool saveSymbol(const QString &name, QgsSymbolV2 *symbol, int groupid, const QStringList &tags)
add the symbol to the DB with the tags
Definition: qgsstylev2.cpp:107
void keyPressEvent(QKeyEvent *event) override
Reimplements dialog keyPress event so we can ignore it.
QModelIndex indexFromItem(const QStandardItem *item) const
QMenu * advancedMenu()
return menu for "advanced" button - create it if doesn't exist and show the advanced button ...
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
bool restoreGeometry(const QByteArray &geometry)
void appendRow(const QList< QStandardItem * > &items)
void setLayer(const QgsVectorLayer *layer)
Definition: qgssymbolv2.h:221
static const int SymbolLayerItemType
void insertRows(int row, const QList< QStandardItem * > &items)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isEmpty() const
QStandardItem * parent() const
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:122
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void deleteLater()
QStringList symbolNames()
return a list of names of symbols
Definition: qgsstylev2.cpp:182
QgsSymbolLayerV2AbstractMetadata * symbolLayerMetadata(const QString &name) const
return metadata for specified symbol layer. Returns NULL if not found
QStandardItem * child(int row, int column) const
bool isWindow() const
void setFont(const QFont &font)
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, QFlags< Qt::WindowType > flags, QFlags< Qt::InputMethodHint > inputMethodHints)
QgsSymbolV2::SymbolType type() const
QgsSymbolV2SelectorDialog(QgsSymbolV2 *symbol, QgsStyleV2 *style, const QgsVectorLayer *vl, QWidget *parent=0, bool embedded=false)
T * data() const
void setEnabled(bool enabled)
int key() const
virtual QString layerType() const =0
virtual QgsSymbolV2 * subSymbol()
void addFile(const QString &fileName, const QSize &size, Mode mode, State state)
virtual void keyPressEvent(QKeyEvent *e)
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
QFont font() const
QVariant value(const QString &key, const QVariant &defaultValue) const
const QAbstractItemModel * model() const
void setLayer(QgsSymbolLayerV2 *layer)
bool insertSymbolLayer(int index, QgsSymbolLayerV2 *layer)
Insert symbol layer to specified index Ownership will be transferred.
QByteArray saveGeometry() const
bool isLocked() const
QImage bigSymbolPreviewImage(QgsExpressionContext *expressionContext=0)
Returns a large (roughly 100x100 pixel) preview image for the symbol.
QStandardItem * itemFromIndex(const QModelIndex &index) const
double offset() const
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
Fill symbol.
Definition: qgssymbolv2.h:72
void changeLayer(QgsSymbolLayerV2 *layer)
alters tree and sets proper widget when Layer Type is changed
QModelIndex index() const
int rowCount() const
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
QgsSymbolLayerV2 * takeSymbolLayer(int index)
Remove symbol layer from the list and return pointer to it.
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
void setSymbol(QgsSymbolV2 *symbol)
Represents a vector layer which manages a vector based data sets.
QPointF offset() const
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
int row() const
virtual QVariant data(int role) const
QIcon icon() const
void insertRow(int row, const QList< QStandardItem * > &items)
void setEditable(bool editable)