QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsattributeform.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsattributeform.h
3  --------------------------------------
4  Date : 3.5.2014
5  Copyright : (C) 2014 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 QGSATTRIBUTEFORM_H
17 #define QGSATTRIBUTEFORM_H
18 
19 #include "qgsfeature.h"
20 #include "qgsvectorlayer.h"
21 #include "qgseditorwidgetwrapper.h"
23 
24 #include <QWidget>
25 #include <QDialogButtonBox>
26 
28 
29 class GUI_EXPORT QgsAttributeForm : public QWidget
30 {
31  Q_OBJECT
32 
33  public:
34  explicit QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature feature = QgsFeature(), QgsAttributeEditorContext context = QgsAttributeEditorContext(), QWidget *parent = 0 );
36 
37  const QgsFeature& feature() { return mFeature; }
38 
42  void hideButtonBox();
43 
47  void showButtonBox();
48 
53  void addInterface( QgsAttributeFormInterface* iface );
54 
60  QgsVectorLayer* layer() { return mLayer; }
61 
67  bool editable();
68 
76  void setIsAddDialog( bool isAddDialog );
77 
83  void setEditCommandMessage( const QString& message ) { mEditCommandMessage = message; }
84 
93  bool eventFilter( QObject* object, QEvent* event );
94 
95  signals:
102  void attributeChanged( QString attribute, const QVariant& value );
103 
112  void beforeSave( bool& ok );
113 
117  void featureSaved( const QgsFeature& feature );
118 
119  public slots:
126  void changeAttribute( const QString& field, const QVariant& value );
127 
133  void setFeature( const QgsFeature& feature );
134 
140  bool save();
141 
147  Q_DECL_DEPRECATED void accept() { save(); }
148 
154  Q_DECL_DEPRECATED void reject() { resetValues(); }
155 
159  void resetValues();
160 
161  private slots:
162  void onAttributeChanged( const QVariant& value );
163  void onAttributeAdded( int idx );
164  void onAttributeDeleted( int idx );
165 
166  void synchronizeEnabledState();
167 
168  private:
169  void init();
170 
171  void cleanPython();
172 
173  void initPython();
174 
175  QWidget* createWidgetFromDef( const QgsAttributeEditorElement* widgetDef, QWidget* parent, QgsVectorLayer* vl, QgsAttributeEditorContext& context, QString& labelText, bool& labelOnTop );
176 
181  void createWrappers();
182  void connectWrappers();
183 
186  QList<QgsWidgetWrapper*> mWidgets;
188  QDialogButtonBox* mButtonBox;
189  QList<QgsAttributeFormInterface*> mInterfaces;
190 
191  // Variables below are used for python
192  static int sFormCounter;
193  int mFormNr;
194  QString mPyFormVarName;
195 
197  bool mIsSaving;
199 
201 };
202 
203 #endif // QGSATTRIBUTEFORM_H
Q_DECL_DEPRECATED void accept()
Alias for save()
This class contains context information for attribute editor widgets.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
QDialogButtonBox * mButtonBox
QgsVectorLayer * layer()
Returns the layer for which this form is shown.
QgsAttributeEditorContext mContext
QList< QgsAttributeFormInterface * > mInterfaces
QgsVectorLayer * mLayer
QList< QgsWidgetWrapper * > mWidgets
static int sFormCounter
Q_DECL_DEPRECATED void reject()
Alias for resetValues()
void setEditCommandMessage(const QString &message)
Sets the edit command message (Undo) that will be used when the dialog is accepted.
const QgsFeature & feature()
bool mIsSaving
Set to true while saving to prevent recursive saves.
Represents a vector layer which manages a vector based data sets.