QGIS API Documentation
2.2.0-Valmiera
|
This widget is used to show the attributes of a set of features of a QgsVectorLayer. More...
#include <qgsdualview.h>
Public Types | |
enum | ViewMode { AttributeTable = 0, AttributeEditor = 1 } |
The view modes, in which this widget can present information. More... |
Public Slots | |
void | setCurrentEditSelection (const QgsFeatureIds &fids) |
Set the current edit selection in the AttributeEditor mode. | |
bool | saveEditChanges () |
saveEditChanges | |
void | reloadAttribute (const int &attribute) |
Update the shown feature if an attribute changed. |
Signals | |
void | displayExpressionChanged (const QString expression) |
Is emitted, whenever the display expression is successfully changed. | |
void | filterChanged () |
Is emitted, whenever the filter changes. |
Public Member Functions | |
QgsDualView (QWidget *parent=0) | |
Constructor. | |
virtual | ~QgsDualView () |
void | init (QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), QgsAttributeEditorContext context=QgsAttributeEditorContext()) |
Has to be called to initialize the dual view. | |
void | setView (ViewMode view) |
Change the current view mode. | |
void | setFilterMode (QgsAttributeTableFilterModel::FilterMode filterMode) |
Set the filter mode. | |
void | setSelectedOnTop (bool selectedOnTop) |
Toggle the selectedOnTop flag. | |
int | featureCount () |
Returns the number of features on the layer. | |
int | filteredFeatureCount () |
Returns the number of features which are currently visible, according to the filter restrictions. | |
void | setFilteredFeatures (QgsFeatureIds filteredFeatures) |
Set a list of currently visible features. | |
QgsAttributeTableModel * | masterModel () const |
Returns the model which has the information about all features (not only filtered) | |
void | setRequest (const QgsFeatureRequest &request) |
void | setFeatureSelectionManager (QgsIFeatureSelectionManager *featureSelectionManager) |
Protected Member Functions | |
void | columnBoxInit () |
Initializes widgets which depend on the attributes of this layer. | |
virtual void | hideEvent (QHideEvent *) |
virtual void | focusOutEvent (QFocusEvent *) |
Private Slots | |
void | on_mFeatureList_currentEditSelectionChanged (const QgsFeature &feat) |
Changes the currently visible feature within the attribute editor. | |
void | previewExpressionBuilder () |
void | previewColumnChanged (QObject *previewAction) |
void | editingToggled () |
void | viewWillShowContextMenu (QMenu *menu, QModelIndex atIndex) |
void | previewExpressionChanged (const QString expression) |
void | attributeDeleted (int attribute) |
If an attribute on this layer is deleted, remove the field also for open attribute dialogs. | |
void | attributeAdded (int attribute) |
If an attribute on this layer is added, add the field also for open attribute dialogs. | |
void | featureDeleted (QgsFeatureId fid) |
Gets called when a feature is deleted. | |
virtual void | progress (int i, bool &cancel) |
Will be called periodically, when loading layers from slow data providers. | |
virtual void | finished () |
Will be called, once all the features are loaded. |
Private Member Functions | |
void | initLayerCache (QgsVectorLayer *layer) |
void | initModels (QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request) |
Private Attributes | |
QgsAttributeEditorContext | mEditorContext |
QgsAttributeTableModel * | mMasterModel |
QgsAttributeTableFilterModel * | mFilterModel |
QgsFeatureListModel * | mFeatureListModel |
QgsAttributeDialog * | mAttributeDialog |
QgsCachedFeatureIterator * | mFeatureCache |
QSignalMapper * | mPreviewActionMapper |
QMenu * | mPreviewColumnsMenu |
QgsVectorLayerCache * | mLayerCache |
QProgressDialog * | mProgressDlg |
QgsIFeatureSelectionManager * | mFeatureSelectionManager |
QgsDistanceArea | mDistanceArea |
Friends | |
class | TestQgsDualView |
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
The attributes can be edited. It supports two different layouts: the table layout, in which the attributes for the features are shown in a table and the editor layout, where the features are shown as a selectable list and the attributes for the currently selected feature are shown in a form.
Definition at line 42 of file qgsdualview.h.
The view modes, in which this widget can present information.
Relates to the QStackedWidget stacks.
Definition at line 53 of file qgsdualview.h.
|
explicit |
Constructor.
parent | The parent widget |
Definition at line 36 of file qgsdualview.cpp.
References displayExpressionChanged(), QgsApplication::getThemeIcon(), mPreviewActionMapper, mPreviewColumnsMenu, previewColumnChanged(), previewExpressionBuilder(), previewExpressionChanged(), and saveEditChanges().
|
virtual |
Definition at line 62 of file qgsdualview.cpp.
References mAttributeDialog.
|
privateslot |
If an attribute on this layer is added, add the field also for open attribute dialogs.
(as long as the attribute dialog is not able to handle this problem)
attribute | The attribute being added |
Definition at line 496 of file qgsdualview.cpp.
References QgsAttributeDialog::accept(), QgsFeature::attribute(), QgsFeature::attributes(), QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsVectorLayerCache::featureAtId(), QgsFeature::id(), QgsVectorLayerCache::layer(), mAttributeDialog, mLayerCache, and QgsFeature::setAttribute().
Referenced by initLayerCache().
|
privateslot |
If an attribute on this layer is deleted, remove the field also for open attribute dialogs.
(as long as the attribute dialog is not able to handle this problem)
attribute | The attribute being deleted |
Definition at line 474 of file qgsdualview.cpp.
References QgsAttributeDialog::accept(), QgsFeature::deleteAttribute(), QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsVectorLayerCache::layer(), mAttributeDialog, and mLayerCache.
Referenced by initLayerCache().
|
protected |
Initializes widgets which depend on the attributes of this layer.
Definition at line 86 of file qgsdualview.cpp.
References QgsVectorLayer::displayExpression(), QgsVectorLayer::displayField(), QgsVectorLayer::editType(), QgsVectorLayer::fieldNameIndex(), QgsApplication::getThemeIcon(), QgsVectorLayer::Hidden, icon(), QgsVectorLayerCache::layer(), mLayerCache, mPreviewActionMapper, mPreviewColumnsMenu, QgsField::name(), QgsVectorLayer::pendingFields(), QgsVectorLayer::pendingPkAttributesList(), and QgsFields::toList().
Referenced by init().
|
signal |
Is emitted, whenever the display expression is successfully changed.
expression | The expression that was applied |
Referenced by initModels(), and QgsDualView().
|
privateslot |
Definition at line 407 of file qgsdualview.cpp.
References QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), mAttributeDialog, and on_mFeatureList_currentEditSelectionChanged().
Referenced by initLayerCache().
int QgsDualView::featureCount | ( | ) |
Returns the number of features on the layer.
Definition at line 416 of file qgsdualview.cpp.
References mMasterModel, and QgsAttributeTableModel::rowCount().
|
privateslot |
Gets called when a feature is deleted.
So it can be removed from the feature form if required.
fid | The feature being deleted |
Definition at line 536 of file qgsdualview.cpp.
References QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsFeature::id(), and mAttributeDialog.
Referenced by initLayerCache().
|
signal |
Is emitted, whenever the filter changes.
int QgsDualView::filteredFeatureCount | ( | ) |
Returns the number of features which are currently visible, according to the filter restrictions.
Definition at line 421 of file qgsdualview.cpp.
References mFilterModel.
|
privatevirtualslot |
Will be called, once all the features are loaded.
Use e.g. to close a dialog created from progress(int i,bool& cancel )
Definition at line 619 of file qgsdualview.cpp.
References mProgressDlg.
Referenced by initLayerCache(), and initModels().
|
protectedvirtual |
Definition at line 199 of file qgsdualview.cpp.
References saveEditChanges().
|
protectedvirtual |
Definition at line 193 of file qgsdualview.cpp.
References saveEditChanges().
void QgsDualView::init | ( | QgsVectorLayer * | layer, |
QgsMapCanvas * | mapCanvas, | ||
const QgsFeatureRequest & | request = QgsFeatureRequest() , |
||
QgsAttributeEditorContext | context = QgsAttributeEditorContext() |
||
) |
Has to be called to initialize the dual view.
layer | The layer which should be used to fetch features |
mapCanvas | The mapCanvas (used for the FilterMode QgsAttributeTableFilterModel::ShowVisible |
request | Use a modified request to limit the shown features |
context | The context in which this view is shown |
Definition at line 67 of file qgsdualview.cpp.
References columnBoxInit(), QgsAttributeDialog::dialog(), initLayerCache(), initModels(), mAttributeDialog, mEditorContext, mFeatureListModel, mFilterModel, and viewWillShowContextMenu().
Referenced by QgsRelationEditorWidget::createRelationEditor().
|
private |
Definition at line 220 of file qgsdualview.cpp.
References attributeAdded(), attributeDeleted(), editingToggled(), featureDeleted(), finished(), mLayerCache, progress(), and QgsVectorDataProvider::SelectAtId.
Referenced by init().
|
private |
Definition at line 243 of file qgsdualview.cpp.
References displayExpressionChanged(), finished(), QgsAttributeTableModel::loadLayer(), mFeatureListModel, mFilterModel, mLayerCache, mMasterModel, progress(), and QgsAttributeTableModel::setRequest().
Referenced by init().
|
inline |
Returns the model which has the information about all features (not only filtered)
Definition at line 135 of file qgsdualview.h.
Referenced by QgsAttributeTableAction::execute(), QgsAttributeTableMapLayerAction::execute(), QgsAttributeTableAction::featureForm(), QgsRelationEditorWidget::on_mAddFeatureButton_clicked(), and QgsRelationEditorWidget::onCollapsedStateChanged().
|
privateslot |
Changes the currently visible feature within the attribute editor.
feat | The newly visible feature |
Definition at line 260 of file qgsdualview.cpp.
References QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsFeature::id(), QgsFeature::isValid(), QgsVectorLayerCache::layer(), mAttributeDialog, mEditorContext, mLayerCache, saveEditChanges(), and setCurrentEditSelection().
Referenced by editingToggled().
|
privateslot |
|
privateslot |
Definition at line 367 of file qgsdualview.cpp.
References QgsVectorLayer::displayExpression(), QgsVectorLayerCache::layer(), mLayerCache, QgsExpressionBuilderDialog::setExpressionText(), and tr.
Referenced by QgsDualView().
|
privateslot |
Definition at line 469 of file qgsdualview.cpp.
References QgsVectorLayerCache::layer(), mLayerCache, and QgsVectorLayer::setDisplayExpression().
Referenced by QgsDualView().
|
privatevirtualslot |
Will be called periodically, when loading layers from slow data providers.
i | The number of features already loaded |
cancel | Set to true to cancel |
Definition at line 601 of file qgsdualview.cpp.
References mProgressDlg, and tr.
Referenced by initLayerCache(), and initModels().
|
slot |
Update the shown feature if an attribute changed.
Definition at line 552 of file qgsdualview.cpp.
References QgsAttributeDialog::accept(), QgsFeature::attribute(), QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsVectorLayerCache::featureAtId(), QgsFeature::id(), QgsVectorLayerCache::layer(), mAttributeDialog, mLayerCache, and QgsFeature::setAttribute().
|
slot |
saveEditChanges
Definition at line 303 of file qgsdualview.cpp.
References QgsAttributeDialog::accept(), QgsFeature::attributes(), QgsVectorLayer::beginEditCommand(), QgsVectorLayer::changeAttributeValue(), QgsAttributeDialog::dialog(), QgsAttributeDialog::editable(), QgsVectorLayer::endEditCommand(), QgsAttributeDialog::feature(), QgsVectorLayerCache::featureAtId(), QgsFeature::id(), QgsVectorLayerCache::layer(), mAttributeDialog, mLayerCache, and tr.
Referenced by focusOutEvent(), hideEvent(), on_mFeatureList_currentEditSelectionChanged(), and QgsDualView().
|
slot |
Set the current edit selection in the AttributeEditor mode.
fids | A list of edited features (Currently only one at a time is supported) |
Definition at line 298 of file qgsdualview.cpp.
Referenced by QgsAttributeTableAction::featureForm(), and on_mFeatureList_currentEditSelectionChanged().
void QgsDualView::setFeatureSelectionManager | ( | QgsIFeatureSelectionManager * | featureSelectionManager | ) |
Definition at line 590 of file qgsdualview.cpp.
References mFeatureSelectionManager.
Referenced by QgsRelationEditorWidget::createRelationEditor().
void QgsDualView::setFilteredFeatures | ( | QgsFeatureIds | filteredFeatures | ) |
Set a list of currently visible features.
filteredFeatures | A list of feature ids |
Definition at line 580 of file qgsdualview.cpp.
References mFilterModel, and QgsAttributeTableFilterModel::setFilteredFeatures().
void QgsDualView::setFilterMode | ( | QgsAttributeTableFilterModel::FilterMode | filterMode | ) |
Set the filter mode.
filterMode |
Definition at line 210 of file qgsdualview.cpp.
References mFilterModel, and QgsAttributeTableFilterModel::setFilterMode().
void QgsDualView::setRequest | ( | const QgsFeatureRequest & | request | ) |
Definition at line 585 of file qgsdualview.cpp.
References mMasterModel, and QgsAttributeTableModel::setRequest().
void QgsDualView::setSelectedOnTop | ( | bool | selectedOnTop | ) |
Toggle the selectedOnTop flag.
If enabled, selected features will be moved to top.
selectedOnTop | True: Show selected features on top. False: Use defined sorting column. |
Definition at line 215 of file qgsdualview.cpp.
References mFilterModel, and QgsAttributeTableFilterModel::setSelectedOnTop().
void QgsDualView::setView | ( | QgsDualView::ViewMode | view | ) |
Change the current view mode.
view | The view mode to set |
Definition at line 205 of file qgsdualview.cpp.
Referenced by QgsAttributeTableAction::featureForm().
|
privateslot |
Definition at line 426 of file qgsdualview.cpp.
References QgsVectorLayer::actions(), QgsAttributeAction::at(), QgsMapLayerActionRegistry::instance(), QgsVectorLayerCache::layer(), QgsMapLayerActionRegistry::mapLayerActions(), mFilterModel, mLayerCache, QgsAction::name(), QgsAction::runable(), QgsAttributeAction::size(), and tr.
Referenced by init().
|
friend |
Definition at line 259 of file qgsdualview.h.
|
private |
Definition at line 250 of file qgsdualview.h.
Referenced by attributeAdded(), attributeDeleted(), editingToggled(), featureDeleted(), init(), on_mFeatureList_currentEditSelectionChanged(), reloadAttribute(), saveEditChanges(), and ~QgsDualView().
|
private |
Definition at line 257 of file qgsdualview.h.
|
private |
Definition at line 246 of file qgsdualview.h.
Referenced by init(), and on_mFeatureList_currentEditSelectionChanged().
|
private |
Definition at line 251 of file qgsdualview.h.
|
private |
Definition at line 249 of file qgsdualview.h.
Referenced by init(), and initModels().
|
private |
Definition at line 256 of file qgsdualview.h.
Referenced by setFeatureSelectionManager().
|
private |
Definition at line 248 of file qgsdualview.h.
Referenced by filteredFeatureCount(), init(), initModels(), setFilteredFeatures(), setFilterMode(), setSelectedOnTop(), and viewWillShowContextMenu().
|
private |
Definition at line 254 of file qgsdualview.h.
Referenced by attributeAdded(), attributeDeleted(), columnBoxInit(), initLayerCache(), initModels(), on_mFeatureList_currentEditSelectionChanged(), previewExpressionBuilder(), previewExpressionChanged(), reloadAttribute(), saveEditChanges(), and viewWillShowContextMenu().
|
private |
Definition at line 247 of file qgsdualview.h.
Referenced by featureCount(), initModels(), and setRequest().
|
private |
Definition at line 252 of file qgsdualview.h.
Referenced by columnBoxInit(), and QgsDualView().
|
private |
Definition at line 253 of file qgsdualview.h.
Referenced by columnBoxInit(), and QgsDualView().
|
private |
Definition at line 255 of file qgsdualview.h.
Referenced by finished(), and progress().