Skip to content

Commit

Permalink
implement #3015
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14243 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 17, 2010
1 parent 7176516 commit 149dcca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "qgsmapcanvas.h"
#include "qgslegend.h"
#include "qgsshortcutsmanager.h"
#include "qgsattributedialog.h"
#include "qgsfield.h"
#include "qgsvectordataprovider.h"

QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
: qgis( _qgis ),
Expand Down Expand Up @@ -352,3 +355,26 @@ QAction *QgisAppInterface::actionQgisHomePage() { return qgis->actionQgisHomePag
QAction *QgisAppInterface::actionCheckQgisVersion() { return qgis->actionCheckQgisVersion(); }
QAction *QgisAppInterface::actionHelpSeparator2() { return qgis->actionHelpSeparator2(); }
QAction *QgisAppInterface::actionAbout() { return qgis->actionAbout(); }

bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f )
{
if ( !vlayer )
return false;

QgsVectorDataProvider *dp = vlayer->dataProvider();
if ( dp )
{
// add the fields to the QgsFeature
const QgsFieldMap fields = vlayer->pendingFields();
for ( QgsFieldMap::const_iterator it = fields.constBegin(); it != fields.constEnd(); ++it )
{
if ( !f.attributeMap().contains( it.key() ) )
f.addAttribute( it.key(), dp->defaultValue( it.key() ) );
}
}

QgsAttributeDialog *mypDialog = new QgsAttributeDialog( vlayer, &f );
bool res = mypDialog->exec();
delete mypDialog;
return res;
}
5 changes: 5 additions & 0 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ class QgisAppInterface : public QgisInterface
virtual QAction *actionHelpSeparator2();
virtual QAction *actionAbout();

//! open feature form
// returns true when dialog was accepted
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f );

signals:
void currentThemeChanged( QString );

Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class QgsMapCanvas;
class QgsRasterLayer;
class QgsVectorLayer;
class QgsLegendInterface;
class QgsFeature;

/** \ingroup gui
* QgisInterface
Expand Down Expand Up @@ -302,6 +303,11 @@ class GUI_EXPORT QgisInterface : public QObject
virtual QAction *actionHelpSeparator2() = 0;
virtual QAction *actionAbout() = 0;

//! Open feature form
// returns true when dialog was accepted
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f ) = 0;

signals:
/** Emited whenever current (selected) layer changes.
* The pointer to layer can be null if no layer is selected
Expand Down

0 comments on commit 149dcca

Please sign in to comment.