QGIS API Documentation  2.0.1-Dufour
 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 : jef@norbit.de
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 
23 #include "qgsfeature.h"
24 
25 class QObject;
26 class QWidget;
27 class QgsVectorLayer;
28 class QComboBox;
29 class QListWidget;
31 
32 /* \brief create attribute widget for editing */
33 class GUI_EXPORT QgsAttributeEditor : public QObject
34 {
35  Q_OBJECT
36 
37  public:
38  QgsAttributeEditor( QObject *parent, QgsVectorLayer *vl = 0, int idx = -1 )
39  : QObject( parent )
40  , mLayer( vl )
41  , mIdx( idx )
42  {};
53  static QWidget *createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value, QMap<int, QWidget*> &proxyWidgets );
63  static QWidget *createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value );
74  static QWidget *createWidgetFromDef( const QgsAttributeEditorElement* widgetDef, QWidget* parent, QgsVectorLayer* vl, QgsAttributes &attrs, QMap<int, QWidget*> &proxyWidgets, bool createGroupBox );
75  static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
76  static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
77 
78  private:
79  static QComboBox *comboBox( QWidget *editor, QWidget *parent );
80  static QListWidget *listWidget( QWidget *editor, QWidget *parent );
81 
82  public slots:
83  void selectFileName();
84  void selectDate();
85  void loadUrl( const QString & );
86  void loadPixmap( const QString & );
87  void updateUrl();
88  void openUrl();
89  void updateColor();
90 
91  private:
93  int mIdx;
94 };
95 
96 class GUI_EXPORT QgsStringRelay : public QObject
97 {
98  Q_OBJECT
99 
100  public:
101 
102  QgsStringRelay( QObject* parent = NULL )
103  : QObject( parent ) {}
104 
105  void appendProxy( QWidget* proxy ) { mProxyList << proxy; }
106 
107  public slots:
108  void changeText();
109  void changeText( QString str );
110 
111  signals:
112  void textChanged( QString );
113 
114  private:
115  QList<QWidget*> mProxyList;
116 };
117 
118 #endif