QGIS API Documentation  2.14.0-Essen
qgsdualview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdualview.h
3  --------------------------------------
4  Date : 10.2.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias at opengis dot ch
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 QGSDUALVIEW_H
17 #define QGSDUALVIEW_H
18 
19 #include <QStackedWidget>
20 
21 #include "ui_qgsdualviewbase.h"
22 
27 #include "qgsdistancearea.h"
28 
29 class QgsAttributeForm;
30 class QgsFeatureRequest;
31 class QSignalMapper;
32 class QgsMapLayerAction;
33 
41 class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
42 {
43  Q_OBJECT
44  Q_ENUMS( ViewMode )
45 
46  public:
47 
53  enum ViewMode
54  {
58  AttributeTable = 0,
64  AttributeEditor = 1
65  };
66 
71  explicit QgsDualView( QWidget* parent = nullptr );
72 
82  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext() );
83 
89  void setView( ViewMode view );
90 
96  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
97 
98  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
99 
106  void setSelectedOnTop( bool selectedOnTop );
107 
113  int featureCount();
114 
121  int filteredFeatureCount();
122 
129  void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
130 
131  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
132 
138  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
139 
140  void setRequest( const QgsFeatureRequest& request );
141 
142  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
143 
144  protected:
148  void columnBoxInit();
149 
150  public slots:
156  void setCurrentEditSelection( const QgsFeatureIds& fids );
157 
164  bool saveEditChanges();
165 
166  void openConditionalStyles();
167 
168  signals:
173  void displayExpressionChanged( const QString& expression );
174 
178  void filterChanged();
179 
180  private slots:
181 
182  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
183 
189  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
190 
191  void previewExpressionBuilder();
192 
193  void previewColumnChanged( QObject* previewAction );
194 
195  void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
196 
197  void previewExpressionChanged( const QString& expression );
198 
204  void featureFormAttributeChanged();
205 
212  virtual void progress( int i, bool &cancel );
213 
218  virtual void finished();
219 
221  void zoomToCurrentFeature();
222 
223  private:
224  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
225  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
226 
227  QgsAttributeEditorContext mEditorContext;
228  QgsAttributeTableModel* mMasterModel;
229  QgsAttributeTableFilterModel* mFilterModel;
230  QgsFeatureListModel* mFeatureListModel;
231  QgsAttributeForm* mAttributeForm;
232  QSignalMapper* mPreviewActionMapper;
233  QMenu* mPreviewColumnsMenu;
234  QgsVectorLayerCache* mLayerCache;
235  QProgressDialog* mProgressDlg;
236  QgsIFeatureSelectionManager* mFeatureSelectionManager;
237  QgsDistanceArea mDistanceArea;
238  QString mDisplayExpression;
239 
240  friend class TestQgsDualView;
241 };
242 
243 class GUI_EXPORT QgsAttributeTableAction : public QAction
244 {
245  Q_OBJECT
246 
247  public:
248  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
249  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
250  {}
251 
252  public slots:
253  void execute();
254  void featureForm();
255 
256  private:
257  QgsDualView* mDualView;
258  int mAction;
259  QModelIndex mFieldIdx;
260 };
261 
262 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
263 {
264  Q_OBJECT
265 
266  public:
267  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
268  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
269  {}
270 
271  public slots:
272  void execute();
273 
274  private:
275  QgsDualView* mDualView;
276  QgsMapLayerAction* mAction;
277  QModelIndex mFieldIdx;
278 };
279 
280 #endif // QGSDUALVIEW_H
This class contains context information for attribute editor widgets.
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:53
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:248
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:267
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureIds filteredFeatures()
Definition: qgsdualview.h:131
This class caches features of a given QgsVectorLayer.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
Definition: qgsdualview.h:138
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:98
General purpose distance and area calculator.
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.
An action which can run on map layers.
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Definition: qgsdualview.h:41