QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgsdualviewbase.h"
20
21#include "qgis_gui.h"
23#include "qgsattributeform.h"
25
26#include <QPointer>
27#include <QStackedWidget>
28#include <QUuid>
29
32class QgsScrollArea;
35
46class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
47{
48 Q_OBJECT
49
50 public:
57 {
58
63
70 };
71 Q_ENUM( ViewMode )
72
73
74
81 Q_ENUM( FeatureListBrowsingAction )
82
83
87 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
88 ~QgsDualView() override;
89
102 void init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request = QgsFeatureRequest(), const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), bool loadFeatures = true, bool showFirstFeature = true );
103
110 void setView( ViewMode view );
111
116 ViewMode view() const;
117
123 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
124
130 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
131
138 void setSelectedOnTop( bool selectedOnTop );
139
145 int featureCount();
146
153 int filteredFeatureCount();
154
162 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
163
170 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
171
175 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
176
182 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
183
189 void setRequest( const QgsFeatureRequest &request );
190
196 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
197
203 QgsAttributeTableView *tableView() { return mTableView; }
204
209 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
210
214 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
215
219 QString sortExpression() const;
220
225 QgsAttributeTableConfig attributeTableConfig() const;
226
232 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
233
234 public slots:
235
241 void setCurrentEditSelection( const QgsFeatureIds &fids );
242
249 bool saveEditChanges();
250
251 void openConditionalStyles();
252
256 void setMultiEditEnabled( bool enabled );
257
262 void toggleSearchMode( bool enabled );
263
267 void copyCellContent() const;
268
272 void cancelProgress();
273
282 void parentFormValueChanged( const QString &attribute, const QVariant &value );
283
284 signals:
285
290 void displayExpressionChanged( const QString &expression );
291
296
302 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
303
309
316
317 protected:
318 void hideEvent( QHideEvent *event ) override;
319
320 private slots:
321
322 void featureListAboutToChangeEditSelection( bool &ok );
323
329 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
330
331 void previewExpressionBuilder();
332
333 void previewColumnChanged( QAction *previewAction, const QString &expression );
334
335 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
336
337 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
338
339 void showViewHeaderMenu( QPoint point );
340
341 void organizeColumns();
342
343 void tableColumnResized( int column, int width );
344
345 void hideColumn();
346
347 void resizeColumn();
348
349 void resizeAllColumns();
350
351 void autosizeColumn();
352
353 void autosizeAllColumns();
354
355 void previewExpressionChanged( const QString &expression );
356
357 void onSortColumnChanged();
358
359 void updateSelectedFeatures();
360 void updateEditedAddedFeatures();
361
362 void extentChanged();
363
369 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
370
377 virtual void progress( int i, bool &cancel );
378
383 virtual void finished();
384
386 void zoomToCurrentFeature();
388 void panToCurrentFeature();
389
390 void flashCurrentFeature();
391
392 void rebuildFullLayerCache();
393
394 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
395
396 void flashButtonClicked( bool clicked );
397
398 void filterError( const QString &errorMessage );
399
400 private:
406 void initAttributeForm( const QgsFeature &feature );
407
411 void columnBoxInit();
412 void initLayerCache( bool cacheGeometry );
413 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
414 void restoreRecentDisplayExpressions();
415 void saveRecentDisplayExpressions() const;
416 void setDisplayExpression( const QString &expression );
417 void insertRecentlyUsedDisplayExpression( const QString &expression );
418 void updateEditSelectionProgress( int progress, int count );
419 void panOrZoomToFeature( const QgsFeatureIds &featureset );
421 void setBrowsingAutoPanScaleAllowed( bool allowed );
422
424 bool modifySort();
425
426 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
427 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
428
429 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
430 QgsAttributeEditorContext mEditorContext;
431 QgsAttributeTableModel *mMasterModel = nullptr;
432 QgsAttributeTableFilterModel *mFilterModel = nullptr;
433 QgsFeatureListModel *mFeatureListModel = nullptr;
434 QgsAttributeForm *mAttributeForm = nullptr;
435 QMenu *mPreviewColumnsMenu = nullptr;
436 QMenu *mPreviewActionMenu = nullptr;
437 QAction *mLastDisplayExpressionAction = nullptr;
438 QMenu *mHorizontalHeaderMenu = nullptr;
439 QgsVectorLayerCache *mLayerCache = nullptr;
440 QPointer<QgsVectorLayer> mLayer = nullptr;
441 QProgressDialog *mProgressDlg = nullptr;
442 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
443 QString mDisplayExpression;
445 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
446 QgsFeatureIds mLastFeatureSet;
447 bool mBrowsingAutoPanScaleAllowed = true;
448 ViewMode mPreviousView = AttributeTable;
449
450 friend class TestQgsDualView;
452};
453
459class GUI_EXPORT QgsAttributeTableAction : public QAction
460{
461 Q_OBJECT
462
463 public:
468 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
469 : QAction( name, dualView )
470 , mDualView( dualView )
471 , mAction( action )
472 , mFieldIdx( fieldIdx )
473 {}
474
475 public slots:
476 void execute();
477 void featureForm();
478
479 private:
480 QgsDualView *mDualView = nullptr;
481 QUuid mAction;
482 QModelIndex mFieldIdx;
483};
484
490class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
491{
492 Q_OBJECT
493
494 public:
495 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
496 : QAction( name, dualView )
497 , mDualView( dualView )
498 , mAction( action )
499 , mFieldIdx( fieldIdx )
500 {}
501
502 public slots:
503 void execute();
504
505 private:
506 QgsDualView *mDualView = nullptr;
507 QgsMapLayerAction *mAction = nullptr;
508 QModelIndex mFieldIdx;
509};
510
511Q_DECLARE_METATYPE( QModelIndex );
512
513#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.
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.
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:47
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:57
@ AttributeTable
Shows the features and attributes in a table layout.
Definition qgsdualview.h:62
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition qgsdualview.h:69
friend class TestQgsAttributeTable
QgsAttributeTableFilterModel::FilterMode filterMode()
Gets the filter mode.
QgsFeatureIds filteredFeatures()
Gets a list of currently visible feature ids.
void filterChanged()
Emitted whenever the filter changes.
QgsDualView(QWidget *parent=nullptr)
Constructor.
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:76
@ NoAction
No action is done.
Definition qgsdualview.h:77
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:78
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:79
void hideEvent(QHideEvent *event) override
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Emitted when a filter expression is set using the view.
friend class TestQgsDualView
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:28