QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
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;
36
47class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
48{
49 Q_OBJECT
50
51 public:
58 {
59
64
71 };
72 Q_ENUM( ViewMode )
73
74
75
82 Q_ENUM( FeatureListBrowsingAction )
83
84#ifndef SIP_RUN
85
91
92#endif
93
98 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
99 ~QgsDualView() override;
100
113 void init(
114 QgsVectorLayer *layer,
115 QgsMapCanvas *mapCanvas,
116 const QgsFeatureRequest &request = QgsFeatureRequest(),
118 bool loadFeatures = true,
119 bool showFirstFeature = true
120 );
121
128 void setView( ViewMode view );
129
134 ViewMode view() const;
135
142
148 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
149
156 void setSelectedOnTop( bool selectedOnTop );
157
163 int featureCount();
164
171 int filteredFeatureCount();
172
180 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
181
188 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
189
193 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
194
200 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
201
207 void setRequest( const QgsFeatureRequest &request );
208
214 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
215
221 QgsAttributeTableView *tableView() { return mTableView; }
222
227 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
228
232 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
233
237 QString sortExpression() const;
238
243 QgsAttributeTableConfig attributeTableConfig() const;
244
250 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
251
252 public slots:
253
259 void setCurrentEditSelection( const QgsFeatureIds &fids );
260
267 bool saveEditChanges();
268
269 void openConditionalStyles();
270
274 void setMultiEditEnabled( bool enabled );
275
280 void toggleSearchMode( bool enabled );
281
285 void copyCellContent() const;
286
290 void cancelProgress();
291
300 void parentFormValueChanged( const QString &attribute, const QVariant &value );
301
302 signals:
303
308 void displayExpressionChanged( const QString &expression );
309
314
320 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
321
327
334
335 protected:
336 void hideEvent( QHideEvent *event ) override;
337
338 private slots:
339
340 void featureListAboutToChangeEditSelection( bool &ok );
341
347 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
348
349 void previewExpressionBuilder();
350
351 void previewColumnChanged( QAction *previewAction, const QString &expression );
352
353 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
354
355 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
356
357 void showViewHeaderMenu( QPoint point );
358
359 void organizeColumns();
360
361 void tableColumnResized( int column, int width );
362
363 void hideColumn();
364
365 void fieldCalculator();
366
367 void resizeColumn();
368
369 void resizeAllColumns();
370
371 void autosizeColumn();
372
373 void autosizeAllColumns();
374
375 void previewExpressionChanged( const QString &expression );
376
377 void onSortColumnChanged();
378
379 void updateSelectedFeatures();
380 void updateEditedAddedFeatures();
381
382 void extentChanged();
383
389 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
390
397 virtual void progress( int i, bool &cancel );
398
403 virtual void finished();
404
406 void zoomToCurrentFeature();
408 void panToCurrentFeature();
409
410 void flashCurrentFeature();
411
412 void rebuildFullLayerCache();
413
414 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
415
416 void flashButtonClicked( bool clicked );
417
418 void filterError( const QString &errorMessage );
419
420 private:
426 void initAttributeForm( const QgsFeature &feature );
427
431 void columnBoxInit();
432 void initLayerCache( bool cacheGeometry );
433 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
434 void restoreRecentDisplayExpressions();
435 void saveRecentDisplayExpressions() const;
436 void setDisplayExpression( const QString &expression );
437 void insertRecentlyUsedDisplayExpression( const QString &expression );
438 void updateEditSelectionProgress( int progress, int count );
439 void panOrZoomToFeature( const QgsFeatureIds &featureset );
441 void setBrowsingAutoPanScaleAllowed( bool allowed );
442
444 bool modifySort();
445
446 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
447 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
448
449 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
450 QgsAttributeEditorContext mEditorContext;
451 QgsAttributeTableModel *mMasterModel = nullptr;
452 QgsAttributeTableFilterModel *mFilterModel = nullptr;
453 QgsFeatureListModel *mFeatureListModel = nullptr;
454 QgsAttributeForm *mAttributeForm = nullptr;
455 QMenu *mPreviewColumnsMenu = nullptr;
456 QMenu *mPreviewActionMenu = nullptr;
457 QAction *mLastDisplayExpressionAction = nullptr;
458 QMenu *mHorizontalHeaderMenu = nullptr;
459 QgsVectorLayerCache *mLayerCache = nullptr;
460 QPointer<QgsVectorLayer> mLayer = nullptr;
461 QProgressDialog *mProgressDlg = nullptr;
462 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
463 QString mDisplayExpression;
465 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
466 QgsFeatureIds mLastFeatureSet;
467 bool mBrowsingAutoPanScaleAllowed = true;
468 ViewMode mPreviousView = AttributeTable;
469
470 friend class TestQgsDualView;
472};
473
479class GUI_EXPORT QgsAttributeTableAction : public QAction
480{
481 Q_OBJECT
482
483 public:
488 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid 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 void featureForm();
498
499 private:
500 QgsDualView *mDualView = nullptr;
501 QUuid mAction;
502 QModelIndex mFieldIdx;
503};
504
510class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
511{
512 Q_OBJECT
513
514 public:
515 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
516 : QAction( name, dualView )
517 , mDualView( dualView )
518 , mAction( action )
519 , mFieldIdx( fieldIdx )
520 {}
521
522 public slots:
523 void execute();
524
525 private:
526 QgsDualView *mDualView = nullptr;
527 QgsMapLayerAction *mAction = nullptr;
528 QModelIndex mFieldIdx;
529};
530
531Q_DECLARE_METATYPE( QModelIndex );
532
533#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:48
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:58
@ AttributeTable
Shows the features and attributes in a table layout.
Definition qgsdualview.h:63
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition qgsdualview.h:70
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.
static const QgsSettingsEntryBool * settingsFeatureListHighlightFeature
Settings entry for whether features are highlighted/flashed in the feature list.
Definition qgsdualview.h:90
QgsDualView(QWidget *parent=nullptr)
Constructor.
ViewMode view() const
Returns the current view mode.
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:77
@ NoAction
No action is done.
Definition qgsdualview.h:78
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:79
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:80
void hideEvent(QHideEvent *event) override
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Emitted when a filter expression is set using the view.
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), bool loadFeatures=true, bool showFirstFeature=true)
Has to be called to initialize the dual 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).
void setFilterMode(QgsAttributeTableFilterModel::FilterMode filterMode)
Set the filter mode.
void setView(ViewMode view)
Change the current view mode.
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.
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
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