QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | Friends | List of all members
QgsDualView Class Reference

This widget is used to show the attributes of a set of features of a QgsVectorLayer. More...

#include <qgsdualview.h>

Collaboration diagram for QgsDualView:
Collaboration graph
[legend]

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.
void 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, QgsDistanceArea myDa)
 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.
QgsAttributeTableModelmasterModel () const
 Returns the model which has the information about all features (not only filtered)

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)

Private Attributes

QgsAttributeTableModelmMasterModel
QgsAttributeTableFilterModelmFilterModel
QgsFeatureListModelmFeatureListModel
QgsAttributeDialogmAttributeDialog
QgsCachedFeatureIteratormFeatureCache
QSignalMapper * mPreviewActionMapper
QMenu * mPreviewColumnsMenu
QgsVectorLayerCachemLayerCache
QProgressDialog * mProgressDlg
QgsDistanceArea mDistanceArea

Friends

class TestQgsDualView

Detailed Description

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.

Note
Added in 2.0

Definition at line 39 of file qgsdualview.h.

Member Enumeration Documentation

The view modes, in which this widget can present information.

Relates to the QStackedWidget stacks.

Enumerator:
AttributeTable 

Shows the features and attributes in a table layout.

AttributeEditor 

Show a list of the features, where one can be chosen and the according attribute dialog will be presented in the neighbouring frame.

Definition at line 50 of file qgsdualview.h.

Constructor & Destructor Documentation

QgsDualView::QgsDualView ( QWidget *  parent = 0)
explicit
QgsDualView::~QgsDualView ( )
virtual

Definition at line 55 of file qgsdualview.cpp.

References mAttributeDialog.

Member Function Documentation

void QgsDualView::attributeAdded ( int  attribute)
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)

Parameters
attributeThe attribute being added

Definition at line 428 of file qgsdualview.cpp.

References QgsAttributeDialog::accept(), QgsFeature::attribute(), QgsFeature::attributes(), QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsVectorLayerCache::featureAtId(), QgsFeature::id(), QgsVectorLayerCache::layer(), mAttributeDialog, mDistanceArea, mLayerCache, and QgsFeature::setAttribute().

Referenced by initLayerCache().

void QgsDualView::attributeDeleted ( int  attribute)
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)

Parameters
attributeThe attribute being deleted

Definition at line 406 of file qgsdualview.cpp.

References QgsAttributeDialog::accept(), QgsFeature::deleteAttribute(), QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsVectorLayerCache::layer(), mAttributeDialog, mDistanceArea, and mLayerCache.

Referenced by initLayerCache().

void QgsDualView::columnBoxInit ( )
protected
void QgsDualView::displayExpressionChanged ( const QString  expression)
signal

Is emitted, whenever the display expression is successfully changed.

Parameters
expressionThe expression that was applied

Referenced by initModels(), and QgsDualView().

void QgsDualView::editingToggled ( )
privateslot
int QgsDualView::featureCount ( )

Returns the number of features on the layer.

Returns
Number of features

Definition at line 365 of file qgsdualview.cpp.

References mMasterModel, and QgsAttributeTableModel::rowCount().

void QgsDualView::featureDeleted ( QgsFeatureId  fid)
privateslot

Gets called when a feature is deleted.

So it can be removed from the feature form if required.

Parameters
fidThe feature being deleted

Definition at line 468 of file qgsdualview.cpp.

References QgsAttributeDialog::dialog(), QgsAttributeDialog::feature(), QgsFeature::id(), and mAttributeDialog.

Referenced by initLayerCache().

void QgsDualView::filterChanged ( )
signal

Is emitted, whenever the filter changes.

int QgsDualView::filteredFeatureCount ( )

Returns the number of features which are currently visible, according to the filter restrictions.

Returns
Number of features

Definition at line 370 of file qgsdualview.cpp.

References mFilterModel.

void QgsDualView::finished ( )
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 535 of file qgsdualview.cpp.

References mProgressDlg.

Referenced by initLayerCache(), and initModels().

void QgsDualView::focusOutEvent ( QFocusEvent *  event)
protectedvirtual

Definition at line 192 of file qgsdualview.cpp.

References saveEditChanges().

void QgsDualView::hideEvent ( QHideEvent *  event)
protectedvirtual

Definition at line 186 of file qgsdualview.cpp.

References saveEditChanges().

void QgsDualView::init ( QgsVectorLayer layer,
QgsMapCanvas mapCanvas,
QgsDistanceArea  myDa 
)

Has to be called to initialize the dual view.

Parameters
layerThe layer which should be used to fetch features
mapCanvasThe mapCanvas (used for the FilterMode QgsAttributeTableFilterModel::ShowVisible
myDaUsed for attribute dialog creation

Definition at line 60 of file qgsdualview.cpp.

References columnBoxInit(), QgsAttributeDialog::dialog(), initLayerCache(), initModels(), mAttributeDialog, mDistanceArea, mFeatureListModel, mFilterModel, and viewWillShowContextMenu().

void QgsDualView::initLayerCache ( QgsVectorLayer layer)
private
void QgsDualView::initModels ( QgsMapCanvas mapCanvas)
private
QgsAttributeTableModel* QgsDualView::masterModel ( ) const
inline

Returns the model which has the information about all features (not only filtered)

Returns
The master model

Definition at line 131 of file qgsdualview.h.

Referenced by QgsAttributeTableAction::execute(), and QgsAttributeTableAction::featureForm().

void QgsDualView::on_mFeatureList_currentEditSelectionChanged ( const QgsFeature feat)
privateslot

Changes the currently visible feature within the attribute editor.

Parameters
featThe newly visible feature

Definition at line 252 of file qgsdualview.cpp.

References QgsAttributeDialog::dialog(), QgsFeature::isValid(), QgsVectorLayerCache::layer(), mAttributeDialog, mDistanceArea, mLayerCache, and saveEditChanges().

Referenced by editingToggled().

void QgsDualView::previewColumnChanged ( QObject *  previewAction)
privateslot

Definition at line 331 of file qgsdualview.cpp.

References tr.

Referenced by QgsDualView().

void QgsDualView::previewExpressionBuilder ( )
privateslot
void QgsDualView::previewExpressionChanged ( const QString  expression)
privateslot
void QgsDualView::progress ( int  i,
bool &  cancel 
)
privatevirtualslot

Will be called periodically, when loading layers from slow data providers.

Parameters
iThe number of features already loaded
cancelSet to true to cancel

Definition at line 517 of file qgsdualview.cpp.

References mProgressDlg, and tr.

Referenced by initLayerCache(), and initModels().

void QgsDualView::reloadAttribute ( const int &  attribute)
slot
void QgsDualView::saveEditChanges ( )
slot
void QgsDualView::setCurrentEditSelection ( const QgsFeatureIds fids)
slot

Set the current edit selection in the AttributeEditor mode.

Parameters
fidsA list of edited features (Currently only one at a time is supported)

Definition at line 273 of file qgsdualview.cpp.

Referenced by QgsAttributeTableAction::featureForm().

void QgsDualView::setFilteredFeatures ( QgsFeatureIds  filteredFeatures)

Set a list of currently visible features.

Parameters
filteredFeaturesA list of feature ids

Definition at line 512 of file qgsdualview.cpp.

References mFilterModel, and QgsAttributeTableFilterModel::setFilteredFeatures().

void QgsDualView::setFilterMode ( QgsAttributeTableFilterModel::FilterMode  filterMode)

Set the filter mode.

Parameters
filterMode

Definition at line 203 of file qgsdualview.cpp.

References mFilterModel, and QgsAttributeTableFilterModel::setFilterMode().

void QgsDualView::setSelectedOnTop ( bool  selectedOnTop)

Toggle the selectedOnTop flag.

If enabled, selected features will be moved to top.

Parameters
selectedOnTopTrue: Show selected features on top. False: Use defined sorting column.

Definition at line 208 of file qgsdualview.cpp.

References mFilterModel, and QgsAttributeTableFilterModel::setSelectedOnTop().

void QgsDualView::setView ( QgsDualView::ViewMode  view)

Change the current view mode.

Parameters
viewThe view mode to set

Definition at line 198 of file qgsdualview.cpp.

Referenced by QgsAttributeTableAction::featureForm().

void QgsDualView::viewWillShowContextMenu ( QMenu *  menu,
QModelIndex  atIndex 
)
privateslot

Friends And Related Function Documentation

friend class TestQgsDualView
friend

Definition at line 247 of file qgsdualview.h.

Member Data Documentation

QgsAttributeDialog* QgsDualView::mAttributeDialog
private
QgsDistanceArea QgsDualView::mDistanceArea
private
QgsCachedFeatureIterator* QgsDualView::mFeatureCache
private

Definition at line 239 of file qgsdualview.h.

QgsFeatureListModel* QgsDualView::mFeatureListModel
private

Definition at line 237 of file qgsdualview.h.

Referenced by init(), and initModels().

QgsAttributeTableFilterModel* QgsDualView::mFilterModel
private
QgsVectorLayerCache* QgsDualView::mLayerCache
private
QgsAttributeTableModel* QgsDualView::mMasterModel
private

Definition at line 235 of file qgsdualview.h.

Referenced by featureCount(), and initModels().

QSignalMapper* QgsDualView::mPreviewActionMapper
private

Definition at line 240 of file qgsdualview.h.

Referenced by columnBoxInit(), and QgsDualView().

QMenu* QgsDualView::mPreviewColumnsMenu
private

Definition at line 241 of file qgsdualview.h.

Referenced by columnBoxInit(), and QgsDualView().

QProgressDialog* QgsDualView::mProgressDlg
private

Definition at line 243 of file qgsdualview.h.

Referenced by finished(), and progress().


The documentation for this class was generated from the following files: