QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgseditorwidgetfactory.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgseditorwidgetfactory.cpp
3  --------------------------------------
4  Date : 21.4.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 
16 #include "qgseditorwidgetfactory.h"
17 
18 #include <QSettings>
19 
21  : mName( name )
22 {
23 }
24 
26 {
27 }
28 
30 {
31  return mName;
32 }
33 
34 QgsEditorWidgetConfig QgsEditorWidgetFactory::readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
35 {
36  return readConfig( configElement, layer, fieldIdx );
37 }
38 
39 void QgsEditorWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
40 {
41  Q_UNUSED( config );
42  Q_UNUSED( configElement );
43  Q_UNUSED( doc );
44  Q_UNUSED( layer );
45  Q_UNUSED( fieldIdx );
46 }
47 
48 QString QgsEditorWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const
49 {
50  Q_UNUSED( vl )
51  Q_UNUSED( fieldIdx )
52  Q_UNUSED( config )
53  Q_UNUSED( cache )
54  Q_UNUSED( value )
55 
56  const QgsField &fld = vl->pendingFields().at( fieldIdx );
57  return fld.displayString( value );
58 }
59 
60 QVariant QgsEditorWidgetFactory::createCache( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config )
61 {
62  Q_UNUSED( vl )
63  Q_UNUSED( fieldIdx )
64  Q_UNUSED( config )
65 
66  return QVariant();
67 }
68 
69 QgsEditorWidgetConfig QgsEditorWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
70 {
71  Q_UNUSED( configElement );
72  Q_UNUSED( layer );
73  Q_UNUSED( fieldIdx );
74 
75  return QgsEditorWidgetConfig();
76 }
77 
78 bool QgsEditorWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
79 {
80  Q_UNUSED( vl )
81  Q_UNUSED( fieldIdx )
82  return true;
83 }
84 
QString displayString(const QVariant &v) const
Formats string for display.
Definition: qgsfield.cpp:118
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.h:227
QgsEditorWidgetFactory(const QString &name)
Constructor.
virtual QVariant createCache(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config)
Create a cache for a given field.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:33
QString name()
Return The human readable identifier name of this widget type.
QgsEditorWidgetConfig readEditorConfig(const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx)
Read the config from an XML file and map it to a proper QgsEditorWidgetConfig.
virtual void writeConfig(const QgsEditorWidgetConfig &config, QDomElement &configElement, QDomDocument &doc, const QgsVectorLayer *layer, int fieldIdx)
Serialize your configuration and save it in a xml doc.
virtual QString representValue(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config, const QVariant &cache, const QVariant &value) const
Create a pretty String representation of the value.
QMap< QString, QVariant > QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
Represents a vector layer which manages a vector based data sets.