QGIS API Documentation  2.11.0-Master
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 dot kuhn at gmx 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 QGSFEATURELIST_H
17 #define QGSFEATURELIST_H
18 
19 #include <QStackedWidget>
20 
21 #include "ui_qgsdualviewbase.h"
22 
26 #include "qgsdistancearea.h"
27 
28 class QgsAttributeForm;
29 class QgsFeatureRequest;
30 class QSignalMapper;
31 class QgsMapLayerAction;
32 
40 class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
41 {
42  Q_OBJECT
43  Q_ENUMS( ViewMode )
44 
45  public:
46 
52  enum ViewMode
53  {
57  AttributeTable = 0,
63  AttributeEditor = 1
64  };
65 
70  explicit QgsDualView( QWidget* parent = 0 );
71 
81  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext() );
82 
88  void setView( ViewMode view );
89 
95  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
96 
97  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
98 
105  void setSelectedOnTop( bool selectedOnTop );
106 
112  int featureCount();
113 
120  int filteredFeatureCount();
121 
128  void setFilteredFeatures( QgsFeatureIds filteredFeatures );
129 
130  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
131 
137  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
138 
139  void setRequest( const QgsFeatureRequest& request );
140 
141  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
142 
143  protected:
147  void columnBoxInit();
148 
149  public slots:
155  void setCurrentEditSelection( const QgsFeatureIds& fids );
156 
163  bool saveEditChanges();
164 
165  signals:
170  void displayExpressionChanged( const QString expression );
171 
175  void filterChanged();
176 
177  private slots:
178 
179  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
180 
186  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
187 
188  void previewExpressionBuilder();
189 
190  void previewColumnChanged( QObject* previewAction );
191 
192  void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );
193 
194  void previewExpressionChanged( const QString expression );
195 
201  void featureFormAttributeChanged();
202 
209  virtual void progress( int i, bool &cancel );
210 
215  virtual void finished();
216 
217  private:
218  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
219  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
220 
221  QgsAttributeEditorContext mEditorContext;
222  QgsAttributeTableModel* mMasterModel;
223  QgsAttributeTableFilterModel* mFilterModel;
224  QgsFeatureListModel* mFeatureListModel;
225  QgsAttributeForm* mAttributeForm;
226  QSignalMapper* mPreviewActionMapper;
227  QMenu* mPreviewColumnsMenu;
228  QgsVectorLayerCache* mLayerCache;
229  QProgressDialog* mProgressDlg;
230  QgsIFeatureSelectionManager* mFeatureSelectionManager;
231  QgsDistanceArea mDistanceArea;
232  QString mDisplayExpression;
233 
234  friend class TestQgsDualView;
235 };
236 
237 class GUI_EXPORT QgsAttributeTableAction : public QAction
238 {
239  Q_OBJECT
240 
241  public:
242  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
243  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
244  {}
245 
246  public slots:
247  void execute();
248  void featureForm();
249 
250  private:
251  QgsDualView* mDualView;
252  int mAction;
253  QModelIndex mFieldIdx;
254 };
255 
256 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
257 {
258  Q_OBJECT
259 
260  public:
261  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
262  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
263  {}
264 
265  public slots:
266  void execute();
267 
268  private:
269  QgsDualView* mDualView;
270  QgsMapLayerAction* mAction;
271  QModelIndex mFieldIdx;
272 };
273 
274 #endif // QGSFEATURELIST_H
This class contains context information for attribute editor widgets.
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:52
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:242
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:261
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:162
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:130
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:137
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:97
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:40