QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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:
49
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,
102 QgsMapCanvas *mapCanvas,
103 const QgsFeatureRequest &request = QgsFeatureRequest(),
105 bool loadFeatures = true, bool showFirstFeature = true );
106
113 void setView( ViewMode view );
114
120 ViewMode view() const;
121
127 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
128
134 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
135
142 void setSelectedOnTop( bool selectedOnTop );
143
149 int featureCount();
150
157 int filteredFeatureCount();
158
166 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
167
174 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
175
179 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
180
186 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
187
193 void setRequest( const QgsFeatureRequest &request );
194
200 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
201
207 QgsAttributeTableView *tableView() { return mTableView; }
208
213 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
214
218 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
219
223 QString sortExpression() const;
224
229 QgsAttributeTableConfig attributeTableConfig() const;
230
236 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
237
238 public slots:
239
245 void setCurrentEditSelection( const QgsFeatureIds &fids );
246
253 bool saveEditChanges();
254
255 void openConditionalStyles();
256
261 void setMultiEditEnabled( bool enabled );
262
268 void toggleSearchMode( bool enabled );
269
274 void copyCellContent() const;
275
280 void cancelProgress( );
281
290 void parentFormValueChanged( const QString &attribute, const QVariant &value );
291
292 signals:
293
298 void displayExpressionChanged( const QString &expression );
299
304
311 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
312
318
325
326 protected:
327 void hideEvent( QHideEvent *event ) override;
328
329 private slots:
330
331 void featureListAboutToChangeEditSelection( bool &ok );
332
338 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
339
340 void previewExpressionBuilder();
341
342 void previewColumnChanged( QAction *previewAction, const QString &expression );
343
344 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
345
346 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
347
348 void showViewHeaderMenu( QPoint point );
349
350 void organizeColumns();
351
352 void tableColumnResized( int column, int width );
353
354 void hideColumn();
355
356 void resizeColumn();
357
358 void resizeAllColumns();
359
360 void autosizeColumn();
361
362 void autosizeAllColumns();
363
364 void previewExpressionChanged( const QString &expression );
365
366 void onSortColumnChanged();
367
368 void updateSelectedFeatures();
369 void updateEditedAddedFeatures();
370
371 void extentChanged();
372
378 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
379
386 virtual void progress( int i, bool &cancel );
387
392 virtual void finished();
393
395 void zoomToCurrentFeature();
397 void panToCurrentFeature();
398
399 void flashCurrentFeature();
400
401 void rebuildFullLayerCache();
402
403 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
404
405 void flashButtonClicked( bool clicked );
406
407 void filterError( const QString &errorMessage );
408
409 private:
410
416 void initAttributeForm( const QgsFeature &feature );
417
421 void columnBoxInit();
422 void initLayerCache( bool cacheGeometry );
423 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
424 void restoreRecentDisplayExpressions();
425 void saveRecentDisplayExpressions() const;
426 void setDisplayExpression( const QString &expression );
427 void insertRecentlyUsedDisplayExpression( const QString &expression );
428 void updateEditSelectionProgress( int progress, int count );
429 void panOrZoomToFeature( const QgsFeatureIds &featureset );
431 void setBrowsingAutoPanScaleAllowed( bool allowed );
432
434 bool modifySort();
435
436 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
437 QgsAttributeEditorContext mEditorContext;
438 QgsAttributeTableModel *mMasterModel = nullptr;
439 QgsAttributeTableFilterModel *mFilterModel = nullptr;
440 QgsFeatureListModel *mFeatureListModel = nullptr;
441 QgsAttributeForm *mAttributeForm = nullptr;
442 QMenu *mPreviewColumnsMenu = nullptr;
443 QMenu *mPreviewActionMenu = nullptr;
444 QAction *mLastDisplayExpressionAction = nullptr;
445 QMenu *mHorizontalHeaderMenu = nullptr;
446 QgsVectorLayerCache *mLayerCache = nullptr;
447 QPointer< QgsVectorLayer > mLayer = nullptr;
448 QProgressDialog *mProgressDlg = nullptr;
449 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
450 QString mDisplayExpression;
452 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
453 QgsFeatureIds mLastFeatureSet;
454 bool mBrowsingAutoPanScaleAllowed = true;
455 ViewMode mPreviousView = AttributeTable;
456
457 friend class TestQgsDualView;
458 friend class TestQgsAttributeTable;
459};
460
465class GUI_EXPORT QgsAttributeTableAction : public QAction
466{
467 Q_OBJECT
468
469 public:
470
476 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
477 : QAction( name, dualView )
478 , mDualView( dualView )
479 , mAction( action )
480 , mFieldIdx( fieldIdx )
481 {}
482
483 public slots:
484 void execute();
485 void featureForm();
486
487 private:
488 QgsDualView *mDualView = nullptr;
489 QUuid mAction;
490 QModelIndex mFieldIdx;
491};
492
497class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
498{
499 Q_OBJECT
500
501 public:
502 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
503 : QAction( name, dualView )
504 , mDualView( dualView )
505 , mAction( action )
506 , mFieldIdx( fieldIdx )
507 {}
508
509 public slots:
510 void execute();
511
512 private:
513 QgsDualView *mDualView = nullptr;
514 QgsMapLayerAction *mAction = nullptr;
515 QModelIndex mFieldIdx;
516};
517
518Q_DECLARE_METATYPE( QModelIndex );
519
520#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: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:56
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