QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
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 = 0 );
73 
83  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), QgsAttributeEditorContext context = QgsAttributeEditorContext() );
84 
90  void setView( ViewMode view );
91 
97  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
98 
99  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
100 
107  void setSelectedOnTop( bool selectedOnTop );
108 
114  int featureCount();
115 
122  int filteredFeatureCount();
123 
130  void setFilteredFeatures( QgsFeatureIds filteredFeatures );
131 
132  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
133 
139  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
140 
141  void setRequest( const QgsFeatureRequest& request );
142 
143  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
144 
145  protected:
149  void columnBoxInit();
150 
151  public slots:
157  void setCurrentEditSelection( const QgsFeatureIds& fids );
158 
165  bool saveEditChanges();
166 
167  signals:
172  void displayExpressionChanged( const QString expression );
173 
177  void filterChanged();
178 
179  private slots:
180 
181  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
182 
188  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
189 
190  void previewExpressionBuilder();
191 
192  void previewColumnChanged( QObject* previewAction );
193 
194  void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );
195 
196  void previewExpressionChanged( const QString expression );
197 
203  void featureFormAttributeChanged();
204 
211  virtual void progress( int i, bool& cancel );
212 
217  virtual void finished();
218 
219  private:
220  void initLayerCache( QgsVectorLayer *layer );
221  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
222 
223  QgsAttributeEditorContext mEditorContext;
224  QgsAttributeTableModel* mMasterModel;
225  QgsAttributeTableFilterModel* mFilterModel;
226  QgsFeatureListModel* mFeatureListModel;
227  QgsAttributeForm* mAttributeForm;
228  QgsCachedFeatureIterator* mFeatureCache;
229  QSignalMapper* mPreviewActionMapper;
230  QMenu* mPreviewColumnsMenu;
231  QgsVectorLayerCache* mLayerCache;
232  QProgressDialog* mProgressDlg;
233  QgsIFeatureSelectionManager* mFeatureSelectionManager;
234  QgsDistanceArea mDistanceArea;
235 
236  friend class TestQgsDualView;
237 };
238 
239 class GUI_EXPORT QgsAttributeTableAction : public QAction
240 {
241  Q_OBJECT
242 
243  public:
244  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
245  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
246  {}
247 
248  public slots:
249  void execute();
250  void featureForm();
251 
252  private:
253  QgsDualView* mDualView;
254  int mAction;
255  QModelIndex mFieldIdx;
256 };
257 
258 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
259 {
260  Q_OBJECT
261 
262  public:
263  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
264  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
265  {}
266 
267  public slots:
268  void execute();
269 
270  private:
271  QgsDualView* mDualView;
272  QgsMapLayerAction* mAction;
273  QModelIndex mFieldIdx;
274 };
275 
276 #endif // QGSFEATURELIST_H
Definition: qgsdualview.h:258
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
This class contains context information for attribute editor widgets.
Definition: qgsattributeeditorcontext.h:33
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:244
Definition: qgsattributetablefiltermodel.h:31
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:263
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Definition: qgsattributetablemodel.h:45
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
Definition: qgsfeaturelistmodel.h:17
FilterMode
Definition: qgsattributetablefiltermodel.h:36
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Definition: qgsfeaturerequest.h:58
QgsFeatureIds filteredFeatures()
Definition: qgsdualview.h:132
Definition: qgsattributeform.h:29
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:38
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
Definition: qgsdualview.h:139
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:99
General purpose distance and area calculator.
Definition: qgsdistancearea.h:34
Delivers features from the cache.
Definition: qgscachedfeatureiterator.h:29
Is an interface class to abstract feature selection handling.
Definition: qgsifeatureselectionmanager.h:29
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
An action which can run on map layers.
Definition: qgsmaplayeractionregistry.h:31
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Definition: qgsdualview.h:42
Definition: qgsdualview.h:239