34
34
35
35
class CORE_EXPORT QgsUnitTypes
36
36
{
37
+ Q_GADGET
38
+
37
39
public:
38
40
39
41
// ! Units of distance
@@ -102,89 +104,89 @@ class CORE_EXPORT QgsUnitTypes
102
104
103
105
/* * Returns the type for a distance unit.
104
106
*/
105
- static DistanceUnitType unitType ( DistanceUnit unit );
107
+ Q_INVOKABLE static DistanceUnitType unitType ( DistanceUnit unit );
106
108
107
109
/* * Encodes a distance unit to a string.
108
110
* @param unit unit to encode
109
111
* @returns encoded string
110
112
* @see decodeDistanceUnit()
111
113
*/
112
- static QString encodeUnit ( QgsUnitTypes::DistanceUnit unit );
114
+ Q_INVOKABLE static QString encodeUnit ( QgsUnitTypes::DistanceUnit unit );
113
115
114
116
/* * Decodes a distance unit from a string.
115
117
* @param string string to decode
116
118
* @param ok optional boolean, will be set to true if string was converted successfully
117
119
* @returns decoded units
118
120
* @see encodeUnit()
119
121
*/
120
- static QgsUnitTypes::DistanceUnit decodeDistanceUnit ( const QString& string, bool *ok = 0 );
122
+ Q_INVOKABLE static QgsUnitTypes::DistanceUnit decodeDistanceUnit ( const QString& string, bool *ok = 0 );
121
123
122
124
/* * Returns a translated string representing a distance unit.
123
125
* @param unit unit to convert to string
124
126
* @see stringToDistanceUnit()
125
127
*/
126
- static QString toString ( QgsUnitTypes::DistanceUnit unit );
128
+ Q_INVOKABLE static QString toString ( QgsUnitTypes::DistanceUnit unit );
127
129
128
130
/* * Converts a translated string to a distance unit.
129
131
* @param string string representing a distance unit
130
132
* @param ok optional boolean, will be set to true if string was converted successfully
131
133
* @see toString()
132
134
*/
133
- static QgsUnitTypes::DistanceUnit stringToDistanceUnit ( const QString& string, bool *ok = 0 );
135
+ Q_INVOKABLE static QgsUnitTypes::DistanceUnit stringToDistanceUnit ( const QString& string, bool *ok = 0 );
134
136
135
137
/* * Returns the conversion factor between the specified distance units.
136
138
* @param fromUnit distance unit to convert from
137
139
* @param toUnit distance unit to convert to
138
140
* @returns multiplication factor to convert between units
139
141
*/
140
- static double fromUnitToUnitFactor ( QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit );
142
+ Q_INVOKABLE static double fromUnitToUnitFactor ( QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit );
141
143
142
144
// AREAL UNITS
143
145
144
146
/* * Returns the type for an areal unit.
145
147
*/
146
- static DistanceUnitType unitType ( AreaUnit unit );
148
+ Q_INVOKABLE static DistanceUnitType unitType ( AreaUnit unit );
147
149
148
150
/* * Encodes an areal unit to a string.
149
151
* @param unit unit to encode
150
152
* @returns encoded string
151
153
* @see decodeAreaUnit()
152
154
*/
153
- static QString encodeUnit ( AreaUnit unit );
155
+ Q_INVOKABLE static QString encodeUnit ( AreaUnit unit );
154
156
155
157
/* * Decodes an areal unit from a string.
156
158
* @param string string to decode
157
159
* @param ok optional boolean, will be set to true if string was converted successfully
158
160
* @returns decoded units
159
161
* @see encodeUnit()
160
162
*/
161
- static AreaUnit decodeAreaUnit ( const QString& string, bool *ok = 0 );
163
+ Q_INVOKABLE static AreaUnit decodeAreaUnit ( const QString& string, bool *ok = 0 );
162
164
163
165
/* * Returns a translated string representing an areal unit.
164
166
* @param unit unit to convert to string
165
167
* @see stringToAreaUnit()
166
168
*/
167
- static QString toString ( AreaUnit unit );
169
+ Q_INVOKABLE static QString toString ( AreaUnit unit );
168
170
169
171
/* * Converts a translated string to an areal unit.
170
172
* @param string string representing an areal unit
171
173
* @param ok optional boolean, will be set to true if string was converted successfully
172
174
* @see toString()
173
175
*/
174
- static AreaUnit stringToAreaUnit ( const QString& string, bool *ok = 0 );
176
+ Q_INVOKABLE static AreaUnit stringToAreaUnit ( const QString& string, bool *ok = 0 );
175
177
176
178
/* * Returns the conversion factor between the specified areal units.
177
179
* @param fromUnit area unit to convert from
178
180
* @param toUnit area unit to convert to
179
181
* @returns multiplication factor to convert between units
180
182
*/
181
- static double fromUnitToUnitFactor ( AreaUnit fromUnit, AreaUnit toUnit );
183
+ Q_INVOKABLE static double fromUnitToUnitFactor ( AreaUnit fromUnit, AreaUnit toUnit );
182
184
183
185
/* * Converts a distance unit to its corresponding area unit, eg meters to square meters
184
186
* @param distanceUnit distance unit to convert
185
187
* @return matching areal unit
186
188
*/
187
- static AreaUnit distanceToAreaUnit ( QgsUnitTypes::DistanceUnit distanceUnit );
189
+ Q_INVOKABLE static AreaUnit distanceToAreaUnit ( QgsUnitTypes::DistanceUnit distanceUnit );
188
190
189
191
// ANGULAR UNITS
190
192
@@ -193,35 +195,35 @@ class CORE_EXPORT QgsUnitTypes
193
195
* @returns encoded string
194
196
* @see decodeAngleUnit()
195
197
*/
196
- static QString encodeUnit ( AngleUnit unit );
198
+ Q_INVOKABLE static QString encodeUnit ( AngleUnit unit );
197
199
198
200
/* * Decodes an angular unit from a string.
199
201
* @param string string to decode
200
202
* @param ok optional boolean, will be set to true if string was converted successfully
201
203
* @returns decoded units
202
204
* @see encodeUnit()
203
205
*/
204
- static AngleUnit decodeAngleUnit ( const QString& string, bool *ok = 0 );
206
+ Q_INVOKABLE static AngleUnit decodeAngleUnit ( const QString& string, bool *ok = 0 );
205
207
206
208
/* * Returns a translated string representing an angular unit.
207
209
* @param unit unit to convert to string
208
210
*/
209
- static QString toString ( AngleUnit unit );
211
+ Q_INVOKABLE static QString toString ( AngleUnit unit );
210
212
211
213
/* * Returns the conversion factor between the specified angular units.
212
214
* @param fromUnit angle unit to convert from
213
215
* @param toUnit angle unit to convert to
214
216
* @returns multiplication factor to convert between units
215
217
*/
216
- static double fromUnitToUnitFactor ( AngleUnit fromUnit, AngleUnit toUnit );
218
+ Q_INVOKABLE static double fromUnitToUnitFactor ( AngleUnit fromUnit, AngleUnit toUnit );
217
219
218
220
/* * Returns an angle formatted as a friendly string.
219
221
* @param angle angle to format
220
222
* @param decimals number of decimal places to show
221
223
* @param unit unit of angle
222
224
* @returns formatted angle string
223
225
*/
224
- static QString formatAngle ( double angle, int decimals, AngleUnit unit );
226
+ Q_INVOKABLE static QString formatAngle ( double angle, int decimals, AngleUnit unit );
225
227
226
228
// RENDER UNITS
227
229
@@ -230,15 +232,15 @@ class CORE_EXPORT QgsUnitTypes
230
232
* @returns encoded string
231
233
* @see decodeRenderUnit()
232
234
*/
233
- static QString encodeUnit ( RenderUnit unit );
235
+ Q_INVOKABLE static QString encodeUnit ( RenderUnit unit );
234
236
235
237
/* * Decodes a render unit from a string.
236
238
* @param string string to decode
237
239
* @param ok optional boolean, will be set to true if string was converted successfully
238
240
* @returns decoded units
239
241
* @see encodeUnit()
240
242
*/
241
- static RenderUnit decodeRenderUnit ( const QString& string, bool *ok = 0 );
243
+ Q_INVOKABLE static RenderUnit decodeRenderUnit ( const QString& string, bool *ok = 0 );
242
244
243
245
};
244
246
0 commit comments