QGIS API Documentation  2.11.0-Master
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 ), mAdvancedMenu( NULL ), mVectorLayer( vl )
209 {
210 #ifdef Q_OS_MAC
211  setWindowModality( Qt::WindowModal );
212 #endif
213  mStyle = style;
214  mSymbol = symbol;
215  mPresentWidget = NULL;
216 
217  setupUi( this );
218  // can be embedded in renderer properties dialog
219  if ( embedded )
220  {
221  buttonBox->hide();
222  layout()->setContentsMargins( 0, 0, 0, 0 );
223  }
224  // setup icons
225  btnAddLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
226  btnRemoveLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) );
227  QIcon iconLock;
228  iconLock.addFile( QgsApplication::iconPath( "locked.svg" ), QSize(), QIcon::Normal, QIcon::On );
229  iconLock.addFile( QgsApplication::iconPath( "unlocked.svg" ), QSize(), QIcon::Normal, QIcon::Off );
230  btnLock->setIcon( iconLock );
231  btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) );
232  btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) );
233 
234  model = new QStandardItemModel();
235  // Set the symbol
236  layersTree->setModel( model );
237  layersTree->setHeaderHidden( true );
238 
239  QItemSelectionModel* selModel = layersTree->selectionModel();
240  connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
241 
242  loadSymbol( symbol, static_cast<SymbolLayerItem*>( model->invisibleRootItem() ) );
243  updatePreview();
244 
245  connect( btnUp, SIGNAL( clicked() ), this, SLOT( moveLayerUp() ) );
246  connect( btnDown, SIGNAL( clicked() ), this, SLOT( moveLayerDown() ) );
247  connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) );
248  connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
249  connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
250  connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
251 
252  updateUi();
253 
254  // set symbol as active item in the tree
255  QModelIndex newIndex = layersTree->model()->index( 0, 0 );
256  layersTree->setCurrentIndex( newIndex );
257 }
258 
260 {
261  // Ignore the ESC key to avoid close the dialog without the properties window
262  if ( !isWindow() && e->key() == Qt::Key_Escape )
263  {
264  e->ignore();
265  }
266  else
267  {
269  }
270 }
271 
273 {
274  if ( mAdvancedMenu == NULL )
275  {
276  mAdvancedMenu = new QMenu;
277  // Brute force method to activate the Advanced menu
278  layerChanged();
279  }
280  return mAdvancedMenu;
281 }
282 
284 {
285  SymbolLayerItem* symbolItem = new SymbolLayerItem( symbol );
286  QFont boldFont = symbolItem->font();
287  boldFont.setBold( true );
288  symbolItem->setFont( boldFont );
289  parent->appendRow( symbolItem );
290 
291  int count = symbol->symbolLayerCount();
292  for ( int i = count - 1; i >= 0; i-- )
293  {
294  SymbolLayerItem *layerItem = new SymbolLayerItem( symbol->symbolLayer( i ) );
295  layerItem->setEditable( false );
296  symbolItem->appendRow( layerItem );
297  if ( symbol->symbolLayer( i )->subSymbol() )
298  {
299  loadSymbol( symbol->symbolLayer( i )->subSymbol(), layerItem );
300  }
301  }
302  layersTree->setExpanded( symbolItem->index(), true );
303 }
304 
305 
307 {
308  model->clear();
309  loadSymbol( mSymbol, static_cast<SymbolLayerItem*>( model->invisibleRootItem() ) );
310 }
311 
313 {
314  QModelIndex currentIdx = layersTree->currentIndex();
315  if ( !currentIdx.isValid() )
316  return;
317 
318  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( currentIdx ) );
319  if ( !item->isLayer() )
320  {
321  btnUp->setEnabled( false );
322  btnDown->setEnabled( false );
323  btnRemoveLayer->setEnabled( false );
324  btnLock->setEnabled( false );
325  return;
326  }
327 
328  int rowCount = item->parent()->rowCount();
329  int currentRow = item->row();
330 
331  btnUp->setEnabled( currentRow > 0 );
332  btnDown->setEnabled( currentRow < rowCount - 1 );
333  btnRemoveLayer->setEnabled( rowCount > 1 );
334  btnLock->setEnabled( true );
335 }
336 
338 {
339  QImage preview = mSymbol->bigSymbolPreviewImage();
340  lblPreview->setPixmap( QPixmap::fromImage( preview ) );
341  // Hope this is a appropriate place
342  emit symbolModified();
343 }
344 
346 {
347  // get current layer item and update its icon
349  if ( item )
350  item->updatePreview();
351  // update also preview of the whole symbol
352  updatePreview();
353 }
354 
356 {
357  QModelIndex idx = layersTree->currentIndex();
358  if ( !idx.isValid() )
359  return NULL;
360 
361  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
362  if ( !item->isLayer() )
363  return NULL;
364 
365  return item;
366 }
367 
369 {
370  QModelIndex idx = layersTree->currentIndex();
371  if ( !idx.isValid() )
372  return NULL;
373 
374  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
375  if ( item->isLayer() )
376  return item->layer();
377 
378  return NULL;
379 }
380 
382 {
383  updateUi();
384 
385  SymbolLayerItem *currentItem = static_cast<SymbolLayerItem*>( model->itemFromIndex( layersTree->currentIndex() ) );
386  if ( currentItem == NULL )
387  return;
388 
389  if ( currentItem->isLayer() )
390  {
391  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( currentItem->parent() );
392  mDataDefineRestorer.reset( new DataDefinedRestorer( parent->symbol(), currentItem->layer() ) );
393  QWidget *layerProp = new QgsLayerPropertiesWidget( currentItem->layer(), parent->symbol(), mVectorLayer );
394  setWidget( layerProp );
395  connect( layerProp, SIGNAL( changed() ), mDataDefineRestorer.data(), SLOT( restore() ) );
396  connect( layerProp, SIGNAL( changed() ), this, SLOT( updateLayerPreview() ) );
397  // This connection when layer type is changed
398  connect( layerProp, SIGNAL( changeLayer( QgsSymbolLayerV2* ) ), this, SLOT( changeLayer( QgsSymbolLayerV2* ) ) );
399  }
400  else
401  {
402  mDataDefineRestorer.reset();
403  // then it must be a symbol
404  currentItem->symbol()->setLayer( mVectorLayer );
405  // Now populate symbols of that type using the symbols list widget:
406  QWidget *symbolsList = new QgsSymbolsListWidget( currentItem->symbol(), mStyle, mAdvancedMenu, this, mVectorLayer );
407 
408  setWidget( symbolsList );
409  connect( symbolsList, SIGNAL( changed() ), this, SLOT( symbolChanged() ) );
410  }
412 }
413 
415 {
416  SymbolLayerItem *currentItem = static_cast<SymbolLayerItem*>( model->itemFromIndex( layersTree->currentIndex() ) );
417  if ( currentItem == NULL || currentItem->isLayer() )
418  return;
419  // disconnect to avoid recreating widget
420  disconnect( layersTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
421  if ( currentItem->parent() )
422  {
423  // it is a sub-symbol
424  QgsSymbolV2* symbol = currentItem->symbol();
425  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( currentItem->parent() );
426  parent->removeRow( 0 );
427  loadSymbol( symbol, parent );
428  layersTree->setCurrentIndex( parent->child( 0 )->index() );
429  parent->updatePreview();
430  }
431  else
432  {
433  //it is the symbol itself
434  loadSymbol();
435  QModelIndex newIndex = layersTree->model()->index( 0, 0 );
436  layersTree->setCurrentIndex( newIndex );
437  }
438  updatePreview();
439  // connect it back once things are set
440  connect( layersTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( layerChanged() ) );
441 }
442 
444 {
445  int index = stackedWidget->addWidget( widget );
446  stackedWidget->setCurrentIndex( index );
447  if ( mPresentWidget )
448  {
449  stackedWidget->removeWidget( mPresentWidget );
450  QWidget *dummy = mPresentWidget;
451  mPresentWidget = widget;
452  delete dummy; // auto disconnects all signals
453  }
454 }
455 
457 {
458  QgsSymbolLayerV2* layer = currentLayer();
459  if ( !layer )
460  return;
461  btnLock->setChecked( layer->isLocked() );
462 }
463 
465 {
466  QModelIndex idx = layersTree->currentIndex();
467  if ( !idx.isValid() )
468  return;
469 
470  int insertIdx = -1;
471  SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
472  if ( item->isLayer() )
473  {
474  insertIdx = item->row();
475  item = static_cast<SymbolLayerItem*>( item->parent() );
476  }
477 
478  QgsSymbolV2* parentSymbol = item->symbol();
479 
480  // save data-defined values at marker level
481  QgsDataDefined ddSize = parentSymbol->type() == QgsSymbolV2::Marker
482  ? static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->dataDefinedSize()
483  : QgsDataDefined();
484  QgsDataDefined ddAngle = parentSymbol->type() == QgsSymbolV2::Marker
485  ? static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->dataDefinedAngle()
486  : QgsDataDefined();
487  QgsDataDefined ddWidth = parentSymbol->type() == QgsSymbolV2::Line
488  ? static_cast<QgsLineSymbolV2 *>( parentSymbol )->dataDefinedWidth()
489  : QgsDataDefined() ;
490 
492  if ( insertIdx == -1 )
493  parentSymbol->appendSymbolLayer( newLayer );
494  else
495  parentSymbol->insertSymbolLayer( item->rowCount() - insertIdx, newLayer );
496 
497  // restore data-defined values at marker level
498  if ( ddSize != QgsDataDefined() )
499  static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->setDataDefinedSize( ddSize );
500  if ( ddAngle != QgsDataDefined() )
501  static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->setDataDefinedAngle( ddAngle );
502  if ( ddWidth != QgsDataDefined() )
503  static_cast<QgsLineSymbolV2 *>( parentSymbol )->setDataDefinedWidth( ddWidth );
504 
505  SymbolLayerItem *newLayerItem = new SymbolLayerItem( newLayer );
506  item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
507  item->updatePreview();
508 
509  layersTree->setCurrentIndex( model->indexFromItem( newLayerItem ) );
510  updateUi();
511  updatePreview();
512 }
513 
515 {
517  int row = item->row();
518  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( item->parent() );
519 
520  int layerIdx = parent->rowCount() - row - 1; // IMPORTANT
521  QgsSymbolV2* parentSymbol = parent->symbol();
522  QgsSymbolLayerV2 *tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
523 
524  parent->removeRow( row );
525  parent->updatePreview();
526 
527  QModelIndex newIdx = parent->child( 0 )->index();
528  layersTree->setCurrentIndex( newIdx );
529 
530  updateUi();
531  updatePreview();
532  //finally delete the removed layer pointer
533  delete tmpLayer;
534 }
535 
537 {
538  moveLayerByOffset( + 1 );
539 }
540 
542 {
543  moveLayerByOffset( -1 );
544 }
545 
547 {
549  if ( item == NULL )
550  return;
551  int row = item->row();
552 
553  SymbolLayerItem *parent = static_cast<SymbolLayerItem*>( item->parent() );
554  QgsSymbolV2* parentSymbol = parent->symbol();
555 
556  int layerIdx = parent->rowCount() - row - 1;
557  // switch layers
558  QgsSymbolLayerV2* tmpLayer = parentSymbol->takeSymbolLayer( layerIdx );
559  parentSymbol->insertSymbolLayer( layerIdx - offset, tmpLayer );
560 
561  QList<QStandardItem*> rowItems = parent->takeRow( row );
562  parent->insertRows( row + offset, rowItems );
563  parent->updatePreview();
564 
565  QModelIndex newIdx = rowItems[ 0 ]->index();
566  layersTree->setCurrentIndex( newIdx );
567 
568  updatePreview();
569  updateUi();
570 }
571 
573 {
574  QgsSymbolLayerV2* layer = currentLayer();
575  if ( !layer )
576  return;
577  layer->setLocked( btnLock->isChecked() );
578 }
579 
581 {
582  bool ok;
583  QString name = QInputDialog::getText( this, tr( "Symbol name" ),
584  tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
585  if ( !ok || name.isEmpty() )
586  return;
587 
588  // check if there is no symbol with same name
589  if ( mStyle->symbolNames().contains( name ) )
590  {
591  int res = QMessageBox::warning( this, tr( "Save symbol" ),
592  tr( "Symbol with name '%1' already exists. Overwrite?" )
593  .arg( name ),
594  QMessageBox::Yes | QMessageBox::No );
595  if ( res != QMessageBox::Yes )
596  {
597  return;
598  }
599  }
600 
601  // add new symbol to style and re-populate the list
602  mStyle->addSymbol( name, mSymbol->clone() );
603 
604  // make sure the symbol is stored
605  mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
606 }
607 
609 {
611  QgsSymbolLayerV2* layer = item->layer();
612 
613  if ( layer->subSymbol() )
614  {
615  item->removeRow( 0 );
616  }
617  // update symbol layer item
618  item->setLayer( newLayer );
619  // When it is a marker symbol
620  if ( newLayer->subSymbol() )
621  {
622  loadSymbol( newLayer->subSymbol(), item );
623  layersTree->setExpanded( item->index(), true );
624  }
625 
626  // Change the symbol at last to avoid deleting item's layer
627  QgsSymbolV2* symbol = static_cast<SymbolLayerItem*>( item->parent() )->symbol();
628  int layerIdx = item->parent()->rowCount() - item->row() - 1;
629  symbol->changeSymbolLayer( layerIdx, newLayer );
630 
631  item->updatePreview();
632  updatePreview();
633  // Important: This lets the layer to have its own layer properties widget
634  layerChanged();
635 }
QLayout * layout() const
void setLocked(bool locked)
int type() const override
QgsSymbolLayerV2 * layer()
static unsigned index
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
bool saveSymbol(QString name, QgsSymbolV2 *symbol, int groupid, QStringList tags)
add the symbol to the DB with the tags
Definition: qgsstylev2.cpp:107
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:86
void setWindowModality(Qt::WindowModality windowModality)
static QString iconPath(QString iconFile)
Returns path to the desired icon file.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
virtual QgsSymbolV2 * clone() const =0
QStyle * style() const
QgsSymbolLayerV2AbstractMetadata * symbolLayerMetadata(QString name) const
return metadata for specified symbol layer. Returns NULL if not found
SymbolLayerItem(QgsSymbolV2 *symbol)
void symbolChanged()
Slot to update tree when a new symbol from style.
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)
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)
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
void reset(T *other)
bool addSymbol(QString name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
Definition: qgsstylev2.cpp:83
void setBold(bool enable)
DataDefinedRestorer(QgsSymbolV2 *symbol, const QgsSymbolLayerV2 *symbolLayer)
const char * name() const
bool isValid() const
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
void ignore()
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
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 appendRow(const QList< QStandardItem * > &items)
void setLayer(const QgsVectorLayer *layer)
Definition: qgssymbolv2.h:188
static const int SymbolLayerItemType
void insertRows(int row, const QList< QStandardItem * > &items)
bool isEmpty() const
QStandardItem * parent() const
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:113
QStringList symbolNames()
return a list of names of symbols
Definition: qgsstylev2.cpp:182
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
const QAbstractItemModel * model() const
void setLayer(QgsSymbolLayerV2 *layer)
bool insertSymbolLayer(int index, QgsSymbolLayerV2 *layer)
insert symbol layer to specified index
bool isLocked() const
QStandardItem * itemFromIndex(const QModelIndex &index) const
double offset() const
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
int row() const
QImage bigSymbolPreviewImage()
virtual QVariant data(int role) const
QIcon icon() const
void insertRow(int row, const QList< QStandardItem * > &items)
void setEditable(bool editable)