QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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"
18 
19 #include <QSettings>
20 
22 
24  : mName( name )
25 {
26 }
27 
29 {
30 }
31 
36 {
37  return new QgsDefaultSearchWidgetWrapper( vl, fieldIdx, 0, parent );
38 }
39 
41 {
42  return mName;
43 }
44 
46 {
47  return readConfig( configElement, layer, fieldIdx );
48 }
49 
51 {
52  Q_UNUSED( config );
53  Q_UNUSED( configElement );
54  Q_UNUSED( doc );
55  Q_UNUSED( layer );
56  Q_UNUSED( fieldIdx );
57 }
58 
60 {
61  Q_UNUSED( vl )
62  Q_UNUSED( fieldIdx )
63  Q_UNUSED( config )
64  Q_UNUSED( cache )
65  Q_UNUSED( value )
66 
67  const QgsField &fld = vl->pendingFields().at( fieldIdx );
68  return fld.displayString( value );
69 }
70 
72 {
73  Q_UNUSED( vl )
74  Q_UNUSED( fieldIdx )
75  Q_UNUSED( config )
76 
77  return QVariant();
78 }
79 
81 {
82  Q_UNUSED( configElement );
83  Q_UNUSED( layer );
84  Q_UNUSED( fieldIdx );
85 
86  return QgsEditorWidgetConfig();
87 }
88 
89 bool QgsEditorWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
90 {
91  Q_UNUSED( vl )
92  Q_UNUSED( fieldIdx )
93  return true;
94 }
95 
QString displayString(const QVariant &v) const
Formats string for display.
Definition: qgsfield.cpp:128
Manages an editor widget Widget and wrapper share the same parent.
QgsVectorLayer * layer()
Access the QgsVectorLayer, you are working on.
QgsEditorWidgetFactory(const QString &name)
Constructor.
virtual QgsEditorWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const
Override in own factory to get something different than the default (a simple QgsFilterLineEdit) ...
virtual QVariant createCache(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config)
Create a cache for a given field.
QgsDefaultSearchWidgetWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *editor=0, QWidget *parent=0)
const char * name() const
const QgsEditorWidgetConfig config()
Returns the whole config.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:38
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.cpp:303
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.
int fieldIdx()
Access the field index.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
QVariant value() override
Will be used to access the widget's value.