QGIS API Documentation  2.15.0-Master (af20121)
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 #include "qgsattributeform.h"
29 
30 class QgsAttributeForm;
31 class QgsFeatureRequest;
32 class QSignalMapper;
33 class QgsMapLayerAction;
34 
42 class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
43 {
44  Q_OBJECT
45  Q_ENUMS( ViewMode )
46 
47  public:
48 
54  enum ViewMode
55  {
59  AttributeTable = 0,
65  AttributeEditor = 1
66  };
67 
72  explicit QgsDualView( QWidget* parent = nullptr );
73 
83  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext() );
84 
91  void setView( ViewMode view );
92 
98  ViewMode view() const;
99 
105  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
106 
112  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
113 
120  void setSelectedOnTop( bool selectedOnTop );
121 
127  int featureCount();
128 
135  int filteredFeatureCount();
136 
143  void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
144 
148  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
149 
155  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
156 
162  void setRequest( const QgsFeatureRequest& request );
163 
169  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
170 
176  QgsAttributeTableView* tableView() { return mTableView; }
177 
182  void setAttributeTableConfig( const QgsAttributeTableConfig& config );
183 
187  void setSortExpression( const QString& sortExpression );
188 
192  QString sortExpression() const;
193 
194  protected:
198  void columnBoxInit();
199 
200  public slots:
206  void setCurrentEditSelection( const QgsFeatureIds& fids );
207 
214  bool saveEditChanges();
215 
216  void openConditionalStyles();
217 
221  void setMultiEditEnabled( bool enabled );
222 
227  void toggleSearchMode( bool enabled );
228 
229  signals:
234  void displayExpressionChanged( const QString& expression );
235 
239  void filterChanged();
240 
246  void filterExpressionSet( const QString& expression, QgsAttributeForm::FilterType type );
247 
251  void formModeChanged( QgsAttributeForm::Mode mode );
252 
253  private slots:
254 
255  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
256 
262  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
263 
264  void previewExpressionBuilder();
265 
266  void previewColumnChanged( QObject* previewAction );
267 
268  void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
269 
270  void previewExpressionChanged( const QString& expression );
271 
272  void sortByPreviewExpression();
273 
279  void featureFormAttributeChanged();
280 
287  virtual void progress( int i, bool &cancel );
288 
293  virtual void finished();
294 
296  void zoomToCurrentFeature();
297 
298  private:
299  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
300  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
301 
302  QgsAttributeEditorContext mEditorContext;
303  QgsAttributeTableModel* mMasterModel;
304  QgsAttributeTableFilterModel* mFilterModel;
305  QgsFeatureListModel* mFeatureListModel;
306  QgsAttributeForm* mAttributeForm;
307  QSignalMapper* mPreviewActionMapper;
308  QMenu* mPreviewColumnsMenu;
309  QgsVectorLayerCache* mLayerCache;
310  QProgressDialog* mProgressDlg;
311  QgsIFeatureSelectionManager* mFeatureSelectionManager;
312  QgsDistanceArea mDistanceArea;
313  QString mDisplayExpression;
314 
315  friend class TestQgsDualView;
316 };
317 
318 class GUI_EXPORT QgsAttributeTableAction : public QAction
319 {
320  Q_OBJECT
321 
322  public:
323  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx )
324  : QAction( name, dualView )
325  , mDualView( dualView )
326  , mAction( action )
327  , mFieldIdx( fieldIdx )
328  {}
329 
330  public slots:
331  void execute();
332  void featureForm();
333 
334  private:
335  QgsDualView* mDualView;
336  int mAction;
337  QModelIndex mFieldIdx;
338 };
339 
340 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
341 {
342  Q_OBJECT
343 
344  public:
345  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx )
346  : QAction( name, dualView )
347  , mDualView( dualView )
348  , mAction( action )
349  , mFieldIdx( fieldIdx )
350  {}
351 
352  public slots:
353  void execute();
354 
355  private:
356  QgsDualView* mDualView;
357  QgsMapLayerAction* mAction;
358  QModelIndex mFieldIdx;
359 };
360 
361 #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:176
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:54
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:323
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:345
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
FilterType
Filter types.
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:148
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:155
QgsAttributeTableFilterModel::FilterMode filterMode()
Get the filter mode.
Definition: qgsdualview.h:112
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:42