QGIS/src/gui/editorwidgets/qgsphotowidgetfactory.cpp
Patrick Valsecchi 91e4b24a39 Better reading/writting of editor widget config.
Avoid saving config parameters that are not set and support not
having them in the XML.
2016-11-07 09:00:17 +01:00

59 lines
2.2 KiB
C++

/***************************************************************************
qgsphotowidgetfactory.cpp
--------------------------------------
Date : 5.1.2014
Copyright : (C) 2014 Matthias Kuhn
Email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsphotowidgetfactory.h"
#include "qgsphotowidgetwrapper.h"
#include "qgsphotoconfigdlg.h"
QgsPhotoWidgetFactory::QgsPhotoWidgetFactory( const QString& name )
: QgsEditorWidgetFactory( name )
{
}
QgsEditorWidgetWrapper* QgsPhotoWidgetFactory::create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const
{
return new QgsPhotoWidgetWrapper( vl, fieldIdx, editor, parent );
}
QgsEditorConfigWidget* QgsPhotoWidgetFactory::configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const
{
return new QgsPhotoConfigDlg( vl, fieldIdx, parent );
}
QgsEditorWidgetConfig QgsPhotoWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
{
Q_UNUSED( layer )
Q_UNUSED( fieldIdx )
QgsEditorWidgetConfig cfg;
xml2config( configElement, cfg, QStringLiteral( "Height" ) );
xml2config( configElement, cfg, QStringLiteral( "Width" ) );
return cfg;
}
void QgsPhotoWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
{
Q_UNUSED( doc )
Q_UNUSED( layer )
Q_UNUSED( fieldIdx )
config2xml( config, configElement, QStringLiteral( "Height" ) );
config2xml( config, configElement, QStringLiteral( "Width" ) );
}