QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrelationreferencefactory.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrelationreferencefactory.cpp
3  --------------------------------------
4  Date : 29.5.2013
5  Copyright : (C) 2013 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 
17 
20 
22  : QgsEditorWidgetFactory( name )
23  , mCanvas( canvas )
24  , mMessageBar( messageBar )
25 {
26 }
27 
28 QgsEditorWidgetWrapper* QgsRelationReferenceFactory::create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const
29 {
30  return new QgsRelationReferenceWidgetWrapper( vl, fieldIdx, editor, mCanvas, mMessageBar, parent );
31 }
32 
34 {
35  return new QgsRelationReferenceConfigDlg( vl, fieldIdx, parent );
36 }
37 
38 QgsEditorWidgetConfig QgsRelationReferenceFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
39 {
40  Q_UNUSED( layer );
41  Q_UNUSED( fieldIdx );
42  QMap<QString, QVariant> cfg;
43 
44  cfg.insert( "AllowNULL", configElement.attribute( "AllowNULL" ) == "1" );
45  cfg.insert( "OrderByValue", configElement.attribute( "OrderByValue" ) == "1" );
46  cfg.insert( "ShowForm", configElement.attribute( "ShowForm" ) == "1" );
47  cfg.insert( "Relation", configElement.attribute( "Relation" ) );
48  cfg.insert( "MapIdentification", configElement.attribute( "MapIdentification" ) == "1" );
49  cfg.insert( "ReadOnly", configElement.attribute( "ReadOnly" ) == "1" );
50 
51  return cfg;
52 }
53 
54 void QgsRelationReferenceFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
55 {
56  Q_UNUSED( doc );
57  Q_UNUSED( layer );
58  Q_UNUSED( fieldIdx );
59 
60  configElement.setAttribute( "AllowNULL", config["AllowNULL"].toBool() );
61  configElement.setAttribute( "OrderByValue", config["OrderByValue"].toBool() );
62  configElement.setAttribute( "ShowForm", config["ShowForm"].toBool() );
63  configElement.setAttribute( "Relation", config["Relation"].toString() );
64  configElement.setAttribute( "MapIdentification", config["MapIdentification"].toBool() );
65  configElement.setAttribute( "ReadOnly", config["ReadOnly"].toBool() );
66 }