QGIS API Documentation 4.1.0-Master (31622b25bb0)
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;
37
48class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
49{
50 Q_OBJECT
51
52 public:
53
55
57
64 {
65
70
77 };
78 Q_ENUM( ViewMode )
79
80
81
88 Q_ENUM( FeatureListBrowsingAction )
89
90
94 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
95 ~QgsDualView() override;
96
109 void init(
110 QgsVectorLayer *layer,
111 QgsMapCanvas *mapCanvas,
112 const QgsFeatureRequest &request = QgsFeatureRequest(),
114 bool loadFeatures = true,
115 bool showFirstFeature = true
116 );
117
124 void setView( ViewMode view );
125
130 ViewMode view() const;
131
137 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
138
144 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
145
152 void setSelectedOnTop( bool selectedOnTop );
153
159 int featureCount();
160
167 int filteredFeatureCount();
168
176 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
177
184 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
185
189 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
190
196 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
197
203 void setRequest( const QgsFeatureRequest &request );
204
210 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
211
217 QgsAttributeTableView *tableView() { return mTableView; }
218
223 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
224
228 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
229
233 QString sortExpression() const;
234
239 QgsAttributeTableConfig attributeTableConfig() const;
240
246 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
247
248 public slots:
249
255 void setCurrentEditSelection( const QgsFeatureIds &fids );
256
263 bool saveEditChanges();
264
265 void openConditionalStyles();
266
270 void setMultiEditEnabled( bool enabled );
271
276 void toggleSearchMode( bool enabled );
277
281 void copyCellContent() const;
282
286 void cancelProgress();
287
296 void parentFormValueChanged( const QString &attribute, const QVariant &value );
297
298 signals:
299
304 void displayExpressionChanged( const QString &expression );
305
310
316 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
317
323
330
331 protected:
332 void hideEvent( QHideEvent *event ) override;
333
334 private slots:
335
336 void featureListAboutToChangeEditSelection( bool &ok );
337
343 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
344
345 void previewExpressionBuilder();
346
347 void previewColumnChanged( QAction *previewAction, const QString &expression );
348
349 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
350
351 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
352
353 void showViewHeaderMenu( QPoint point );
354
355 void organizeColumns();
356
357 void tableColumnResized( int column, int width );
358
359 void hideColumn();
360
361 void fieldCalculator();
362
363 void resizeColumn();
364
365 void resizeAllColumns();
366
367 void autosizeColumn();
368
369 void autosizeAllColumns();
370
371 void previewExpressionChanged( const QString &expression );
372
373 void onSortColumnChanged();
374
375 void updateSelectedFeatures();
376 void updateEditedAddedFeatures();
377
378 void extentChanged();
379
385 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
386
393 virtual void progress( int i, bool &cancel );
394
399 virtual void finished();
400
402 void zoomToCurrentFeature();
404 void panToCurrentFeature();
405
406 void flashCurrentFeature();
407
408 void rebuildFullLayerCache();
409
410 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
411
412 void flashButtonClicked( bool clicked );
413
414 void filterError( const QString &errorMessage );
415
416 private:
422 void initAttributeForm( const QgsFeature &feature );
423
427 void columnBoxInit();
428 void initLayerCache( bool cacheGeometry );
429 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
430 void restoreRecentDisplayExpressions();
431 void saveRecentDisplayExpressions() const;
432 void setDisplayExpression( const QString &expression );
433 void insertRecentlyUsedDisplayExpression( const QString &expression );
434 void updateEditSelectionProgress( int progress, int count );
435 void panOrZoomToFeature( const QgsFeatureIds &featureset );
437 void setBrowsingAutoPanScaleAllowed( bool allowed );
438
440 bool modifySort();
441
442 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
443 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
444
445 QgsFieldConditionalFormatWidget *mConditionalFormatWidget = nullptr;
446 QgsAttributeEditorContext mEditorContext;
447 QgsAttributeTableModel *mMasterModel = nullptr;
448 QgsAttributeTableFilterModel *mFilterModel = nullptr;
449 QgsFeatureListModel *mFeatureListModel = nullptr;
450 QgsAttributeForm *mAttributeForm = nullptr;
451 QMenu *mPreviewColumnsMenu = nullptr;
452 QMenu *mPreviewActionMenu = nullptr;
453 QAction *mLastDisplayExpressionAction = nullptr;
454 QMenu *mHorizontalHeaderMenu = nullptr;
455 QgsVectorLayerCache *mLayerCache = nullptr;
456 QPointer<QgsVectorLayer> mLayer = nullptr;
457 QProgressDialog *mProgressDlg = nullptr;
458 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
459 QString mDisplayExpression;
461 QgsScrollArea *mAttributeEditorScrollArea = nullptr;
462 QgsFeatureIds mLastFeatureSet;
463 bool mBrowsingAutoPanScaleAllowed = true;
464 ViewMode mPreviousView = AttributeTable;
465
466 friend class TestQgsDualView;
468};
469
475class GUI_EXPORT QgsAttributeTableAction : public QAction
476{
477 Q_OBJECT
478
479 public:
484 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
485 : QAction( name, dualView )
486 , mDualView( dualView )
487 , mAction( action )
488 , mFieldIdx( fieldIdx )
489 {}
490
491 public slots:
492 void execute();
493 void featureForm();
494
495 private:
496 QgsDualView *mDualView = nullptr;
497 QUuid mAction;
498 QModelIndex mFieldIdx;
499};
500
506class GUI_EXPORT QgsAttributeTableMapLayerAction : public QAction
507{
508 Q_OBJECT
509
510 public:
511 QgsAttributeTableMapLayerAction( const QString &name, QgsDualView *dualView, QgsMapLayerAction *action, const QModelIndex &fieldIdx )
512 : QAction( name, dualView )
513 , mDualView( dualView )
514 , mAction( action )
515 , mFieldIdx( fieldIdx )
516 {}
517
518 public slots:
519 void execute();
520
521 private:
522 QgsDualView *mDualView = nullptr;
523 QgsMapLayerAction *mAction = nullptr;
524 QModelIndex mFieldIdx;
525};
526
527Q_DECLARE_METATYPE( QModelIndex );
528
529#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: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:64
@ AttributeTable
Shows the features and attributes in a table layout.
Definition qgsdualview.h:69
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition qgsdualview.h:76
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
Definition qgsdualview.h:54
static const QgsSettingsEntryInteger * settingsAttributeTableRowCache
Definition qgsdualview.h:56
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:83
@ NoAction
No action is done.
Definition qgsdualview.h:84
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:85
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:86
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:133
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