File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 29
29
#include " qgsmapcanvas.h"
30
30
#include " qgslegend.h"
31
31
#include " qgsshortcutsmanager.h"
32
+ #include " qgsattributedialog.h"
33
+ #include " qgsfield.h"
34
+ #include " qgsvectordataprovider.h"
32
35
33
36
QgisAppInterface::QgisAppInterface ( QgisApp * _qgis )
34
37
: qgis( _qgis ),
@@ -352,3 +355,26 @@ QAction *QgisAppInterface::actionQgisHomePage() { return qgis->actionQgisHomePag
352
355
QAction *QgisAppInterface::actionCheckQgisVersion () { return qgis->actionCheckQgisVersion (); }
353
356
QAction *QgisAppInterface::actionHelpSeparator2 () { return qgis->actionHelpSeparator2 (); }
354
357
QAction *QgisAppInterface::actionAbout () { return qgis->actionAbout (); }
358
+
359
+ bool QgisAppInterface::openFeatureForm ( QgsVectorLayer *vlayer, QgsFeature &f )
360
+ {
361
+ if ( !vlayer )
362
+ return false ;
363
+
364
+ QgsVectorDataProvider *dp = vlayer->dataProvider ();
365
+ if ( dp )
366
+ {
367
+ // add the fields to the QgsFeature
368
+ const QgsFieldMap fields = vlayer->pendingFields ();
369
+ for ( QgsFieldMap::const_iterator it = fields.constBegin (); it != fields.constEnd (); ++it )
370
+ {
371
+ if ( !f.attributeMap ().contains ( it.key () ) )
372
+ f.addAttribute ( it.key (), dp->defaultValue ( it.key () ) );
373
+ }
374
+ }
375
+
376
+ QgsAttributeDialog *mypDialog = new QgsAttributeDialog ( vlayer, &f );
377
+ bool res = mypDialog->exec ();
378
+ delete mypDialog;
379
+ return res;
380
+ }
Original file line number Diff line number Diff line change @@ -262,6 +262,11 @@ class QgisAppInterface : public QgisInterface
262
262
virtual QAction *actionHelpSeparator2 ();
263
263
virtual QAction *actionAbout ();
264
264
265
+ // ! open feature form
266
+ // returns true when dialog was accepted
267
+ // @added in 1.6
268
+ virtual bool openFeatureForm ( QgsVectorLayer *l, QgsFeature &f );
269
+
265
270
signals:
266
271
void currentThemeChanged ( QString );
267
272
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class QgsMapCanvas;
37
37
class QgsRasterLayer ;
38
38
class QgsVectorLayer ;
39
39
class QgsLegendInterface ;
40
+ class QgsFeature ;
40
41
41
42
/* * \ingroup gui
42
43
* QgisInterface
@@ -302,6 +303,11 @@ class GUI_EXPORT QgisInterface : public QObject
302
303
virtual QAction *actionHelpSeparator2 () = 0;
303
304
virtual QAction *actionAbout () = 0;
304
305
306
+ // ! Open feature form
307
+ // returns true when dialog was accepted
308
+ // @added in 1.6
309
+ virtual bool openFeatureForm ( QgsVectorLayer *vlayer, QgsFeature &f ) = 0;
310
+
305
311
signals:
306
312
/* * Emited whenever current (selected) layer changes.
307
313
* The pointer to layer can be null if no layer is selected
You can’t perform that action at this time.
0 commit comments