QGIS API Documentation  2.14.0-Essen
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 class DataDefinedRestorer: public QObject
47 {
48  Q_OBJECT
49  public:
50  DataDefinedRestorer( QgsSymbolV2* symbol, const QgsSymbolLayerV2* symbolLayer );
51 
52  public slots:
53  void restore();
54 
55  private:
56  QgsMarkerSymbolV2* mMarker;
57  const QgsMarkerSymbolLayerV2* mMarkerSymbolLayer;
58  double mSize;
59  double mAngle;
60  QPointF mMarkerOffset;
61  QgsDataDefined mDDSize;
62  QgsDataDefined mDDAngle;
63 
64  QgsLineSymbolV2* mLine;
65  const QgsLineSymbolLayerV2* mLineSymbolLayer;
66  double mWidth;
67  double mLineOffset;
68  QgsDataDefined mDDWidth;
69 
70  void save();
71 };
73 
74 class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymbolV2SelectorDialogBase
75 {
76  Q_OBJECT
77 
78  public:
79  QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = nullptr, bool embedded = false );
81 
83  QMenu* advancedMenu();
84 
92  void setExpressionContext( QgsExpressionContext* context );
93 
100  QgsExpressionContext* expressionContext() const { return mPresetExpressionContext.data(); }
101 
107  void setMapCanvas( QgsMapCanvas* canvas );
108 
109  protected:
111  void keyPressEvent( QKeyEvent * event ) override;
112 
113  void loadSymbol();
115  void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );
116 
117  void updateUi();
118 
119  void updateLockButton();
120 
122  SymbolLayerItem* currentLayerItem();
123  QgsSymbolLayerV2* currentLayer();
124 
125  void moveLayerByOffset( int offset );
126 
127  void setWidget( QWidget* widget );
128 
129  signals:
130  void symbolModified();
131 
132  public slots:
133  void moveLayerDown();
134  void moveLayerUp();
135 
136  void addLayer();
137  void removeLayer();
138 
139  void lockLayer();
140 
141  Q_DECL_DEPRECATED void saveSymbol();
142 
145  void duplicateLayer();
146 
147  void layerChanged();
148 
149  void updateLayerPreview();
150  void updatePreview();
151 
153  void symbolChanged();
156  void changeLayer( QgsSymbolLayerV2* layer );
157 
158 
159  protected: // data
164 
167 
168  private:
169  QScopedPointer<DataDefinedRestorer> mDataDefineRestorer;
170  QScopedPointer< QgsExpressionContext > mPresetExpressionContext;
171 
172  QgsMapCanvas* mMapCanvas;
173 };
174 
175 #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:105
QgsExpressionContext * expressionContext() const
Returns the expression context used for the dialog, if set.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Represents a vector layer which manages a vector based data sets.