QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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"
18 #include "qgssearchwidgetwrapper.h"
19 
20 #include <QSettings>
21 
23 
25  : mName( name )
26 {
27 }
28 
30 {
31 }
32 
37 {
38  return new QgsDefaultSearchWidgetWrapper( vl, fieldIdx, parent );
39 }
40 
42 {
43  return mName;
44 }
45 
47 {
48  return readConfig( configElement, layer, fieldIdx );
49 }
50 
52 {
53  Q_UNUSED( config );
54  Q_UNUSED( configElement );
55  Q_UNUSED( doc );
56  Q_UNUSED( layer );
57  Q_UNUSED( fieldIdx );
58 }
59 
60 QString QgsEditorWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const
61 {
62  Q_UNUSED( vl )
63  Q_UNUSED( fieldIdx )
64  Q_UNUSED( config )
65  Q_UNUSED( cache )
66  Q_UNUSED( value )
67 
68  const QgsField &fld = vl->pendingFields().at( fieldIdx );
69  return fld.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:128
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.
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.
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.
virtual QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const
Override in own factory to get something different than the default (a simple QgsFilterLineEdit) ...