QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 QgsAttributeDialog;
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 
46  public:
47 
53  enum ViewMode
54  {
58  AttributeTable = 0,
64  AttributeEditor = 1
65  };
66 
71  explicit QgsDualView( QWidget* parent = 0 );
72  virtual ~QgsDualView();
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 
105  void setSelectedOnTop( bool selectedOnTop );
106 
112  int featureCount();
113 
120  int filteredFeatureCount();
121 
128  void setFilteredFeatures( QgsFeatureIds filteredFeatures );
129 
135  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
136 
137  void setRequest( const QgsFeatureRequest& request );
138 
139  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
140 
141  protected:
145  void columnBoxInit();
146 
147  virtual void hideEvent( QHideEvent * );
148  virtual void focusOutEvent( QFocusEvent * );
149 
150  public slots:
156  void setCurrentEditSelection( const QgsFeatureIds& fids );
157 
164  bool saveEditChanges();
165 
169  void reloadAttribute( const int& attribute );
170 
171 
172  signals:
177  void displayExpressionChanged( const QString expression );
178 
182  void filterChanged();
183 
184  private slots:
190  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
191 
192  void previewExpressionBuilder();
193 
194  void previewColumnChanged( QObject* previewAction );
195 
196  void editingToggled();
197 
198  void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );
199 
200  void previewExpressionChanged( const QString expression );
201 
209  void attributeDeleted( int attribute );
210 
218  void attributeAdded( int attribute );
219 
226  void featureDeleted( QgsFeatureId fid );
227 
234  virtual void progress( int i, bool& cancel );
235 
240  virtual void finished();
241 
242  private:
243  void initLayerCache( QgsVectorLayer *layer );
244  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
245 
252  QSignalMapper* mPreviewActionMapper;
255  QProgressDialog* mProgressDlg;
258 
259  friend class TestQgsDualView;
260 };
261 
262 class GUI_EXPORT QgsAttributeTableAction : public QAction
263 {
264  Q_OBJECT
265 
266  public:
267  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
268  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
269  {}
270 
271  public slots:
272  void execute();
273  void featureForm();
274 
275  private:
277  int mAction;
278  QModelIndex mFieldIdx;
279 };
280 
281 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
282 {
283  Q_OBJECT
284 
285  public:
286  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
287  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
288  {}
289 
290  public slots:
291  void execute();
292 
293  private:
296  QModelIndex mFieldIdx;
297 };
298 
299 #endif // QGSFEATURELIST_H
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:326
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:267
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:286
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
QMenu * mPreviewColumnsMenu
Definition: qgsdualview.h:253
QgsAttributeEditorContext mEditorContext
Definition: qgsdualview.h:246
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
QSignalMapper * mPreviewActionMapper
Definition: qgsdualview.h:252
QgsMapLayerAction * mAction
Definition: qgsdualview.h:295
QgsFeatureListModel * mFeatureListModel
Definition: qgsdualview.h:249
QgsIFeatureSelectionManager * mFeatureSelectionManager
Definition: qgsdualview.h:256
QgsCachedFeatureIterator * mFeatureCache
Definition: qgsdualview.h:251
This class wraps a request for features to a vector layer (or directly its vector data provider)...
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:135
General purpose distance and area calculator.
QgsVectorLayerCache * mLayerCache
Definition: qgsdualview.h:254
QgsAttributeDialog * mAttributeDialog
Definition: qgsdualview.h:250
QgsAttributeTableFilterModel * mFilterModel
Definition: qgsdualview.h:248
qint64 QgsFeatureId
Definition: qgsfeature.h:30
QgsDualView * mDualView
Definition: qgsdualview.h:276
Delivers features from the cache.
QProgressDialog * mProgressDlg
Definition: qgsdualview.h:255
Is an interface class to abstract feature selection handling.
QgsAttributeTableModel * mMasterModel
Definition: qgsdualview.h:247
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
QgsDistanceArea mDistanceArea
Definition: qgsdualview.h:257