QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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;
35
46class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBase
47{
48 Q_OBJECT
49
50 public:
57 {
58
63
70 };
71 Q_ENUM( ViewMode )
72
73
74
81 Q_ENUM( FeatureListBrowsingAction )
82
83
87 explicit QgsDualView( QWidget *parent SIP_TRANSFERTHIS = nullptr );
88 ~QgsDualView() override;
89
102 void init(
103 QgsVectorLayer *layer,
104 QgsMapCanvas *mapCanvas,
105 const QgsFeatureRequest &request = QgsFeatureRequest(),
107 bool loadFeatures = true,
108 bool showFirstFeature = true
109 );
110
117 void setView( ViewMode view );
118
123 ViewMode view() const;
124
130 void setFilterMode( QgsAttributeTableFilterModel::FilterMode filterMode );
131
137 QgsAttributeTableFilterModel::FilterMode filterMode() { return mFilterModel->filterMode(); }
138
145 void setSelectedOnTop( bool selectedOnTop );
146
152 int featureCount();
153
160 int filteredFeatureCount();
161
169 Q_DECL_DEPRECATED void setFilteredFeatures( const QgsFeatureIds &filteredFeatures );
170
177 void filterFeatures( const QgsExpression &filterExpression, const QgsExpressionContext &context );
178
182 QgsFeatureIds filteredFeatures() { return mFilterModel->filteredFeatures(); }
183
189 QgsAttributeTableModel *masterModel() const { return mMasterModel; }
190
196 void setRequest( const QgsFeatureRequest &request );
197
203 void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
204
210 QgsAttributeTableView *tableView() { return mTableView; }
211
216 void setAttributeTableConfig( const QgsAttributeTableConfig &config );
217
221 void setSortExpression( const QString &sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder );
222
226 QString sortExpression() const;
227
232 QgsAttributeTableConfig attributeTableConfig() const;
233
239 static QgsAttributeList requiredAttributes( const QgsVectorLayer *layer );
240
241 public slots:
242
248 void setCurrentEditSelection( const QgsFeatureIds &fids );
249
256 bool saveEditChanges();
257
258 void openConditionalStyles();
259
263 void setMultiEditEnabled( bool enabled );
264
269 void toggleSearchMode( bool enabled );
270
274 void copyCellContent() const;
275
279 void cancelProgress();
280
289 void parentFormValueChanged( const QString &attribute, const QVariant &value );
290
291 signals:
292
297 void displayExpressionChanged( const QString &expression );
298
303
309 void filterExpressionSet( const QString &expression, QgsAttributeForm::FilterType type );
310
316
323
324 protected:
325 void hideEvent( QHideEvent *event ) override;
326
327 private slots:
328
329 void featureListAboutToChangeEditSelection( bool &ok );
330
336 void featureListCurrentEditSelectionChanged( const QgsFeature &feat );
337
338 void previewExpressionBuilder();
339
340 void previewColumnChanged( QAction *previewAction, const QString &expression );
341
342 void viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex );
343
344 void widgetWillShowContextMenu( QgsActionMenu *menu, const QModelIndex &atIndex );
345
346 void showViewHeaderMenu( QPoint point );
347
348 void organizeColumns();
349
350 void tableColumnResized( int column, int width );
351
352 void hideColumn();
353
354 void resizeColumn();
355
356 void resizeAllColumns();
357
358 void autosizeColumn();
359
360 void autosizeAllColumns();
361
362 void previewExpressionChanged( const QString &expression );
363
364 void onSortColumnChanged();
365
366 void updateSelectedFeatures();
367 void updateEditedAddedFeatures();
368
369 void extentChanged();
370
376 void featureFormAttributeChanged( const QString &attribute, const QVariant &value, bool attributeChanged );
377
384 virtual void progress( int i, bool &cancel );
385
390 virtual void finished();
391
393 void zoomToCurrentFeature();
395 void panToCurrentFeature();
396
397 void flashCurrentFeature();
398
399 void rebuildFullLayerCache();
400
401 void panZoomGroupButtonToggled( QAbstractButton *button, bool checked );
402
403 void flashButtonClicked( bool clicked );
404
405 void filterError( const QString &errorMessage );
406
407 private:
413 void initAttributeForm( const QgsFeature &feature );
414
418 void columnBoxInit();
419 void initLayerCache( bool cacheGeometry );
420 void initModels( QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, bool loadFeatures );
421 void restoreRecentDisplayExpressions();
422 void saveRecentDisplayExpressions() const;
423 void setDisplayExpression( const QString &expression );
424 void insertRecentlyUsedDisplayExpression( const QString &expression );
425 void updateEditSelectionProgress( int progress, int count );
426 void panOrZoomToFeature( const QgsFeatureIds &featureset );
428 void setBrowsingAutoPanScaleAllowed( bool allowed );
429
431 bool modifySort();
432
433 static const std::unique_ptr<QgsSettingsEntryVariant> conditionalFormattingSplitterState;
434 static const std::unique_ptr<QgsSettingsEntryVariant> attributeEditorSplitterState;
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;
459};
460
466class GUI_EXPORT QgsAttributeTableAction : public QAction
467{
468 Q_OBJECT
469
470 public:
475 QgsAttributeTableAction( const QString &name, QgsDualView *dualView, QUuid action, const QModelIndex &fieldIdx )
476 : QAction( name, dualView )
477 , mDualView( dualView )
478 , mAction( action )
479 , mFieldIdx( fieldIdx )
480 {}
481
482 public slots:
483 void execute();
484 void featureForm();
485
486 private:
487 QgsDualView *mDualView = nullptr;
488 QUuid mAction;
489 QModelIndex mFieldIdx;
490};
491
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
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:47
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:57
@ AttributeTable
Shows the features and attributes in a table layout.
Definition qgsdualview.h:62
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition qgsdualview.h:69
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.
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:76
@ NoAction
No action is done.
Definition qgsdualview.h:77
@ PanToFeature
The map is panned to the center of the feature bounding-box.
Definition qgsdualview.h:78
@ ZoomToFeature
The map is zoomed to contained the feature bounding-box.
Definition qgsdualview.h:79
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 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