File: qgseditorwidgetwrapper.sip

package info (click to toggle)
qgis 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 374,696 kB
  • ctags: 66,263
  • sloc: cpp: 396,139; ansic: 241,070; python: 130,609; xml: 14,884; perl: 1,290; sh: 1,287; sql: 500; yacc: 268; lex: 242; makefile: 168
file content (155 lines) | stat: -rw-r--r-- 5,023 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/***************************************************************************
    qgseditorwidgetwrapper.sip
     --------------------------------------
    Date                 : 20.4.2013
    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.                                   *
 *                                                                         *
 ***************************************************************************/

class QgsEditorWidgetWrapper : QObject
{
%TypeHeaderCode
#include <qgseditorwidgetwrapper.h>
%End

  public:
    /**
     * Create a new widget wrapper
     *
     * @param vl        The layer on which the field is
     * @param fieldIdx  The field which will be controlled
     * @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.
     */
    explicit QgsEditorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor = 0, QWidget* parent /TransferThis/ = 0 );

    QWidget* widget();
    virtual void setConfig( QMap<QString, QVariant> config );
    QVariant config( QString key );
    QgsVectorLayer* layer();

    /**
     * Will be used to access the widget's value. Read the value from the widget and
     * return it properly formatted to be saved in the attribute.
     *
     * If an invalid variant is returned this will be interpreted as no change.
     * Be sure to return a NULL QVariant if it should be set to NULL.
     *
     * @return The current value the widget represents
     */
    virtual QVariant value() = 0;

    /**
     * Access the field index.
     *
     * @return The index of the field you are working on
     *
     * @see layer()
     */
    int fieldIdx();

    /**
     * Access the field.
     *
     * @return The field you are working on
     *
     * @see layer()
     */
    QgsField field();

    /**
     * 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 QgsEditorWidgetWrapper* fromWidget( QWidget* widget );

  protected:
    virtual QWidget* createWidget( QWidget* parent ) = 0 /Factory/;

    virtual void initWidget( QWidget* editor );

  signals:
    /**
     * Emit this signal, whenever the value changed.
     *
     * @param value The new value
     */
    void valueChanged( const QVariant& value );

  public slots:
    /**
     * Will be called when the feature changes
     *
     * Is forwarded to the slot @link{setValue()}
     *
     * @param feature The new feature
     */
    void setFeature( const QgsFeature& feature );

    /**
     * Is called, when the value of the widget needs to be changed. Update the widget representation
     * to reflect the new value.
     *
     * @param value The new value of the attribute
     */
    virtual void setValue( const QVariant& value ) = 0;

    virtual void setEnabled( bool enabled );

  protected slots:
    /**
     * If you emit to this slot in your implementation, an appropriate change notification
     * will be broadcasted. Helper for string type widgets.
     *
     * @param value The value
     */
    void valueChanged( const QString& value );

    /**
     * If you emit to this slot in your implementation, an appropriate change notification
     * will be broadcasted. Helper for int type widgets.
     *
     * @param value The value
     * @note python name valueChangedInt
     */
    void valueChanged( int value ) /PyName=valueChangedInt/;

    /**
     * If you emit to this slot in your implementation, an appropriate change notification
     * will be broadcasted. Helper for double type widgets.
     *
     * @param value The value
     * @note python name valueChangedDouble
     */
    void valueChanged( double value ) /PyName=valueChangedDouble/;

    /**
     * If you emit to this slot in your implementation, an appropriate change notification
     * will be broadcasted. Helper for bool type widgets.
     *
     * @param value The value
     * @note python name valueChangedBool
     */
    void valueChanged( bool value ) /PyName=valueChangedBool/;

    /**
     * If you emit to this slot in your implementation, an appropriate change notification
     * will be broadcasted. Helper for longlong type widgets.
     *
     * @param value The value
     */
    void valueChanged( qlonglong value );

    /**
     * Will call the value() method to determine the emitted value
     */
    void valueChanged();
};