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  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 
229  QSignalMapper* mPreviewActionMapper;
232  QProgressDialog* mProgressDlg;
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:
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:
273  QModelIndex mFieldIdx;
274 };
275 
276 #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:54
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:244
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:263
QgsAttributeForm * mAttributeForm
Definition: qgsdualview.h:227
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:230
QgsAttributeEditorContext mEditorContext
Definition: qgsdualview.h:223
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
QSignalMapper * mPreviewActionMapper
Definition: qgsdualview.h:229
QgsMapLayerAction * mAction
Definition: qgsdualview.h:272
QgsFeatureListModel * mFeatureListModel
Definition: qgsdualview.h:226
QgsIFeatureSelectionManager * mFeatureSelectionManager
Definition: qgsdualview.h:233
QgsCachedFeatureIterator * mFeatureCache
Definition: qgsdualview.h:228
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureIds filteredFeatures()
Definition: qgsdualview.h:132
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:139
QgsAttributeTableFilterModel::FilterMode filterMode()
Definition: qgsdualview.h:99
General purpose distance and area calculator.
QgsVectorLayerCache * mLayerCache
Definition: qgsdualview.h:231
QgsAttributeTableFilterModel * mFilterModel
Definition: qgsdualview.h:225
QgsDualView * mDualView
Definition: qgsdualview.h:253
Delivers features from the cache.
QProgressDialog * mProgressDlg
Definition: qgsdualview.h:232
Is an interface class to abstract feature selection handling.
QgsAttributeTableModel * mMasterModel
Definition: qgsdualview.h:224
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:234