-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add python bindings for QgsWidgetWrapper
Allows the usage of `widget.wrapper()` from a form's python init script.
- ltr-3_40
- ltr-3_34
- ltr-3_28
- ltr-3_22
- ltr-3_16
- ltr-3_10
- ltr-3_4
- ltr-2_18
- ltr-2_14
- final-3_40_2
- final-3_40_1
- final-3_40_0
- final-3_38_3
- final-3_38_2
- final-3_38_1
- final-3_38_0
- final-3_36_3
- final-3_36_2
- final-3_36_1
- final-3_36_0
- final-3_34_14
- final-3_34_13
- final-3_34_12
- final-3_34_11
- final-3_34_10
- final-3_34_9
- final-3_34_8
- final-3_34_7
- final-3_34_6
- final-3_34_5
- final-3_34_4
- final-3_34_3
- final-3_34_2
- final-3_34_1
- final-3_34_0
- final-3_32_3
- final-3_32_2
- final-3_32_1
- final-3_32_0
- final-3_30_3
- final-3_30_2
- final-3_30_1
- final-3_30_0
- final-3_28_15
- final-3_28_14
- final-3_28_13
- final-3_28_12
- final-3_28_11
- final-3_28_10
- final-3_28_9
- final-3_28_8
- final-3_28_7
- final-3_28_6
- final-3_28_5
- final-3_28_4
- final-3_28_3
- final-3_28_2
- final-3_28_1
- final-3_28_0
- final-3_26_3
- final-3_26_2
- final-3_26_1
- final-3_26_0
- final-3_24_3
- final-3_24_2
- final-3_24_1
- final-3_24_0
- final-3_22_16
- final-3_22_15
- final-3_22_14
- final-3_22_13
- final-3_22_12
- final-3_22_11
- final-3_22_10
- final-3_22_9
- final-3_22_8
- final-3_22_7
- final-3_22_6
- final-3_22_5
- final-3_22_4
- final-3_22_3
- final-3_22_2
- final-3_22_1
- final-3_22_0
- final-3_20_3
- final-3_20_2
- final-3_20_1
- final-3_20_0
- final-3_18_3
- final-3_18_2
- final-3_18_1
- final-3_18_0
- final-3_16_16
- final-3_16_15
- final-3_16_14
- final-3_16_13
- final-3_16_12
- final-3_16_11
- final-3_16_10
- final-3_16_9
- final-3_16_8
- final-3_16_7
- final-3_16_6
- final-3_16_5
- final-3_16_4
- final-3_16_3
- final-3_16_2
- final-3_16_1
- final-3_16_0
- final-3_14_16
- final-3_14_15
- final-3_14_1
- final-3_14_0
- final-3_12_3
- final-3_12_2
- final-3_12_1
- final-3_12_0
- final-3_10_14
- final-3_10_13
- final-3_10_12
- final-3_10_11
- final-3_10_10
- final-3_10_9
- final-3_10_8
- final-3_10_7
- final-3_10_6
- final-3_10_5
- final-3_10_4
- final-3_10_3
- final-3_10_2
- final-3_10_1
- final-3_10_0
- final-3_8_3
- final-3_8_2
- final-3_8_1
- final-3_8_0
- final-3_6_3
- final-3_6_2
- final-3_6_1
- final-3_6_0
- final-3_4_15
- final-3_4_14
- final-3_4_13
- final-3_4_12
- final-3_4_11
- final-3_4_10
- final-3_4_9
- final-3_4_8
- final-3_4_7
- final-3_4_6
- final-3_4_5
- final-3_4_4
- final-3_4_3
- final-3_4_2
- final-3_4_1
- final-3_4_0
- final-3_2_3
- final-3_2_2
- final-3_2_1
- final-3_2_0
- final-3_0_3
- final-3_0_2
- final-3_0_1
- final-3_0_0
- final-2_18_28
- final-2_18_27
- final-2_18_26
- final-2_18_25
- final-2_18_24
- final-2_18_23
- final-2_18_22
- final-2_18_21
- final-2_18_20
- final-2_18_19
- final-2_18_18
- final-2_18_17
- final-2_18_16
- final-2_18_15
- final-2_18_14
- final-2_18_13
- final-2_18_12
- final-2_18_11
- final-2_18_10
- final-2_18_9
- final-2_18_8
- final-2_18_7
- final-2_18_6
- final-2_18_5
- final-2_18_4
- final-2_18_3
- final-2_18_2
- final-2_18_1
- final-2_18_0
- final-2_16_3
- final-2_16_2
- final-2_16_1
- final-2_16_0
- final-2_14_22
- final-2_14_21
- final-2_14_20
- final-2_14_19
- final-2_14_18
- final-2_14_17
- final-2_14_16
- final-2_14_15
- final-2_14_14
- final-2_14_13
- final-2_14_12
- final-2_14_11
- final-2_14_10
- final-2_14_9
- final-2_14_8
- final-2_14_7
- final-2_14_6
- final-2_14_5
- final-2_14_4
- final-2_14_3
- final-2_14_2
- final-2_14_1
- final-2_14_0
- final-2_12_3
- final-2_12_2
- final-2_12_1
- final-2_12_0
- final-2_10_1
- final-2_10_0
- archive/master_2
Showing
2 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/*************************************************************************** | ||
qgswidgetwrapper.h | ||
-------------------------------------- | ||
Date : 14.5.2014 | ||
Copyright : (C) 2013 Matthias Kuhn | ||
Email : matthias dot kuhn at gmx dot ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
/** | ||
* Manages an editor widget | ||
* Widget and wrapper share the same parent | ||
* | ||
* A wrapper controls one attribute editor widget and is able to create a default | ||
* widget or use a pre-existent widget. It is able to set the widget to the value implied | ||
* by a field of a vector layer, or return the value it currently holds. Every time it is changed | ||
* it has to emit a valueChanged signal. If it fails to do so, there is no guarantee that the | ||
* changed status of the widget will be saved. | ||
* | ||
*/ | ||
class QgsWidgetWrapper : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include "qgswidgetwrapper.h" | ||
%End | ||
|
||
%ConvertToSubClassCode | ||
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( sipCpp ); | ||
if ( eww ) | ||
sipType = sipType_QgsEditorWidgetWrapper; | ||
else | ||
sipType = 0; | ||
%End | ||
|
||
public: | ||
/** | ||
* Create a new widget wrapper | ||
* | ||
* @param vl The layer on which the field is | ||
* @param editor An editor widget. Can be NULL if one should be autogenerated. | ||
* @param parent A parent widget for this widget wrapper and the created widget. | ||
*/ | ||
QgsWidgetWrapper( QgsVectorLayer* vl, QWidget* editor = 0, QWidget* parent = 0 ); | ||
|
||
/** | ||
* @brief Access the widget managed by this wrapper | ||
* | ||
* @return The widget | ||
*/ | ||
QWidget* widget(); | ||
|
||
|
||
/** | ||
* Will set the config of this wrapper to the specified config. | ||
* | ||
* @param config The config for this wrapper | ||
*/ | ||
void setConfig( const QgsEditorWidgetConfig& config ); | ||
|
||
/** | ||
* Set the context in which this widget is shown | ||
* | ||
* @param context context information | ||
*/ | ||
void setContext( const QgsAttributeEditorContext& context ); | ||
|
||
/** | ||
* Use this inside your overriden classes to access the configuration. | ||
* | ||
* @param key The configuration option you want to load | ||
* @param defaultVal Default value | ||
* | ||
* @return the value assigned to this configuration option | ||
*/ | ||
QVariant config( QString key, QVariant defaultVal = QVariant() ); | ||
|
||
/** | ||
* Returns the whole config | ||
* | ||
* @return The configuration | ||
*/ | ||
const QgsEditorWidgetConfig config(); | ||
|
||
/** | ||
* Returns information about the context in which this widget is shown | ||
* | ||
* @return context information | ||
*/ | ||
const QgsAttributeEditorContext& context(); | ||
|
||
/** | ||
* Access the QgsVectorLayer, you are working on | ||
* | ||
* @return The layer | ||
* | ||
* @see field() | ||
*/ | ||
QgsVectorLayer* layer(); | ||
|
||
/** | ||
* Will return a wrapper for a given widget | ||
* @param widget The widget which was created by a wrapper | ||
* @return The wrapper for the widget or NULL | ||
*/ | ||
static QgsWidgetWrapper* fromWidget( QWidget* widget ); | ||
|
||
protected: | ||
/** | ||
* This method should create a new widget with the provided parent. This will only be called | ||
* if the form did not already provide a widget, so it is not guaranteed to be called! | ||
* You should not do initialisation stuff, which also has to be done for custom editor | ||
* widgets inside this method. Things like filling comboboxes and assigning other data which | ||
* will also be used to make widgets on forms created in the QtDesigner usable should be assigned | ||
* in {@link initWidget(QWidget*)}. | ||
* | ||
* @param parent You should set this parent on the created widget. | ||
* @return A new widget | ||
*/ | ||
virtual QWidget* createWidget( QWidget* parent ) = 0; | ||
|
||
/** | ||
* This method should initialize the editor widget with runtime data. Fill your comboboxes here. | ||
* | ||
* @param editor The widget which will represent this attribute editor in a form. | ||
*/ | ||
virtual void initWidget( QWidget* editor ); | ||
|
||
public slots: | ||
/** | ||
* Is called, when the value of the widget needs to be changed. Update the widget representation | ||
* to reflect the new value. | ||
* | ||
* @param feature The new feature | ||
*/ | ||
virtual void setFeature( const QgsFeature& feature ) = 0; | ||
|
||
/** | ||
* Is used to enable or disable the edit functionality of the managed widget. | ||
* By default this will not change the enabled state of the widget | ||
* | ||
* @param enabled Enable or Disable? | ||
*/ | ||
virtual void setEnabled( bool enabled ); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters