QGIS API Documentation 3.43.0-Master (c67cf405802)
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 "qgsattributeform.h"
26#include "qgis_gui.h"
27
28#include <QPointer>
29#include <QUuid>
30
33class QgsScrollArea;
36
47class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
48{
49 Q_OBJECT
50
51 public:
58 {
59
63 AttributeTable = 0,
64
70 AttributeEditor = 1
71 };
72 Q_ENUM( ViewMode )
73
74
75
82 Q_ENUM( FeatureListBrowsingAction )
83
84
88 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
89 ~QgsDualView() override;
90
103 void init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request = QgsFeatureRequest(), const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), bool loadFeatures = true, bool showFirstFeature = true );
104
111 void setView( ViewMode view );
112
117 ViewMode view() const;
118
124 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
125
131 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
132
139 void setSelectedOnTop( bool selectedOnTop );
140
146 int featureCount();
147
154 int filteredFeatureCount();
155
163 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
164
171 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
172
176 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
177
183 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
184
190 void setRequest( const QgsFeatureRequest &request );
191
197 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
198
204 QgsAttributeTableView *tableView() { return mTableView; }
205
210 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
211
215 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
216
220 QString sortExpression() const;
221
226 QgsAttributeTableConfig attributeTableConfig() const;
227
233 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
234
235 public slots:
236
242 void setCurrentEditSelection( const QgsFeatureIds &fids );
243
250 bool saveEditChanges();
251
252 void openConditionalStyles();
253
257 void setMultiEditEnabled( bool enabled );
258
263 void toggleSearchMode( bool enabled );
264
268 void copyCellContent() const;
269
273 void cancelProgress();
274
283 void parentFormValueChanged( const QString &attribute, const QVariant &value );
284
285 signals:
286
291 void displayExpressionChanged( const QString &expression );
292
297
303 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
304
310
317
318 protected:
319 void hideEvent( QHideEvent *event ) override;
320
321 private slots:
322
323 void featureListAboutToChangeEditSelection( bool &ok );
324
330 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
331
332 void previewExpressionBuilder();
333
334 void previewColumnChanged( QAction *previewAction, const QString &expression );
335
336 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
337
338 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
339
340 void showViewHeaderMenu( QPoint point );
341
342 void organizeColumns();
343
344 void tableColumnResized( int column, int width );
345
346 void hideColumn();
347
348 void resizeColumn();
349
350 void resizeAllColumns();
351
352 void autosizeColumn();
353
354 void autosizeAllColumns();
355
356 void previewExpressionChanged( const QString &expression );
357
358 void onSortColumnChanged();
359
360 void updateSelectedFeatures();
361 void updateEditedAddedFeatures();
362
363 void extentChanged();
364
370 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
371
378 virtual void progress( int i, bool &cancel );
379
384 virtual void finished();
385
387 void zoomToCurrentFeature();
389 void panToCurrentFeature();
390
391 void flashCurrentFeature();
392
393 void rebuildFullLayerCache();
394
395 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
396
397 void flashButtonClicked( bool clicked );
398
399 void filterError( const QString &errorMessage );
400
401 private:
407 void initAttributeForm( const QgsFeature &feature );
408
412 void columnBoxInit();
413 void initLayerCache( bool cacheGeometry );
414 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
415 void restoreRecentDisplayExpressions();
416 void saveRecentDisplayExpressions() const;
417 void setDisplayExpression( const QString &expression );
418 void insertRecentlyUsedDisplayExpression( const QString &expression );
419 void updateEditSelectionProgress( int progress, int count );
420 void panOrZoomToFeature( const QgsFeatureIds &featureset );
422 void setBrowsingAutoPanScaleAllowed( bool allowed );
423
425 bool modifySort();
426
427 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
428 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
429
430 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
431 QgsAttributeEditorContext mEditorContext;
432 QgsAttributeTableModel *mMasterModel = nullptr;
433 QgsAttributeTableFilterModel *mFilterModel = nullptr;
434 QgsFeatureListModel *mFeatureListModel = nullptr;
435 QgsAttributeForm *mAttributeForm = nullptr;
436 QMenu *mPreviewColumnsMenu = nullptr;
437 QMenu *mPreviewActionMenu = nullptr;
438 QAction *mLastDisplayExpressionAction = nullptr;
439 QMenu *mHorizontalHeaderMenu = nullptr;
440 QgsVectorLayerCache *mLayerCache = nullptr;
441 QPointer<QgsVectorLayer> mLayer = nullptr;
442 QProgressDialog *mProgressDlg = nullptr;
443 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
444 QString mDisplayExpression;
446 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
447 QgsFeatureIds mLastFeatureSet;
448 bool mBrowsingAutoPanScaleAllowed = true;
449 ViewMode mPreviousView = AttributeTable;
450
451 friend class TestQgsDualView;
452 friend class TestQgsAttributeTable;
453};
454
460class GUI_EXPORT QgsAttributeTableAction : public QAction
461{
462 Q_OBJECT
463
464 public:
469 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
470 : QAction( name, dualView )
471 , mDualView( dualView )
472 , mAction( action )
473 , mFieldIdx( fieldIdx )
474 {}
475
476 public slots:
477 void execute();
478 void featureForm();
479
480 private:
481 QgsDualView *mDualView = nullptr;
482 QUuid mAction;
483 QModelIndex mFieldIdx;
484};
485
491class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
492{
493 Q_OBJECT
494
495 public:
496 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
497 : QAction( name, dualView )
498 , mDualView( dualView )
499 , mAction( action )
500 , mFieldIdx( fieldIdx )
501 {}
502
503 public slots:
504 void execute();
505
506 private:
507 QgsDualView *mDualView = nullptr;
508 QgsMapLayerAction *mAction = nullptr;
509 QModelIndex mFieldIdx;
510};
511
512Q_DECLARE_METATYPE( QModelIndex );
513
514#endif // QGSDUALVIEW_H
A menu that is populated automatically with the actions defined for a given layer.
Contains context information for attribute editor widgets.
The attribute form widget for vector layer features.
FilterType
Filter types.
A QAction subclass for map layer actions shown in an attribute table.
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx)
Create a new attribute table action.
A container for configuration of the attribute table.
A proxy model for filtering an attribute table model.
FilterMode
The filter mode defines how the rows should be filtered.
A QAction for attribute table map layer actions.
QgsAttributeTableMapLayerAction(const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx)
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Provides a table view of features of a QgsVectorLayer.
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Definition qgsdualview.h:48
void showContextMenuExternally(QgsActionMenu *menu, QgsFeatureId fid)
Emitted when selecting context menu on the feature list to create the context menu individually.
ViewMode
The view modes, in which this widget can present information.
Definition qgsdualview.h:58
QgsAttributeTableFilterModel::FilterMode filterMode()
Gets the filter mode.
QgsFeatureIds filteredFeatures()
Gets a list of currently visible feature ids.
void filterChanged()
Emitted whenever the filter changes.
QgsAttributeTableView * tableView()
Returns the table view.
void formModeChanged(QgsAttributeEditorContext::Mode mode)
Emitted when the form changes mode.
FeatureListBrowsingAction
Action on the map canvas when browsing the list of features.
Definition qgsdualview.h:77
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:79
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:80
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Emitted when a filter expression is set using the view.
void displayExpressionChanged(const QString &expression)
Emitted whenever the display expression is successfully changed.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
A proxy model for feature lists.
Wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A widget for customizing conditional formatting options.
Is an interface class to abstract feature selection handling.
Map canvas is a class for displaying all GIS data types on a canvas.
An action which can run on map layers.
A QScrollArea subclass with improved scrolling behavior.
A variant settings entry.
Caches features for a given QgsVectorLayer.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
Q_DECLARE_METATYPE(QModelIndex)
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QList< int > QgsAttributeList
Definition qgsfield.h:27