QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsattributeeditor.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsattributeeditor.h - description
3  -------------------
4  begin : July 2009
5  copyright : (C) 2009 by Jürgen E. Fischer
6  email : [email protected]
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSATTRIBUTEEDITOR_H
18 #define QGSATTRIBUTEEDITOR_H
19 
20 #include <QVariant>
21 #include <QMetaType>
22 #include <QGridLayout>
23 
24 #include "qgsfeature.h"
25 #include "qgsrelationmanager.h"
26 
27 class QObject;
28 class QWidget;
29 class QComboBox;
30 class QListWidget;
31 
34 class QgsDualView;
35 class QgsRelationManager;
36 class QgsVectorLayer;
37 
38 /* \brief create attribute widget for editing */
39 class GUI_EXPORT QgsAttributeEditor : public QObject
40 {
41  Q_OBJECT
42 
43  public:
44  QgsAttributeEditor( QObject* parent, QgsVectorLayer* vl = 0, int idx = -1 )
45  : QObject( parent )
46  , mLayer( vl )
47  , mIdx( idx )
48  {}
60  static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant &value, QMap<int, QWidget*>& proxyWidgets );
61 
71  static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value );
82  static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value, QgsAttributeEditorContext& context );
83 
97  static QWidget *createWidgetFromDef( const QgsAttributeEditorElement* widgetDef, QWidget* parent, QgsVectorLayer* vl, const QgsFeature &feat, QgsAttributeEditorContext& context, QString& labelText, bool& labelOnTop );
98 
99  static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
100  static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
101 
102  private:
103  static QComboBox *comboBox( QWidget *editor, QWidget *parent );
104  static QListWidget *listWidget( QWidget *editor, QWidget *parent );
105  static QgsDualView* dualView( QWidget* editor, QWidget* parent );
106 
107  public slots:
108  void selectFileName();
109  void selectDate();
110  void loadUrl( const QString & );
111  void loadPixmap( const QString & );
112  void updateUrl();
113  void openUrl();
114  void updateColor();
115 
116  private:
118  int mIdx;
119 };
120 
121 class GUI_EXPORT QgsStringRelay : public QObject
122 {
123  Q_OBJECT
124 
125  public:
126 
127  QgsStringRelay( QObject* parent = NULL )
128  : QObject( parent ) {}
129 
130  void appendProxy( QWidget* proxy ) { mProxyList << proxy; }
131 
132  public slots:
133  void changeText();
134  void changeText( QString str );
135 
136  signals:
137  void textChanged( QString );
138 
139  private:
140  QList<QWidget*> mProxyList;
141 };
142 
144 
145 #endif