Skip to content

Commit 149dcca

Browse files
author
jef
committed
implement #3015
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14243 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7176516 commit 149dcca

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/app/qgisappinterface.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "qgsmapcanvas.h"
3030
#include "qgslegend.h"
3131
#include "qgsshortcutsmanager.h"
32+
#include "qgsattributedialog.h"
33+
#include "qgsfield.h"
34+
#include "qgsvectordataprovider.h"
3235

3336
QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
3437
: qgis( _qgis ),
@@ -352,3 +355,26 @@ QAction *QgisAppInterface::actionQgisHomePage() { return qgis->actionQgisHomePag
352355
QAction *QgisAppInterface::actionCheckQgisVersion() { return qgis->actionCheckQgisVersion(); }
353356
QAction *QgisAppInterface::actionHelpSeparator2() { return qgis->actionHelpSeparator2(); }
354357
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+
}

src/app/qgisappinterface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ class QgisAppInterface : public QgisInterface
262262
virtual QAction *actionHelpSeparator2();
263263
virtual QAction *actionAbout();
264264

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+
265270
signals:
266271
void currentThemeChanged( QString );
267272

src/gui/qgisinterface.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class QgsMapCanvas;
3737
class QgsRasterLayer;
3838
class QgsVectorLayer;
3939
class QgsLegendInterface;
40+
class QgsFeature;
4041

4142
/** \ingroup gui
4243
* QgisInterface
@@ -302,6 +303,11 @@ class GUI_EXPORT QgisInterface : public QObject
302303
virtual QAction *actionHelpSeparator2() = 0;
303304
virtual QAction *actionAbout() = 0;
304305

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+
305311
signals:
306312
/** Emited whenever current (selected) layer changes.
307313
* The pointer to layer can be null if no layer is selected

0 commit comments

Comments
 (0)