QGIS API Documentation  2.12.0-Lyon
qgssymbolv2selectordialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolv2selectordialog.h
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 
16 #ifndef QGSSYMBOLV2SELECTORDIALOG_H
17 #define QGSSYMBOLV2SELECTORDIALOG_H
18 
19 #include <QDialog>
20 
21 #include "ui_qgssymbolv2selectordialogbase.h"
22 
23 #include "qgsdatadefined.h"
24 
25 #include <QStandardItemModel>
26 #include <QScopedPointer>
27 
28 class QgsStyleV2;
29 class QgsSymbolV2;
30 class QgsSymbolLayerV2;
31 class QgsVectorLayer;
32 
33 class QMenu;
34 class QWidget;
35 
36 class SymbolLayerItem;
37 class QgsMarkerSymbolV2;
38 class QgsLineSymbolV2;
41 
42 class QgsMapCanvas;
43 
45 {
46  Q_OBJECT
47  public:
48  DataDefinedRestorer( QgsSymbolV2* symbol, const QgsSymbolLayerV2* symbolLayer );
49 
50  public slots:
51  void restore();
52 
53  private:
54  QgsMarkerSymbolV2* mMarker;
55  const QgsMarkerSymbolLayerV2* mMarkerSymbolLayer;
56  double mSize;
57  double mAngle;
58  QPointF mMarkerOffset;
59  QgsDataDefined mDDSize;
60  QgsDataDefined mDDAngle;
61 
62  QgsLineSymbolV2* mLine;
63  const QgsLineSymbolLayerV2* mLineSymbolLayer;
64  double mWidth;
65  double mLineOffset;
66  QgsDataDefined mDDWidth;
67 
68  void save();
69 };
70 
71 class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymbolV2SelectorDialogBase
72 {
73  Q_OBJECT
74 
75  public:
76  QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = 0, bool embedded = false );
78 
80  QMenu* advancedMenu();
81 
89  void setExpressionContext( QgsExpressionContext* context );
90 
97  QgsExpressionContext* expressionContext() const { return mPresetExpressionContext.data(); }
98 
104  void setMapCanvas( QgsMapCanvas* canvas );
105 
106  protected:
108  void keyPressEvent( QKeyEvent * event ) override;
109 
110  void loadSymbol();
112  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
113 
114  void updateUi();
115 
116  void updateLockButton();
117 
119  SymbolLayerItem* currentLayerItem();
120  QgsSymbolLayerV2* currentLayer();
121 
122  void moveLayerByOffset( int offset );
123 
124  void setWidget( QWidget* widget );
125 
126  signals:
127  void symbolModified();
128 
129  public slots:
130  void moveLayerDown();
131  void moveLayerUp();
132 
133  void addLayer();
134  void removeLayer();
135 
136  void saveSymbol();
137  void lockLayer();
138 
139  void layerChanged();
140 
141  void updateLayerPreview();
142  void updatePreview();
143 
145  void symbolChanged();
148  void changeLayer( QgsSymbolLayerV2* layer );
149 
150 
151  protected: // data
156 
159 
160  private:
161  QScopedPointer<DataDefinedRestorer> mDataDefineRestorer;
162  QScopedPointer< QgsExpressionContext > mPresetExpressionContext;
163 
164  QgsMapCanvas* mMapCanvas;
165 };
166 
167 #endif
A container class for data source field mapping or expression.
const QgsVectorLayer * mVectorLayer
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:107
QgsExpressionContext * expressionContext() const
Returns the expression context used for the dialog, if set.
DataDefinedRestorer(QgsSymbolV2 *symbol, const QgsSymbolLayerV2 *symbolLayer)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual void keyPressEvent(QKeyEvent *e)
Represents a vector layer which manages a vector based data sets.