QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
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;
35
44class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
45{
46 Q_OBJECT
47
48 public:
55 {
56
60 AttributeTable = 0,
61
67 AttributeEditor = 1
68 };
69 Q_ENUM( ViewMode )
70
71
72
79 Q_ENUM( FeatureListBrowsingAction )
80
81
85 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
86 ~QgsDualView() override;
87
100 void init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request = QgsFeatureRequest(), const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), bool loadFeatures = true, bool showFirstFeature = true );
101
108 void setView( ViewMode view );
109
114 ViewMode view() const;
115
121 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
122
128 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
129
136 void setSelectedOnTop( bool selectedOnTop );
137
143 int featureCount();
144
151 int filteredFeatureCount();
152
160 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
161
168 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
169
173 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
174
180 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
181
187 void setRequest( const QgsFeatureRequest &request );
188
194 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
195
201 QgsAttributeTableView *tableView() { return mTableView; }
202
207 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
208
212 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
213
217 QString sortExpression() const;
218
223 QgsAttributeTableConfig attributeTableConfig() const;
224
230 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
231
232 public slots:
233
239 void setCurrentEditSelection( const QgsFeatureIds &fids );
240
247 bool saveEditChanges();
248
249 void openConditionalStyles();
250
254 void setMultiEditEnabled( bool enabled );
255
260 void toggleSearchMode( bool enabled );
261
265 void copyCellContent() const;
266
270 void cancelProgress();
271
280 void parentFormValueChanged( const QString &attribute, const QVariant &value );
281
282 signals:
283
288 void displayExpressionChanged( const QString &expression );
289
294
300 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
301
307
314
315 protected:
316 void hideEvent( QHideEvent *event ) override;
317
318 private slots:
319
320 void featureListAboutToChangeEditSelection( bool &ok );
321
327 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
328
329 void previewExpressionBuilder();
330
331 void previewColumnChanged( QAction *previewAction, const QString &expression );
332
333 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
334
335 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
336
337 void showViewHeaderMenu( QPoint point );
338
339 void organizeColumns();
340
341 void tableColumnResized( int column, int width );
342
343 void hideColumn();
344
345 void resizeColumn();
346
347 void resizeAllColumns();
348
349 void autosizeColumn();
350
351 void autosizeAllColumns();
352
353 void previewExpressionChanged( const QString &expression );
354
355 void onSortColumnChanged();
356
357 void updateSelectedFeatures();
358 void updateEditedAddedFeatures();
359
360 void extentChanged();
361
367 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
368
375 virtual void progress( int i, bool &cancel );
376
381 virtual void finished();
382
384 void zoomToCurrentFeature();
386 void panToCurrentFeature();
387
388 void flashCurrentFeature();
389
390 void rebuildFullLayerCache();
391
392 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
393
394 void flashButtonClicked( bool clicked );
395
396 void filterError( const QString &errorMessage );
397
398 private:
404 void initAttributeForm( const QgsFeature &feature );
405
409 void columnBoxInit();
410 void initLayerCache( bool cacheGeometry );
411 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
412 void restoreRecentDisplayExpressions();
413 void saveRecentDisplayExpressions() const;
414 void setDisplayExpression( const QString &expression );
415 void insertRecentlyUsedDisplayExpression( const QString &expression );
416 void updateEditSelectionProgress( int progress, int count );
417 void panOrZoomToFeature( const QgsFeatureIds &featureset );
419 void setBrowsingAutoPanScaleAllowed( bool allowed );
420
422 bool modifySort();
423
424 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
425 QgsAttributeEditorContext mEditorContext;
426 QgsAttributeTableModel *mMasterModel = nullptr;
427 QgsAttributeTableFilterModel *mFilterModel = nullptr;
428 QgsFeatureListModel *mFeatureListModel = nullptr;
429 QgsAttributeForm *mAttributeForm = nullptr;
430 QMenu *mPreviewColumnsMenu = nullptr;
431 QMenu *mPreviewActionMenu = nullptr;
432 QAction *mLastDisplayExpressionAction = nullptr;
433 QMenu *mHorizontalHeaderMenu = nullptr;
434 QgsVectorLayerCache *mLayerCache = nullptr;
435 QPointer<QgsVectorLayer> mLayer = nullptr;
436 QProgressDialog *mProgressDlg = nullptr;
437 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
438 QString mDisplayExpression;
440 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
441 QgsFeatureIds mLastFeatureSet;
442 bool mBrowsingAutoPanScaleAllowed = true;
443 ViewMode mPreviousView = AttributeTable;
444
445 friend class TestQgsDualView;
446 friend class TestQgsAttributeTable;
447};
448
453class GUI_EXPORT QgsAttributeTableAction : public QAction
454{
455 Q_OBJECT
456
457 public:
462 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
463 : QAction( name, dualView )
464 , mDualView( dualView )
465 , mAction( action )
466 , mFieldIdx( fieldIdx )
467 {}
468
469 public slots:
470 void execute();
471 void featureForm();
472
473 private:
474 QgsDualView *mDualView = nullptr;
475 QUuid mAction;
476 QModelIndex mFieldIdx;
477};
478
483class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
484{
485 Q_OBJECT
486
487 public:
488 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
489 : QAction( name, dualView )
490 , mDualView( dualView )
491 , mAction( action )
492 , mFieldIdx( fieldIdx )
493 {}
494
495 public slots:
496 void execute();
497
498 private:
499 QgsDualView *mDualView = nullptr;
500 QgsMapLayerAction *mAction = nullptr;
501 QModelIndex mFieldIdx;
502};
503
504Q_DECLARE_METATYPE( QModelIndex );
505
506#endif // QGSDUALVIEW_H
This class is a menu that is populated automatically with the actions defined for a given layer.
This class contains context information for attribute editor widgets.
FilterType
Filter types.
QgsAttributeTableAction(const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx)
Create a new attribute table action.
This is a container for configuration of the attribute table.
FilterMode
The filter mode defines how the rows should be filtered.
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:45
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:55
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:74
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:76
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:77
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...
Class for parsing and evaluation of expressions (formerly called "search strings").
This class 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 The class can be used in two manners:
A QScrollArea subclass with improved scrolling behavior.
This class caches features of a given QgsVectorLayer.
Represents a vector layer which manages a vector based data sets.
#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