QGIS API Documentation
qgssymbolslistwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolslist.cpp
3  ---------------------
4  begin : June 2012
5  copyright : (C) 2012 by Arunmozhi
6  email : aruntheguy at gmail.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 
16 
17 #include "qgssymbolslistwidget.h"
18 
19 #include "qgssizescalewidget.h"
20 
22 #include "qgsdatadefined.h"
23 
24 #include "qgssymbolv2.h"
25 #include "qgsstylev2.h"
26 #include "qgssymbollayerv2utils.h"
27 #include "qgsmarkersymbollayerv2.h"
28 #include "qgsmapcanvas.h"
29 #include "qgsapplication.h"
30 
31 #include <QString>
32 #include <QStringList>
33 #include <QPainter>
34 #include <QIcon>
35 #include <QStandardItemModel>
36 #include <QColorDialog>
37 #include <QInputDialog>
38 #include <QMessageBox>
39 #include <QMenu>
40 #include <QScopedPointer>
41 
42 
44  : QWidget( parent )
45  , mSymbol( symbol )
46  , mStyle( style )
47  , mAdvancedMenu( nullptr )
48  , mClipFeaturesAction( nullptr )
49  , mLayer( layer )
50  , mMapCanvas( nullptr )
51  , mPresetExpressionContext( nullptr )
52 {
53  setupUi( this );
54 
56 
57  btnAdvanced->hide(); // advanced button is hidden by default
58  if ( menu ) // show it if there is a menu pointer
59  {
60  mAdvancedMenu = menu;
61  btnAdvanced->show();
62  btnAdvanced->setMenu( mAdvancedMenu );
63  }
64  else
65  {
66  btnAdvanced->setMenu( new QMenu( this ) );
67  }
68  mClipFeaturesAction = new QAction( tr( "Clip features to canvas extent" ), this );
70  connect( mClipFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( clipFeaturesToggled( bool ) ) );
71 
72  // populate the groups
73  groupsCombo->addItem( "" );
74  populateGroups();
75  QStringList groups = style->smartgroupNames();
76  Q_FOREACH ( const QString& group, groups )
77  {
78  groupsCombo->addItem( group, QVariant( "smart" ) );
79  }
80 
81  QStandardItemModel* model = new QStandardItemModel( viewSymbols );
82  viewSymbols->setModel( model );
83  connect( viewSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );
84 
85  connect( mStyle, SIGNAL( symbolSaved( QString, QgsSymbolV2* ) ), this, SLOT( symbolAddedToStyle( QString, QgsSymbolV2* ) ) );
86  connect( openStyleManagerButton, SIGNAL( pressed() ), this, SLOT( openStyleManager() ) );
87 
88  lblSymbolName->setText( "" );
90 
91  if ( mSymbol )
92  {
94  }
95 
96  // select correct page in stacked widget
97  // there's a correspondence between symbol type number and page numbering => exploit it!
98  stackedWidget->setCurrentIndex( symbol->type() );
99  connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setSymbolColor( const QColor& ) ) );
100  connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setMarkerAngle( double ) ) );
101  connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setMarkerSize( double ) ) );
102  connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( setLineWidth( double ) ) );
103 
104  connect( mRotationDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedMarkerAngle() ) );
105  connect( mRotationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedMarkerAngle() ) );
106  connect( mSizeDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedMarkerSize() ) );
107  connect( mSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedMarkerSize() ) );
108  connect( mWidthDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedLineWidth() ) );
109  connect( mWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedLineWidth() ) );
110 
111  if ( mSymbol->type() == QgsSymbolV2::Marker && mLayer )
112  mSizeDDBtn->setAssistant( tr( "Size Assistant..." ), new QgsSizeScaleWidget( mLayer, mSymbol ) );
113  else if ( mSymbol->type() == QgsSymbolV2::Line && mLayer )
114  mWidthDDBtn->setAssistant( tr( "Width Assistant..." ), new QgsSizeScaleWidget( mLayer, mSymbol ) );
115 
116  // Live color updates are not undoable to child symbol layers
117  btnColor->setAcceptLiveUpdates( false );
118  btnColor->setAllowAlpha( true );
119  btnColor->setColorDialogTitle( tr( "Select color" ) );
120  btnColor->setContext( "symbology" );
121 
122  connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
123 }
124 
126 {
127  // This action was added to the menu by this widget, clean it up
128  // The menu can be passed in the constructor, so may live longer than this widget
129  btnAdvanced->menu()->removeAction( mClipFeaturesAction );
130 }
131 
133 {
134  mMapCanvas = canvas;
135  Q_FOREACH ( QgsUnitSelectionWidget* unitWidget, findChildren<QgsUnitSelectionWidget*>() )
136  {
137  unitWidget->setMapCanvas( canvas );
138  }
139  Q_FOREACH ( QgsDataDefinedButton* ddButton, findChildren<QgsDataDefinedButton*>() )
140  {
141  if ( ddButton->assistant() )
142  ddButton->assistant()->setMapCanvas( mMapCanvas );
143  }
144 }
145 
147 {
148  return mMapCanvas;
149 }
150 
152 {
153  mPresetExpressionContext = context;
154 }
155 
156 void QgsSymbolsListWidget::populateGroups( const QString& parent, const QString& prepend )
157 {
158  QgsSymbolGroupMap groups = mStyle->childGroupNames( parent );
160  while ( i != groups.constEnd() )
161  {
162  QString text;
163  if ( !prepend.isEmpty() )
164  {
165  text = prepend + '/' + i.value();
166  }
167  else
168  {
169  text = i.value();
170  }
171  groupsCombo->addItem( text, QVariant( i.key() ) );
172  populateGroups( i.value(), text );
173  ++i;
174  }
175 }
176 
178 {
180 }
181 
183 {
184  QSize previewSize = viewSymbols->iconSize();
185  QPixmap p( previewSize );
186  QPainter painter;
187 
188  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
189  if ( !model )
190  {
191  return;
192  }
193  model->clear();
194 
195  for ( int i = 0; i < names.count(); i++ )
196  {
197  QgsSymbolV2* s = mStyle->symbol( names[i] );
198  if ( s->type() != mSymbol->type() )
199  {
200  delete s;
201  continue;
202  }
203  QStandardItem* item = new QStandardItem( names[i] );
204  item->setData( names[i], Qt::UserRole ); //so we can load symbol with that name
205  item->setText( names[i] );
206  item->setToolTip( names[i] );
207  item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
208  // Set font to 10points to show reasonable text
209  QFont itemFont = item->font();
210  itemFont.setPointSize( 10 );
211  item->setFont( itemFont );
212  // create preview icon
214  item->setIcon( icon );
215  // add to model
216  model->appendRow( item );
217  delete s;
218  }
219 }
220 
222 {
223  QgsStyleV2ManagerDialog dlg( mStyle, this );
224  dlg.exec();
225 
227 }
228 
230 {
231  if ( !mSymbol )
232  return;
233 
234  mSymbol->setClipFeaturesToExtent( checked );
235  emit changed();
236 }
237 
239 {
240  mSymbol->setColor( color );
241  emit changed();
242 }
243 
245 {
246  QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
247  if ( markerSymbol->angle() == angle )
248  return;
249  markerSymbol->setAngle( angle );
250  emit changed();
251 }
252 
254 {
255  QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
256  QgsDataDefined dd = mRotationDDBtn->currentDataDefined();
257 
258  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
259 
260  bool isDefault = dd.hasDefaultValues();
261 
262  if ( // shall we remove datadefined expressions for layers ?
263  ( markerSymbol->dataDefinedAngle().hasDefaultValues() && isDefault )
264  // shall we set the "en masse" expression for properties ?
265  || !isDefault )
266  {
267  markerSymbol->setDataDefinedAngle( dd );
268  emit changed();
269  }
270 }
271 
273 {
274  QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
275  if ( markerSymbol->size() == size )
276  return;
277  markerSymbol->setSize( size );
278  emit changed();
279 }
280 
282 {
283  QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
284  QgsDataDefined dd = mSizeDDBtn->currentDataDefined();
285 
286  spinSize->setEnabled( !mSizeDDBtn->isActive() );
287 
288  bool isDefault = dd.hasDefaultValues();
289 
290  if ( // shall we remove datadefined expressions for layers ?
291  ( !markerSymbol->dataDefinedSize().hasDefaultValues() && isDefault )
292  // shall we set the "en masse" expression for properties ?
293  || !isDefault )
294  {
295  markerSymbol->setDataDefinedSize( dd );
297  emit changed();
298  }
299 }
300 
302 {
303  QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( mSymbol );
304  if ( lineSymbol->width() == width )
305  return;
306  lineSymbol->setWidth( width );
307  emit changed();
308 }
309 
311 {
312  QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( mSymbol );
313  QgsDataDefined dd = mWidthDDBtn->currentDataDefined();
314 
315  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
316 
317  bool isDefault = dd.hasDefaultValues();
318 
319  if ( // shall we remove datadefined expressions for layers ?
320  ( !lineSymbol->dataDefinedWidth().hasDefaultValues() && isDefault )
321  // shall we set the "en masse" expression for properties ?
322  || !isDefault )
323  {
324  lineSymbol->setDataDefinedWidth( dd );
325  emit changed();
326  }
327 }
328 
330 {
331  Q_UNUSED( name );
332  Q_UNUSED( symbol );
334 }
335 
337 {
338  bool ok;
339  QString name = QInputDialog::getText( this, tr( "Symbol name" ),
340  tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
341  if ( !ok || name.isEmpty() )
342  return;
343 
344  // check if there is no symbol with same name
345  if ( mStyle->symbolNames().contains( name ) )
346  {
347  int res = QMessageBox::warning( this, tr( "Save symbol" ),
348  tr( "Symbol with name '%1' already exists. Overwrite?" )
349  .arg( name ),
350  QMessageBox::Yes | QMessageBox::No );
351  if ( res != QMessageBox::Yes )
352  {
353  return;
354  }
355  }
356 
357  // add new symbol to style and re-populate the list
358  mStyle->addSymbol( name, mSymbol->clone() );
359 
360  // make sure the symbol is stored
361  mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
363 }
364 
366 {
367  bool ok;
368  QString name = QInputDialog::getText( this, tr( "Symbol name" ),
369  tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
370  if ( !ok || name.isEmpty() )
371  return;
372 
373  // check if there is no symbol with same name
374  if ( mStyle->symbolNames().contains( name ) )
375  {
376  int res = QMessageBox::warning( this, tr( "Save symbol" ),
377  tr( "Symbol with name '%1' already exists. Overwrite?" )
378  .arg( name ),
379  QMessageBox::Yes | QMessageBox::No );
380  if ( res != QMessageBox::Yes )
381  {
382  return;
383  }
384  }
385 
386  // add new symbol to style and re-populate the list
387  mStyle->addSymbol( name, mSymbol->clone() );
388 
389  // make sure the symbol is stored
390  mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
391 }
392 
394 {
395  if ( mSymbol )
396  {
397 
398  mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
399  mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
400 
401  emit changed();
402  }
403 }
404 
406 {
407  if ( mSymbol )
408  {
409  double alpha = 1 - ( value / 255.0 );
410  mSymbol->setAlpha( alpha );
411  displayTransparency( alpha );
412  emit changed();
413  }
414 }
415 
416 void QgsSymbolsListWidget::displayTransparency( double alpha )
417 {
418  double transparencyPercent = ( 1 - alpha ) * 100;
419  mTransparencyLabel->setText( tr( "Transparency %1%" ).arg(( int ) transparencyPercent ) );
420 }
421 
423 {
424  btnColor->blockSignals( true );
425  btnColor->setColor( mSymbol->color() );
426  btnColor->blockSignals( false );
427 }
428 
429 static QgsExpressionContext _getExpressionContext( const void* context )
430 {
431  const QgsSymbolsListWidget* widget = ( const QgsSymbolsListWidget* ) context;
432 
433  if ( widget->expressionContext() )
434  return QgsExpressionContext( *widget->expressionContext() );
435 
436  //otherwise create a default symbol context
437  QgsExpressionContext expContext;
441 
442  if ( widget->mapCanvas() )
443  {
446  }
447  else
448  {
450  }
451 
452  const QgsVectorLayer* layer = widget->layer();
453  if ( layer )
454  expContext << QgsExpressionContextUtils::layerScope( layer );
455 
456  return expContext;
457 }
458 
460 {
462 
463  Q_FOREACH ( QgsDataDefinedButton* button, findChildren< QgsDataDefinedButton* >() )
464  {
466  }
467 
468  if ( mSymbol->type() == QgsSymbolV2::Marker )
469  {
470  QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
471  spinSize->setValue( markerSymbol->size() );
472  spinAngle->setValue( markerSymbol->angle() );
473 
474  if ( mLayer )
475  {
476  QgsDataDefined ddSize = markerSymbol->dataDefinedSize();
478  spinSize->setEnabled( !mSizeDDBtn->isActive() );
479  QgsDataDefined ddAngle( markerSymbol->dataDefinedAngle() );
480  mRotationDDBtn->init( mLayer, &ddAngle, QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
481  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
482  }
483  else
484  {
485  mSizeDDBtn->setEnabled( false );
486  mRotationDDBtn->setEnabled( false );
487  }
488  }
489  else if ( mSymbol->type() == QgsSymbolV2::Line )
490  {
491  QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( mSymbol );
492  spinWidth->setValue( lineSymbol->width() );
493 
494  if ( mLayer )
495  {
496  QgsDataDefined dd( lineSymbol->dataDefinedWidth() );
498  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
499  }
500  else
501  {
502  mWidthDDBtn->setEnabled( false );
503  }
504  }
505 
506  mSymbolUnitWidget->blockSignals( true );
507  mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
508  mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
509  mSymbolUnitWidget->blockSignals( false );
510 
511  mTransparencySlider->blockSignals( true );
512  double transparency = 1 - mSymbol->alpha();
513  mTransparencySlider->setValue( transparency * 255 );
514  displayTransparency( mSymbol->alpha() );
515  mTransparencySlider->blockSignals( false );
516 
518  {
519  //add clip features option for line or fill symbols
520  btnAdvanced->menu()->addAction( mClipFeaturesAction );
521  }
522  else
523  {
524  btnAdvanced->menu()->removeAction( mClipFeaturesAction );
525  }
526  btnAdvanced->setVisible( mAdvancedMenu || !btnAdvanced->menu()->isEmpty() );
527 
531 }
532 
534 {
535  QString symbolName = index.data( Qt::UserRole ).toString();
536  lblSymbolName->setText( symbolName );
537  // get new instance of symbol from style
538  QgsSymbolV2* s = mStyle->symbol( symbolName );
540  // remove all symbol layers from original symbol
541  while ( mSymbol->symbolLayerCount() )
543  // move all symbol layers to our symbol
544  while ( s->symbolLayerCount() )
545  {
546  QgsSymbolLayerV2* sl = s->takeSymbolLayer( 0 );
547  mSymbol->appendSymbolLayer( sl );
548  }
549  mSymbol->setAlpha( s->alpha() );
550  mSymbol->setOutputUnit( unit );
551  // delete the temporary symbol
552  delete s;
553 
555  emit changed();
556 }
557 
559 {
560  QStringList symbols;
561  QString text = groupsCombo->itemText( index );
562  // List all symbols when empty list item is selected
563  if ( text.isEmpty() )
564  {
565  symbols = mStyle->symbolNames();
566  }
567  else
568  {
569  int groupid;
570  if ( groupsCombo->itemData( index ).toString() == "smart" )
571  {
572  groupid = mStyle->smartgroupId( text );
573  symbols = mStyle->symbolsOfSmartgroup( QgsStyleV2::SymbolEntity, groupid );
574  }
575  else
576  {
577  groupid = groupsCombo->itemData( index ).toInt();
578  symbols = mStyle->symbolsOfGroup( QgsStyleV2::SymbolEntity, groupid );
579  }
580  }
581  populateSymbols( symbols );
582 }
583 
585 {
587  populateSymbols( symbols );
588 }
void setToolTip(const QString &toolTip)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
static unsigned index
void setPointSize(int pointSize)
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context&#39;s extent...
Definition: qgssymbolv2.h:215
void on_mTransparencySlider_valueChanged(int value)
void setLineWidth(double width)
QgsSymbolsListWidget(QgsSymbolV2 *symbol, QgsStyleV2 *style, QMenu *menu, QWidget *parent, const QgsVectorLayer *layer=nullptr)
void setupUi(QWidget *widget)
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:62
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.
void setSymbolFromStyle(const QModelIndex &index)
static QString doublePosDesc()
SymbolType type() const
Definition: qgssymbolv2.h:104
bool addSymbol(const QString &name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol&#39;s ownership
Definition: qgsstylev2.cpp:81
static QgsExpressionContextScope * atlasScope(const QgsAtlasComposition *atlas)
Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
void setChecked(bool)
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
virtual QgsSymbolV2 * clone() const =0
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
const_iterator constBegin() const
The output shall be in pixels.
Definition: qgssymbolv2.h:67
Calculate scale by the diameter.
Definition: qgssymbolv2.h:90
QStringList symbolsOfGroup(StyleEntity type, int groupid)
returns the symbolnames of a given groupid
Definition: qgsstylev2.cpp:538
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsMapUnitScale mapUnitScale() const
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
int exec()
Line symbol.
Definition: qgssymbolv2.h:79
const QPixmap * icon() const
void setMarkerSize(double size)
void on_groupsCombo_editTextChanged(const QString &text)
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:105
const QgsVectorLayer * mLayer
void setWidth(double width)
Marker symbol.
Definition: qgssymbolv2.h:78
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
virtual void setData(const QVariant &value, int role)
void setMapUnitScale(const QgsMapUnitScale &scale)
The QgsMapSettings class contains configuration for rendering of the map.
bool isEmpty() const
int width() const
QSize size() const
void setColor(const QColor &color)
const char * name() const
The output shall be in millimeters.
Definition: qgssymbolv2.h:64
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
QgsSymbolGroupMap childGroupNames(const QString &parent="")
return a map of groupid and names for the given parent group
Definition: qgsstylev2.cpp:491
int count(const T &value) const
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
double width() const
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
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:105
const Key & key() const
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbolv2.h:200
void setFlags(QFlags< Qt::ItemFlag > flags)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isEmpty() const
const_iterator constEnd() const
The output shall be in map unitx.
Definition: qgssymbolv2.h:65
double angle() const
Returns the marker angle for the whole symbol.
void setAngle(double angle)
Sets the angle for the whole symbol.
void setSymbolColor(const QColor &color)
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:131
void setSize(double size)
Sets the size for the whole symbol.
const T & value() const
void setMarkerAngle(double angle)
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
QgsDataDefinedAssistant * assistant()
Returns the assistant used to defined the data defined object properties, if set. ...
Single scope for storing variables and functions for use within a QgsExpressionContext.
QStringList symbolNames()
return a list of names of symbols
Definition: qgsstylev2.cpp:180
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
void setFont(const QFont &font)
A button for defining data source field mappings or expressions.
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)
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QgsSymbolV2 * symbol(const QString &name)
return a NEW copy of symbol
Definition: qgsstylev2.cpp:164
bool blockSignals(bool block)
void on_groupsCombo_currentIndexChanged(int index)
virtual ~QgsSymbolsListWidget()
Destructor.
void registerGetExpressionContextCallback(ExpressionContextCallback fnGetExpressionContext, const void *context)
Register callback function for retrieving the expression context for the button.
void setCheckable(bool)
void setText(const QString &text)
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
void clipFeaturesToggled(bool checked)
QStringList smartgroupNames()
returns the smart groups list
QFont font() const
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
Definition: qgsmapcanvas.h:443
QgsDataDefined dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
const QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QVariant data(int role) const
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
Fill symbol.
Definition: qgssymbolv2.h:80
QgsSymbolV2::OutputUnit outputUnit() const
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
static QgsExpressionContext _getExpressionContext(const void *context)
void show()
QgsSymbolLayerV2 * takeSymbolLayer(int index)
Remove symbol layer from the list and return pointer to it.
bool hasDefaultValues() const
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
int smartgroupId(const QString &smartgroup)
return the DB id for the given smartgroup name
Widget displaying a combobox allowing the user to choose between millimeter and map units If the user...
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
void populateSymbols(const QStringList &symbols)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context&#39;s extent...
Definition: qgssymbolv2.h:225
Represents a vector layer which manages a vector based data sets.
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QString toString() const
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void appendRow(const QList< QStandardItem * > &items)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbolv2.h:202
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QStringList findSymbols(StyleEntity type, const QString &qword)
return the names of the symbols which have a matching &#39;substring&#39; in its defintion ...
Definition: qgsstylev2.cpp:796
QColor color() const
void symbolAddedToStyle(const QString &name, QgsSymbolV2 *symbol)