QGIS API Documentation  2.99.0-Master (e077efd)
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 at opengis 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 QGSDUALVIEW_H
17 #define QGSDUALVIEW_H
18 
19 #include <QStackedWidget>
20 
21 #include "ui_qgsdualviewbase.h"
22 
25 #include "qgsdistancearea.h"
26 #include "qgsattributeform.h"
27 
28 class QgsFeatureRequest;
29 class QSignalMapper;
30 class QgsMapLayerAction;
31 class QScrollArea;
32 
40 class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
41 {
42  Q_OBJECT
43  Q_ENUMS( ViewMode )
44 
45  public:
46 
52  enum ViewMode
53  {
54 
58  AttributeTable = 0,
59 
65  AttributeEditor = 1
66  };
67 
72  explicit QgsDualView( QWidget* parent = nullptr );
73 
83  void init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext() );
84 
91  void setView( ViewMode view );
92 
98  ViewMode view() const;
99 
105  void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
106 
112  QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
113 
120  void setSelectedOnTop( bool selectedOnTop );
121 
127  int featureCount();
128 
135  int filteredFeatureCount();
136 
143  void setFilteredFeatures( const QgsFeatureIds& filteredFeatures );
144 
148  QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
149 
155  QgsAttributeTableModel* masterModel() const { return mMasterModel; }
156 
162  void setRequest( const QgsFeatureRequest& request );
163 
169  void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
170 
176  QgsAttributeTableView* tableView() { return mTableView; }
177 
182  void setAttributeTableConfig( const QgsAttributeTableConfig& config );
183 
187  void setSortExpression( const QString& sortExpression , Qt::SortOrder sortOrder = Qt::AscendingOrder );
188 
192  QString sortExpression() const;
193 
194  protected:
195 
199  void columnBoxInit();
200 
201  public slots:
202 
208  void setCurrentEditSelection( const QgsFeatureIds& fids );
209 
216  bool saveEditChanges();
217 
218  void openConditionalStyles();
219 
223  void setMultiEditEnabled( bool enabled );
224 
229  void toggleSearchMode( bool enabled );
230 
235  void copyCellContent() const;
236 
237  signals:
238 
243  void displayExpressionChanged( const QString& expression );
244 
248  void filterChanged();
249 
255  void filterExpressionSet( const QString& expression, QgsAttributeForm::FilterType type );
256 
260  void formModeChanged( QgsAttributeForm::Mode mode );
261 
262  private slots:
263 
264  void on_mFeatureList_aboutToChangeEditSelection( bool& ok );
265 
271  void on_mFeatureList_currentEditSelectionChanged( const QgsFeature& feat );
272 
273  void previewExpressionBuilder();
274 
275  void previewColumnChanged( QObject* previewAction );
276 
277  void viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex );
278 
279  void showViewHeaderMenu( QPoint point );
280 
281  void organizeColumns();
282 
283  void tableColumnResized( int column, int width );
284 
285  void hideColumn();
286 
287  void resizeColumn();
288 
289  void autosizeColumn();
290 
291  void modifySort();
292 
293  void previewExpressionChanged( const QString& expression );
294 
295  void onSortColumnChanged();
296 
297  void sortByPreviewExpression();
298 
304  void featureFormAttributeChanged();
305 
312  virtual void progress( int i, bool &cancel );
313 
318  virtual void finished();
319 
321  void zoomToCurrentFeature();
323  void panToCurrentFeature();
324 
325  private:
326  void initLayerCache( QgsVectorLayer *layer, bool cacheGeometry );
327  void initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request );
328 
329  QgsAttributeEditorContext mEditorContext;
330  QgsAttributeTableModel* mMasterModel;
331  QgsAttributeTableFilterModel* mFilterModel;
332  QgsFeatureListModel* mFeatureListModel;
333  QgsAttributeForm* mAttributeForm;
334  QSignalMapper* mPreviewActionMapper;
335  QMenu* mPreviewColumnsMenu;
336  QMenu* mHorizontalHeaderMenu;
337  QgsVectorLayerCache* mLayerCache;
338  QProgressDialog* mProgressDlg;
339  QgsIFeatureSelectionManager* mFeatureSelectionManager;
340  QgsDistanceArea mDistanceArea;
341  QString mDisplayExpression;
342  QgsAttributeTableConfig mConfig;
343  QScrollArea* mAttributeEditorScrollArea;
344 
345  friend class TestQgsDualView;
346 };
347 
351 class GUI_EXPORT QgsAttributeTableAction : public QAction
352 {
353  Q_OBJECT
354 
355  public:
356 
362  QgsAttributeTableAction( const QString& name, QgsDualView* dualView, const QUuid& action, const QModelIndex& fieldIdx )
363  : QAction( name, dualView )
364  , mDualView( dualView )
365  , mAction( action )
366  , mFieldIdx( fieldIdx )
367  {}
368 
369  public slots:
370  void execute();
371  void featureForm();
372 
373  private:
374  QgsDualView* mDualView;
375  QUuid mAction;
376  QModelIndex mFieldIdx;
377 };
378 
382 class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
383 {
384  Q_OBJECT
385 
386  public:
387  QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction* action, const QModelIndex &fieldIdx )
388  : QAction( name, dualView )
389  , mDualView( dualView )
390  , mAction( action )
391  , mFieldIdx( fieldIdx )
392  {}
393 
394  public slots:
395  void execute();
396 
397  private:
398  QgsDualView* mDualView;
399  QgsMapLayerAction* mAction;
400  QModelIndex mFieldIdx;
401 };
402 
403 Q_DECLARE_METATYPE( QModelIndex );
404 
405 #endif // QGSDUALVIEW_H
Provides a table view of features of a QgsVectorLayer.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
Definition: qgsdualview.h:155
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:355
This class contains context information for attribute editor widgets.
QgsAttributeTableView * tableView()
Returns the table view.
Definition: qgsdualview.h:176
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:52
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
Definition: qgsdualview.h:387
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Q_DECLARE_METATYPE(QModelIndex)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:106
FilterType
Filter types.
FilterMode
The filter mode defines how the rows should be filtered.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureIds filteredFeatures()
Get a list of currently visible feature ids.
Definition: qgsdualview.h:148
This class caches features of a given QgsVectorLayer.
QgsAttributeTableFilterModel::FilterMode filterMode()
Get the filter mode.
Definition: qgsdualview.h:112
General purpose distance and area calculator.
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, const QUuid &action, const QModelIndex &fieldIdx)
Create a new attribute table action.
Definition: qgsdualview.h:362
This is a container for configuration of the attribute table.
Is an interface class to abstract feature selection handling.
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:40