QGIS API Documentation 4.3.0-Master (16eddb2670e)
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"
22#include "qgis_sip.h"
24#include "qgsattributeform.h"
25
26#include <QPointer>
27#include <QStackedWidget>
28#include <QUuid>
29
32class QgsScrollArea;
37
48class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
49{
50 Q_OBJECT
51
52 public:
54
56
63 {
64
69
76 };
77 Q_ENUM( ViewMode )
78
79
80
87 Q_ENUM( FeatureListBrowsingAction )
88
89
93 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
94 ~QgsDualView() override;
95
108 void init(
109 QgsVectorLayer *layer,
110 QgsMapCanvas *mapCanvas,
111 const QgsFeatureRequest &request = QgsFeatureRequest(),
113 bool loadFeatures = true,
114 bool showFirstFeature = true
115 );
116
123 void setView( ViewMode view );
124
129 ViewMode view() const;
130
136 void setFilterMode( Qgis::AttributeTableFilterMode filterMode );
137
143 Qgis::AttributeTableFilterMode filterMode() const;
144
151 void setSelectedOnTop( bool selectedOnTop );
152
158 int featureCount();
159
166 int filteredFeatureCount();
167
175 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
176
183 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
184
188 QgsFeatureIds filteredFeatures() const;
189
195 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
196
202 void setRequest( const QgsFeatureRequest &request );
203
209 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
210
216 QgsAttributeTableView *tableView() { return mTableView; }
217
222 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
223
227 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
228
232 QString sortExpression() const;
233
238 QgsAttributeTableConfig attributeTableConfig() const;
239
245 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
246
247 public slots:
248
254 void setCurrentEditSelection( const QgsFeatureIds &fids );
255
262 bool saveEditChanges();
263
264 void openConditionalStyles();
265
269 void setMultiEditEnabled( bool enabled );
270
275 void toggleSearchMode( bool enabled );
276
280 void copyCellContent() const;
281
285 void cancelProgress();
286
295 void parentFormValueChanged( const QString &attribute, const QVariant &value );
296
297 signals:
298
303 void displayExpressionChanged( const QString &expression );
304
309
315 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
316
322
329
330 protected:
331 void hideEvent( QHideEvent *event ) override;
332
333 private slots:
334
335 void featureListAboutToChangeEditSelection( bool &ok );
336
342 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
343
344 void previewExpressionBuilder();
345
346 void previewColumnChanged( QAction *previewAction, const QString &expression );
347
348 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
349
350 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
351
352 void showViewHeaderMenu( QPoint point );
353
354 void organizeColumns();
355
356 void tableColumnResized( int column, int width );
357
358 void hideColumn();
359
360 void fieldCalculator();
361
362 void resizeColumn();
363
364 void resizeAllColumns();
365
366 void autosizeColumn();
367
368 void autosizeAllColumns();
369
370 void previewExpressionChanged( const QString &expression );
371
372 void onSortColumnChanged();
373
374 void updateSelectedFeatures();
375 void updateEditedAddedFeatures();
376
377 void extentChanged();
378
384 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
385
392 virtual void progress( int i, bool &cancel );
393
398 virtual void finished();
399
401 void zoomToCurrentFeature();
403 void panToCurrentFeature();
404
405 void flashCurrentFeature();
406
407 void rebuildFullLayerCache();
408
409 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
410
411 void flashButtonClicked( bool clicked );
412
413 void filterError( const QString &errorMessage );
414
415 private:
421 void initAttributeForm( const QgsFeature &feature );
422
426 void columnBoxInit();
427 void initLayerCache( bool cacheGeometry );
428 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
429 void restoreRecentDisplayExpressions();
430 void saveRecentDisplayExpressions() const;
431 void setDisplayExpression( const QString &expression );
432 void insertRecentlyUsedDisplayExpression( const QString &expression );
433 void updateEditSelectionProgress( int progress, int count );
434 void panOrZoomToFeature( const QgsFeatureIds &featureset );
436 void setBrowsingAutoPanScaleAllowed( bool allowed );
437
439 bool modifySort();
440
441 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
442 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
443
444 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
445 QgsAttributeEditorContext mEditorContext;
446 QgsAttributeTableModel *mMasterModel = nullptr;
447 QgsAttributeTableFilterModel *mFilterModel = nullptr;
448 QgsFeatureListModel *mFeatureListModel = nullptr;
449 QgsAttributeForm *mAttributeForm = nullptr;
450 QMenu *mPreviewColumnsMenu = nullptr;
451 QMenu *mPreviewActionMenu = nullptr;
452 QAction *mLastDisplayExpressionAction = nullptr;
453 QMenu *mHorizontalHeaderMenu = nullptr;
454 QgsVectorLayerCache *mLayerCache = nullptr;
455 QPointer<QgsVectorLayer> mLayer = nullptr;
456 QProgressDialog *mProgressDlg = nullptr;
457 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
458 QString mDisplayExpression;
460 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
461 QgsFeatureIds mLastFeatureSet;
462 bool mBrowsingAutoPanScaleAllowed = true;
463 ViewMode mPreviousView = AttributeTable;
464
465 bool mSkipDisplayExpressionChangedSignal = false;
466
467 friend class TestQgsDualView;
469};
470
476class GUI_EXPORT QgsAttributeTableAction : public QAction
477{
478 Q_OBJECT
479
480 public:
485 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
486 : QAction( name, dualView )
487 , mDualView( dualView )
488 , mAction( action )
489 , mFieldIdx( fieldIdx )
490 {}
491
492 public slots:
493 void execute();
494 void featureForm();
495
496 private:
497 QgsDualView *mDualView = nullptr;
498 QUuid mAction;
499 QModelIndex mFieldIdx;
500};
501
507class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
508{
509 Q_OBJECT
510
511 public:
512 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
513 : QAction( name, dualView )
514 , mDualView( dualView )
515 , mAction( action )
516 , mFieldIdx( fieldIdx )
517 {}
518
519 public slots:
520 void execute();
521
522 private:
523 QgsDualView *mDualView = nullptr;
524 QgsMapLayerAction *mAction = nullptr;
525 QModelIndex mFieldIdx;
526};
527
528Q_DECLARE_METATYPE( QModelIndex );
529
530#endif // QGSDUALVIEW_H
AttributeTableFilterMode
Defines how rows in attribute tables should be filtered.
Definition qgis.h:7277
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.
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:49
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:63
@ AttributeTable
Shows the features and attributes in a table layout.
Definition qgsdualview.h:68
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition qgsdualview.h:75
friend class TestQgsAttributeTable
void filterChanged()
Emitted whenever the filter changes.
static const QgsSettingsEntryBool * settingsFeatureListHighlightFeature
Definition qgsdualview.h:53
static const QgsSettingsEntryInteger * settingsAttributeTableRowCache
Definition qgsdualview.h:55
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:82
@ NoAction
No action is done.
Definition qgsdualview.h:83
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:84
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:85
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:60
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 boolean settings entry.
An integer settings entry.
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:52
#define SIP_SKIP
Definition qgis_sip.h:138
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:30