QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsattributeeditorcontext.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsattributeeditorcontext.h
3  --------------------------------------
4  Date : 30.7.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias dot kuhn at gmx 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 QGSATTRIBUTEEDITORCONTEXT_H
17 #define QGSATTRIBUTEEDITORCONTEXT_H
18 
19 #include <QMap>
20 #include <QWidget>
21 
22 #include <qgsdistancearea.h>
23 #include <qgsvectorlayer.h>
24 #include <qgsvectorlayertools.h>
25 
26 
33 class GUI_EXPORT QgsAttributeEditorContext
34 {
35  public:
40  {
43  Single
44  };
45 
46  enum FormMode
47  {
50  Popup
51  };
52 
54  : mParentContext( 0 )
55  , mLayer( 0 )
56  , mVectorLayerTools( 0 )
57  , mRelationMode( Undefined )
58  {}
59 
61  : mParentContext( &parentContext )
62  , mLayer( 0 )
63  , mVectorLayerTools( parentContext.mVectorLayerTools )
64  , mDistanceArea( parentContext.mDistanceArea )
65  , mRelationMode( Undefined )
66  , mFormMode( formMode )
67  {
68  Q_ASSERT( parentContext.vectorLayerTools() );
69  }
70 
71  QgsAttributeEditorContext( const QgsAttributeEditorContext& parentContext, const QgsRelation& relation, RelationMode relationMode, FormMode widgetMode )
72  : mParentContext( &parentContext )
73  , mLayer( 0 )
74  , mVectorLayerTools( parentContext.mVectorLayerTools )
75  , mDistanceArea( parentContext.mDistanceArea )
76  , mRelation( relation )
77  , mRelationMode( relationMode )
78  , mFormMode( widgetMode )
79  {
80  Q_ASSERT( parentContext.vectorLayerTools() );
81  }
82 
83  inline void setDistanceArea( const QgsDistanceArea& distanceArea )
84  {
85  if ( mLayer )
86  {
87  mDistanceArea = distanceArea;
88  mDistanceArea.setSourceCrs( mLayer->crs() );
89  }
90  }
91 
92  inline const QgsDistanceArea& distanceArea() const { return mDistanceArea; }
93 
94  inline void setVectorLayerTools( QgsVectorLayerTools* vlTools ) { mVectorLayerTools = vlTools; }
95  inline const QgsVectorLayerTools* vectorLayerTools() const { return mVectorLayerTools; }
96 
97  inline void setRelation( const QgsRelation& relation, RelationMode mode ) { mRelation = relation; mRelationMode = mode; }
98  inline const QgsRelation& relation() const { return mRelation; }
99  inline RelationMode relationMode() const { return mRelationMode; }
100 
101  inline FormMode formMode() const { return mFormMode; }
102 
103  inline const QgsAttributeEditorContext* parentContext() const { return mParentContext; }
104 
105  private:
106  const QgsAttributeEditorContext* mParentContext;
107  QgsVectorLayer* mLayer;
108  QgsVectorLayerTools* mVectorLayerTools;
109  QgsDistanceArea mDistanceArea;
110  QgsRelation mRelation;
111  RelationMode mRelationMode;
112  FormMode mFormMode;
113 };
114 
115 #endif // QGSATTRIBUTEEDITORCONTEXT_H
Methods in this class are used to handle basic operations on vector layers.
Definition: qgsvectorlayertools.h:33
A form was opened as a new dialog.
Definition: qgsattributeeditorcontext.h:49
const QgsDistanceArea & distanceArea() const
Definition: qgsattributeeditorcontext.h:92
This class contains context information for attribute editor widgets.
Definition: qgsattributeeditorcontext.h:33
QgsAttributeEditorContext(const QgsAttributeEditorContext &parentContext, FormMode formMode)
Definition: qgsattributeeditorcontext.h:60
void setSourceCrs(long srsid)
sets source spatial reference system (by QGIS CRS)
Definition: qgsdistancearea.cpp:93
When showing a list of features (e.g. houses as an embedded form in a district form) ...
Definition: qgsattributeeditorcontext.h:42
QgsAttributeEditorContext()
Definition: qgsattributeeditorcontext.h:53
QgsAttributeEditorContext(const QgsAttributeEditorContext &parentContext, const QgsRelation &relation, RelationMode relationMode, FormMode widgetMode)
Definition: qgsattributeeditorcontext.h:71
void setVectorLayerTools(QgsVectorLayerTools *vlTools)
Definition: qgsattributeeditorcontext.h:94
This context is not defined by a relation.
Definition: qgsattributeeditorcontext.h:41
RelationMode relationMode() const
Definition: qgsattributeeditorcontext.h:99
RelationMode
Determines in which direction a relation was resolved.
Definition: qgsattributeeditorcontext.h:39
void setDistanceArea(const QgsDistanceArea &distanceArea)
Definition: qgsattributeeditorcontext.h:83
FormMode formMode() const
Definition: qgsattributeeditorcontext.h:101
General purpose distance and area calculator.
Definition: qgsdistancearea.h:34
Definition: qgsrelation.h:28
const QgsRelation & relation() const
Definition: qgsattributeeditorcontext.h:98
const QgsVectorLayerTools * vectorLayerTools() const
Definition: qgsattributeeditorcontext.h:95
const QgsAttributeEditorContext * parentContext() const
Definition: qgsattributeeditorcontext.h:103
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
void setRelation(const QgsRelation &relation, RelationMode mode)
Definition: qgsattributeeditorcontext.h:97
A form was embedded as a widget on another form.
Definition: qgsattributeeditorcontext.h:48
FormMode
Definition: qgsattributeeditorcontext.h:46