QGIS API Documentation
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 
90  void setView( ViewMode view );
91 
97  ViewMode view() const;
98 
104  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
105 
106  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
107 
114  void setSelectedOnTop( bool selectedOnTop );
115 
121  int featureCount();
122 
129  int filteredFeatureCount();
130 
137  void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
138 
139  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
140 
146  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
147 
148  void setRequest( const QgsFeatureRequest& request );
149 
150  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
151 
152  protected:
156  void columnBoxInit();
157 
158  public slots:
164  void setCurrentEditSelection( const QgsFeatureIds& fids );
165 
172  bool saveEditChanges();
173 
174  void openConditionalStyles();
175 
179  void setMultiEditEnabled( bool enabled );
180 
181  signals:
186  void displayExpressionChanged( const QString& expression );
187 
191  void filterChanged();
192 
193  private slots:
194 
195  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
196 
202  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
203 
204  void previewExpressionBuilder();
205 
206  void previewColumnChanged( QObject* previewAction );
207 
208  void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
209 
210  void previewExpressionChanged( const QString& expression );
211 
217  void featureFormAttributeChanged();
218 
225  virtual void progress( int i, bool &cancel );
226 
231  virtual void finished();
232 
234  void zoomToCurrentFeature();
235 
236  private:
237  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
238  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
239 
240  QgsAttributeEditorContext mEditorContext;
241  QgsAttributeTableModel* mMasterModel;
242  QgsAttributeTableFilterModel* mFilterModel;
243  QgsFeatureListModel* mFeatureListModel;
244  QgsAttributeForm* mAttributeForm;
245  QSignalMapper* mPreviewActionMapper;
246  QMenu* mPreviewColumnsMenu;
247  QgsVectorLayerCache* mLayerCache;
248  QProgressDialog* mProgressDlg;
249  QgsIFeatureSelectionManager* mFeatureSelectionManager;
250  QgsDistanceArea mDistanceArea;
251  QString mDisplayExpression;
252 
253  friend class TestQgsDualView;
254 };
255 
256 class GUI_EXPORT QgsAttributeTableAction : public QAction
257 {
258  Q_OBJECT
259 
260  public:
261  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
262  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
263  {}
264 
265  public slots:
266  void execute();
267  void featureForm();
268 
269  private:
270  QgsDualView* mDualView;
271  int mAction;
272  QModelIndex mFieldIdx;
273 };
274 
275 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
276 {
277  Q_OBJECT
278 
279  public:
280  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
281  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
282  {}
283 
284  public slots:
285  void execute();
286 
287  private:
288  QgsDualView* mDualView;
289  QgsMapLayerAction* mAction;
290  QModelIndex mFieldIdx;
291 };
292 
293 #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:261
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:280
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:139
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:146
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:106
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