QGIS API Documentation  2.11.0-Master
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 at opengis 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"
18 #include "qgssearchwidgetwrapper.h"
19 
20 #include <QSettings>
21 
23 
25  : mName( name )
26 {
27 }
28 
30 {
31 }
32 
38 {
39  return new QgsDefaultSearchWidgetWrapper( vl, fieldIdx, parent );
40 }
41 
43 {
44  return mName;
45 }
46 
48 {
49  return readConfig( configElement, layer, fieldIdx );
50 }
51 
53 {
54  Q_UNUSED( config );
55  Q_UNUSED( configElement );
56  Q_UNUSED( doc );
57  Q_UNUSED( layer );
58  Q_UNUSED( fieldIdx );
59 }
60 
61 QString QgsEditorWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const
62 {
63  Q_UNUSED( vl )
64  Q_UNUSED( fieldIdx )
65  Q_UNUSED( config )
66  Q_UNUSED( cache )
67  Q_UNUSED( value )
68 
69  return vl->fields().at( fieldIdx ).displayString( value );
70 }
71 
73 {
74  Q_UNUSED( vl )
75  Q_UNUSED( fieldIdx )
76  Q_UNUSED( config )
77 
78  return QVariant();
79 }
80 
82 {
83  Q_UNUSED( configElement );
84  Q_UNUSED( layer );
85  Q_UNUSED( fieldIdx );
86 
87  return QgsEditorWidgetConfig();
88 }
89 
90 bool QgsEditorWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
91 {
92  Q_UNUSED( vl )
93  Q_UNUSED( fieldIdx )
94  return true;
95 }
96 
Manages an editor widget Widget and wrapper share the same parent.
QString displayString(const QVariant &v) const
Formats string for display.
Definition: qgsfield.cpp:129
QgsFields fields() const
Returns the list of fields of this layer.
QgsVectorLayer * layer()
Access the QgsVectorLayer, you are working on.
QgsEditorWidgetFactory(const QString &name)
Constructor.
QgsDefaultSearchWidgetWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=0)
virtual QVariant createCache(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config)
Create a cache for a given field.
const char * name() const
const QgsEditorWidgetConfig config()
Returns the whole config.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.cpp:305
QString name()
Return The human readable identifier name of this widget type.
virtual QgsEditorWidgetConfig readConfig(const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx)
Read the config from an XML file and map it to a proper QgsEditorWidgetConfig.
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.
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
virtual QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const
By default a simple QgsFilterLineEdit is returned as search widget.