QGIS API Documentation 3.41.0-Master (af5edcb665c)
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;
36
45class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
46{
47 Q_OBJECT
48
49 public:
56 {
57
61 AttributeTable = 0,
62
68 AttributeEditor = 1
69 };
70 Q_ENUM( ViewMode )
71
72
73
80 Q_ENUM( FeatureListBrowsingAction )
81
82
86 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
87 ~QgsDualView() override;
88
101 void init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request = QgsFeatureRequest(), const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), bool loadFeatures = true, bool showFirstFeature = true );
102
109 void setView( ViewMode view );
110
115 ViewMode view() const;
116
122 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
123
129 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
130
137 void setSelectedOnTop( bool selectedOnTop );
138
144 int featureCount();
145
152 int filteredFeatureCount();
153
161 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
162
169 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
170
174 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
175
181 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
182
188 void setRequest( const QgsFeatureRequest &request );
189
195 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
196
202 QgsAttributeTableView *tableView() { return mTableView; }
203
208 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
209
213 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
214
218 QString sortExpression() const;
219
224 QgsAttributeTableConfig attributeTableConfig() const;
225
231 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
232
233 public slots:
234
240 void setCurrentEditSelection( const QgsFeatureIds &fids );
241
248 bool saveEditChanges();
249
250 void openConditionalStyles();
251
255 void setMultiEditEnabled( bool enabled );
256
261 void toggleSearchMode( bool enabled );
262
266 void copyCellContent() const;
267
271 void cancelProgress();
272
281 void parentFormValueChanged( const QString &attribute, const QVariant &value );
282
283 signals:
284
289 void displayExpressionChanged( const QString &expression );
290
295
301 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
302
308
315
316 protected:
317 void hideEvent( QHideEvent *event ) override;
318
319 private slots:
320
321 void featureListAboutToChangeEditSelection( bool &ok );
322
328 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
329
330 void previewExpressionBuilder();
331
332 void previewColumnChanged( QAction *previewAction, const QString &expression );
333
334 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
335
336 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
337
338 void showViewHeaderMenu( QPoint point );
339
340 void organizeColumns();
341
342 void tableColumnResized( int column, int width );
343
344 void hideColumn();
345
346 void resizeColumn();
347
348 void resizeAllColumns();
349
350 void autosizeColumn();
351
352 void autosizeAllColumns();
353
354 void previewExpressionChanged( const QString &expression );
355
356 void onSortColumnChanged();
357
358 void updateSelectedFeatures();
359 void updateEditedAddedFeatures();
360
361 void extentChanged();
362
368 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
369
376 virtual void progress( int i, bool &cancel );
377
382 virtual void finished();
383
385 void zoomToCurrentFeature();
387 void panToCurrentFeature();
388
389 void flashCurrentFeature();
390
391 void rebuildFullLayerCache();
392
393 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
394
395 void flashButtonClicked( bool clicked );
396
397 void filterError( const QString &errorMessage );
398
399 private:
405 void initAttributeForm( const QgsFeature &feature );
406
410 void columnBoxInit();
411 void initLayerCache( bool cacheGeometry );
412 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
413 void restoreRecentDisplayExpressions();
414 void saveRecentDisplayExpressions() const;
415 void setDisplayExpression( const QString &expression );
416 void insertRecentlyUsedDisplayExpression( const QString &expression );
417 void updateEditSelectionProgress( int progress, int count );
418 void panOrZoomToFeature( const QgsFeatureIds &featureset );
420 void setBrowsingAutoPanScaleAllowed( bool allowed );
421
423 bool modifySort();
424
425 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
426 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
427
428 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
429 QgsAttributeEditorContext mEditorContext;
430 QgsAttributeTableModel *mMasterModel = nullptr;
431 QgsAttributeTableFilterModel *mFilterModel = nullptr;
432 QgsFeatureListModel *mFeatureListModel = nullptr;
433 QgsAttributeForm *mAttributeForm = nullptr;
434 QMenu *mPreviewColumnsMenu = nullptr;
435 QMenu *mPreviewActionMenu = nullptr;
436 QAction *mLastDisplayExpressionAction = nullptr;
437 QMenu *mHorizontalHeaderMenu = nullptr;
438 QgsVectorLayerCache *mLayerCache = nullptr;
439 QPointer<QgsVectorLayer> mLayer = nullptr;
440 QProgressDialog *mProgressDlg = nullptr;
441 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
442 QString mDisplayExpression;
444 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
445 QgsFeatureIds mLastFeatureSet;
446 bool mBrowsingAutoPanScaleAllowed = true;
447 ViewMode mPreviousView = AttributeTable;
448
449 friend class TestQgsDualView;
450 friend class TestQgsAttributeTable;
451};
452
457class GUI_EXPORT QgsAttributeTableAction : public QAction
458{
459 Q_OBJECT
460
461 public:
466 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
467 : QAction( name, dualView )
468 , mDualView( dualView )
469 , mAction( action )
470 , mFieldIdx( fieldIdx )
471 {}
472
473 public slots:
474 void execute();
475 void featureForm();
476
477 private:
478 QgsDualView *mDualView = nullptr;
479 QUuid mAction;
480 QModelIndex mFieldIdx;
481};
482
487class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
488{
489 Q_OBJECT
490
491 public:
492 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
493 : QAction( name, dualView )
494 , mDualView( dualView )
495 , mAction( action )
496 , mFieldIdx( fieldIdx )
497 {}
498
499 public slots:
500 void execute();
501
502 private:
503 QgsDualView *mDualView = nullptr;
504 QgsMapLayerAction *mAction = nullptr;
505 QModelIndex mFieldIdx;
506};
507
508Q_DECLARE_METATYPE( QModelIndex );
509
510#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:46
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:56
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:75
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:77
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:78
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.
A variant settings entry.
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