QGIS API Documentation  2.15.0-Master (13f053b)
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 
111  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
112 
119  void setSelectedOnTop( bool selectedOnTop );
120 
126  int featureCount();
127 
134  int filteredFeatureCount();
135 
142  void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
143 
147  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
148 
154  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
155 
161  void setRequest( const QgsFeatureRequest& request );
162 
168  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
169 
175  QgsAttributeTableView* tableView() { return mTableView; }
176 
181  void setAttributeTableConfig( const QgsAttributeTableConfig& config );
182 
186  void setSortExpression( const QString& sortExpression );
187 
191  QString sortExpression() const;
192 
193  protected:
197  void columnBoxInit();
198 
199  public slots:
205  void setCurrentEditSelection( const QgsFeatureIds& fids );
206 
213  bool saveEditChanges();
214 
215  void openConditionalStyles();
216 
220  void setMultiEditEnabled( bool enabled );
221 
222  signals:
227  void displayExpressionChanged( const QString& expression );
228 
232  void filterChanged();
233 
234  private slots:
235 
236  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
237 
243  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
244 
245  void previewExpressionBuilder();
246 
247  void previewColumnChanged( QObject* previewAction );
248 
249  void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
250 
251  void previewExpressionChanged( const QString& expression );
252 
253  void sortByPreviewExpression();
254 
260  void featureFormAttributeChanged();
261 
268  virtual void progress( int i, bool &cancel );
269 
274  virtual void finished();
275 
277  void zoomToCurrentFeature();
278 
279  private:
280  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
281  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
282 
283  QgsAttributeEditorContext mEditorContext;
284  QgsAttributeTableModel* mMasterModel;
285  QgsAttributeTableFilterModel* mFilterModel;
286  QgsFeatureListModel* mFeatureListModel;
287  QgsAttributeForm* mAttributeForm;
288  QSignalMapper* mPreviewActionMapper;
289  QMenu* mPreviewColumnsMenu;
290  QgsVectorLayerCache* mLayerCache;
291  QProgressDialog* mProgressDlg;
292  QgsIFeatureSelectionManager* mFeatureSelectionManager;
293  QgsDistanceArea mDistanceArea;
294  QString mDisplayExpression;
295 
296  friend class TestQgsDualView;
297 };
298 
299 class GUI_EXPORT QgsAttributeTableAction : public QAction
300 {
301  Q_OBJECT
302 
303  public:
304  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx )
305  : QAction( name, dualView )
306  , mDualView( dualView )
307  , mAction( action )
308  , mFieldIdx( fieldIdx )
309  {}
310 
311  public slots:
312  void execute();
313  void featureForm();
314 
315  private:
316  QgsDualView* mDualView;
317  int mAction;
318  QModelIndex mFieldIdx;
319 };
320 
321 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
322 {
323  Q_OBJECT
324 
325  public:
326  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx )
327  : QAction( name, dualView )
328  , mDualView( dualView )
329  , mAction( action )
330  , mFieldIdx( fieldIdx )
331  {}
332 
333  public slots:
334  void execute();
335 
336  private:
337  QgsDualView* mDualView;
338  QgsMapLayerAction* mAction;
339  QModelIndex mFieldIdx;
340 };
341 
342 #endif // QGSDUALVIEW_H
Provides a table view of features of a QgsVectorLayer.
This class contains context information for attribute editor widgets.
QgsAttributeTableView * tableView()
Returns the table view.
Definition: qgsdualview.h:175
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:304
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:326
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:108
FilterMode
The filter mode defines how the rows should be filtered.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureIds filteredFeatures()
Get a list of currently visible feature ids.
Definition: qgsdualview.h:147
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:154
QgsAttributeTableFilterModel::FilterMode filterMode()
Get the filter mode.
Definition: qgsdualview.h:111
General purpose distance and area calculator.
This is a container for configuration of the attribute table.
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