|
QGIS API Documentation
master-3f58142
|
00001 /*************************************************************************** 00002 qgsattributeeditor.h - description 00003 ------------------- 00004 begin : July 2009 00005 copyright : (C) 2009 by Jürgen E. Fischer 00006 email : jef@norbit.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #ifndef QGSATTRIBUTEEDITOR_H 00018 #define QGSATTRIBUTEEDITOR_H 00019 00020 #include <QVariant> 00021 #include <QMetaType> 00022 00023 #include "qgsfeature.h" 00024 00025 class QObject; 00026 class QWidget; 00027 class QgsVectorLayer; 00028 class QComboBox; 00029 class QListWidget; 00030 class QgsAttributeEditorElement; 00031 00032 /* \brief create attribute widget for editing */ 00033 class GUI_EXPORT QgsAttributeEditor : public QObject 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 QgsAttributeEditor( QObject *parent, QgsVectorLayer *vl = 0, int idx = -1 ) 00039 : QObject( parent ) 00040 , mLayer( vl ) 00041 , mIdx( idx ) 00042 {}; 00053 static QWidget *createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value, QMap<int, QWidget*> &proxyWidgets ); 00063 static QWidget *createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value ); 00074 static QWidget *createWidgetFromDef( const QgsAttributeEditorElement* widgetDef, QWidget* parent, QgsVectorLayer* vl, QgsAttributes &attrs, QMap<int, QWidget*> &proxyWidgets, bool createGroupBox ); 00075 static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value ); 00076 static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value ); 00077 00078 private: 00079 static QComboBox *comboBox( QWidget *editor, QWidget *parent ); 00080 static QListWidget *listWidget( QWidget *editor, QWidget *parent ); 00081 00082 public slots: 00083 void selectFileName(); 00084 void selectDate(); 00085 void loadUrl( const QString & ); 00086 void loadPixmap( const QString & ); 00087 void updateUrl(); 00088 void updateColor(); 00089 00090 private: 00091 QgsVectorLayer *mLayer; 00092 int mIdx; 00093 }; 00094 00095 class QgsStringRelay : public QObject 00096 { 00097 Q_OBJECT 00098 00099 public: 00100 00101 QgsStringRelay( QObject* parent = NULL ) 00102 : QObject( parent ) {} 00103 00104 void appendProxy( QWidget* proxy ) { mProxyList << proxy; } 00105 00106 public slots: 00107 void changeText(); 00108 void changeText( QString str ); 00109 00110 signals: 00111 void textChanged( QString ); 00112 00113 private: 00114 QList<QWidget*> mProxyList; 00115 }; 00116 00117 #endif