QGIS API Documentation  2.5.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 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 
46  public:
47 
53  enum ViewMode
54  {
58  AttributeTable = 0,
64  AttributeEditor = 1
65  };
66 
71  explicit QgsDualView( QWidget* parent = 0 );
72 
82  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), QgsAttributeEditorContext context = QgsAttributeEditorContext() );
83 
89  void setView( ViewMode view );
90 
96  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
97 
98  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
99 
106  void setSelectedOnTop( bool selectedOnTop );
107 
113  int featureCount();
114 
121  int filteredFeatureCount();
122 
129  void setFilteredFeatures( QgsFeatureIds filteredFeatures );
130 
131  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
132 
138  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
139 
140  void setRequest( const QgsFeatureRequest& request );
141 
142  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
143 
144  protected:
148  void columnBoxInit();
149 
150  public slots:
156  void setCurrentEditSelection( const QgsFeatureIds& fids );
157 
164  bool saveEditChanges();
165 
166  signals:
171  void displayExpressionChanged( const QString expression );
172 
176  void filterChanged();
177 
178  private slots:
179 
180  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
181 
187  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
188 
189  void previewExpressionBuilder();
190 
191  void previewColumnChanged( QObject* previewAction );
192 
193  void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );
194 
195  void previewExpressionChanged( const QString expression );
196 
202  void featureFormAttributeChanged();
203 
210  virtual void progress( int i, bool& cancel );
211 
216  virtual void finished();
217 
218  private:
219  void initLayerCache( QgsVectorLayer *layer );
220  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
221 
228  QSignalMapper* mPreviewActionMapper;
231  QProgressDialog* mProgressDlg;
234 
235  friend class TestQgsDualView;
236 };
237 
238 class GUI_EXPORT QgsAttributeTableAction : public QAction
239 {
240  Q_OBJECT
241 
242  public:
243  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
244  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
245  {}
246 
247  public slots:
248  void execute();
249  void featureForm();
250 
251  private:
253  int mAction;
254  QModelIndex mFieldIdx;
255 };
256 
257 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
258 {
259  Q_OBJECT
260 
261  public:
262  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx ) :
263  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
264  {}
265 
266  public slots:
267  void execute();
268 
269  private:
272  QModelIndex mFieldIdx;
273 };
274 
275 #endif // QGSFEATURELIST_H
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
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:243
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:262
QgsAttributeForm * mAttributeForm
Definition: qgsdualview.h:226
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...
QMenu * mPreviewColumnsMenu
Definition: qgsdualview.h:229
QgsAttributeEditorContext mEditorContext
Definition: qgsdualview.h:222
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
QSignalMapper * mPreviewActionMapper
Definition: qgsdualview.h:228
QgsMapLayerAction * mAction
Definition: qgsdualview.h:271
QgsFeatureListModel * mFeatureListModel
Definition: qgsdualview.h:225
QgsIFeatureSelectionManager * mFeatureSelectionManager
Definition: qgsdualview.h:232
QgsCachedFeatureIterator * mFeatureCache
Definition: qgsdualview.h:227
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureIds filteredFeatures()
Definition: qgsdualview.h:131
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:138
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:98
General purpose distance and area calculator.
QgsVectorLayerCache * mLayerCache
Definition: qgsdualview.h:230
QgsAttributeTableFilterModel * mFilterModel
Definition: qgsdualview.h:224
QgsDualView * mDualView
Definition: qgsdualview.h:252
Delivers features from the cache.
QProgressDialog * mProgressDlg
Definition: qgsdualview.h:231
Is an interface class to abstract feature selection handling.
QgsAttributeTableModel * mMasterModel
Definition: qgsdualview.h:223
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:233