QGIS API Documentation  2.0.1-Dufour
 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 "qgsdistancearea.h"
24 #include "ui_qgsdualviewbase.h"
25 
26 class QgsFeatureRequest;
27 class QgsAttributeDialog;
28 class QSignalMapper;
29 
39 class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
40 {
41  Q_OBJECT
42 
43  public:
44 
50  enum ViewMode
51  {
55  AttributeTable = 0,
61  AttributeEditor = 1
62  };
63 
68  explicit QgsDualView( QWidget* parent = 0 );
69  virtual ~QgsDualView();
70 
79  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QgsDistanceArea myDa );
80 
86  void setView( ViewMode view );
87 
93  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
94 
101  void setSelectedOnTop( bool selectedOnTop );
102 
108  int featureCount();
109 
116  int filteredFeatureCount();
117 
124  void setFilteredFeatures( QgsFeatureIds filteredFeatures );
125 
131  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
132 
133  protected:
137  void columnBoxInit();
138 
139  virtual void hideEvent( QHideEvent * );
140  virtual void focusOutEvent( QFocusEvent * );
141 
142  public slots:
148  void setCurrentEditSelection( const QgsFeatureIds& fids );
149 
153  void saveEditChanges();
154 
158  void reloadAttribute( const int& attribute );
159 
160 
161  signals:
166  void displayExpressionChanged( const QString expression );
167 
171  void filterChanged();
172 
173  private slots:
179  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
180 
181  void previewExpressionBuilder();
182 
183  void previewColumnChanged( QObject* previewAction );
184 
185  void editingToggled();
186 
187  void viewWillShowContextMenu( QMenu* menu, QModelIndex atIndex );
188 
189  void previewExpressionChanged( const QString expression );
190 
198  void attributeDeleted( int attribute );
199 
207  void attributeAdded( int attribute );
208 
215  void featureDeleted( QgsFeatureId fid );
216 
223  virtual void progress( int i, bool& cancel );
224 
229  virtual void finished();
230 
231  private:
232  void initLayerCache( QgsVectorLayer *layer );
233  void initModels( QgsMapCanvas* mapCanvas );
234 
240  QSignalMapper* mPreviewActionMapper;
243  QProgressDialog* mProgressDlg;
244 
246 
247  friend class TestQgsDualView;
248 };
249 
250 class GUI_EXPORT QgsAttributeTableAction : public QAction
251 {
252  Q_OBJECT
253 
254  public:
255  QgsAttributeTableAction( const QString &name, QgsDualView *dualView, int action, const QModelIndex &fieldIdx ) :
256  QAction( name, dualView ), mDualView( dualView ), mAction( action ), mFieldIdx( fieldIdx )
257  {}
258 
259  public slots:
260  void execute();
261  void featureForm();
262 
263  private:
265  int mAction;
266  QModelIndex mFieldIdx;
267 };
268 
269 #endif // QGSFEATURELIST_H