Changeset View
Changeset View
Standalone View
Standalone View
src/KPropertyUnit_p.h
Show All 18 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to | ||
20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
21 | * Boston, MA 02110-1301, USA. | 21 | * Boston, MA 02110-1301, USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #ifndef KPROPERTYUNIT_H | 24 | #ifndef KPROPERTYUNIT_H | ||
25 | #define KPROPERTYUNIT_H | 25 | #define KPROPERTYUNIT_H | ||
26 | 26 | | |||
27 | #include "kproperty_export.h" | 27 | #include "kpropertycore_export.h" | ||
28 | 28 | | |||
29 | #include <QString> | 29 | #include <QString> | ||
30 | #include <QStringList> | 30 | #include <QStringList> | ||
31 | #include <QDebug> | 31 | #include <QDebug> | ||
32 | #include <QMetaType> | 32 | #include <QMetaType> | ||
33 | 33 | | |||
34 | #include <math.h> // for floor | 34 | #include <math.h> // for floor | ||
35 | 35 | | |||
Show All 23 Lines | |||||
59 | * When displaying a value to the user, the value is converted to the user's unit | 59 | * When displaying a value to the user, the value is converted to the user's unit | ||
60 | * of choice, and rounded to a reasonable precision to avoid 0.999999 | 60 | * of choice, and rounded to a reasonable precision to avoid 0.999999 | ||
61 | * | 61 | * | ||
62 | * For implementing the selection of a unit type in the UI use the *ForUi() methods. | 62 | * For implementing the selection of a unit type in the UI use the *ForUi() methods. | ||
63 | * They ensure the same order of the unit types in all places, with the order not | 63 | * They ensure the same order of the unit types in all places, with the order not | ||
64 | * bound to the order in the enum (so ABI-compatible extension is possible) and | 64 | * bound to the order in the enum (so ABI-compatible extension is possible) and | ||
65 | * with the order and scope of listed types controlled by the @c ListOptions parameter. | 65 | * with the order and scope of listed types controlled by the @c ListOptions parameter. | ||
66 | */ | 66 | */ | ||
67 | class KPROPERTY_EXPORT KPropertyUnit | 67 | class KPROPERTYCORE_EXPORT KPropertyUnit | ||
68 | { | 68 | { | ||
69 | public: | 69 | public: | ||
70 | /** Length units supported by Calligra. */ | 70 | /** Length units supported by Calligra. */ | ||
71 | enum Type { | 71 | enum Type { | ||
72 | Millimeter = 0, | 72 | Millimeter = 0, | ||
73 | Point, ///< Postscript point, 1/72th of an Inco | 73 | Point, ///< Postscript point, 1/72th of an Inco | ||
74 | Inch, | 74 | Inch, | ||
75 | Centimeter, | 75 | Centimeter, | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
235 | 235 | | |||
236 | /// parse an angle to its value in degrees | 236 | /// parse an angle to its value in degrees | ||
237 | static qreal parseAngle(const QString &value, qreal defaultVal = 0.0); | 237 | static qreal parseAngle(const QString &value, qreal defaultVal = 0.0); | ||
238 | 238 | | |||
239 | QString toString() { | 239 | QString toString() { | ||
240 | return symbol(); | 240 | return symbol(); | ||
241 | } | 241 | } | ||
242 | 242 | | |||
243 | #ifdef KPROPERTY_WIDGET | ||||
244 | | ||||
243 | /** | 245 | /** | ||
244 | * Get an approximate scale of a unit vector that was converted by | 246 | * Get an approximate scale of a unit vector that was converted by | ||
245 | * the transfomation. | 247 | * the transfomation. | ||
246 | * | 248 | * | ||
247 | * Please note that exact values are guaranteed only for | 249 | * Please note that exact values are guaranteed only for | ||
248 | * combinations of Translate, Rotation and Unifor Scale | 250 | * combinations of Translate, Rotation and Unifor Scale | ||
249 | * matrices. For combinations having shears and perspective the | 251 | * matrices. For combinations having shears and perspective the | ||
250 | * value will be average for the point near CS origin. | 252 | * value will be average for the point near CS origin. | ||
251 | */ | 253 | */ | ||
252 | static qreal approxTransformScale(const QTransform &t); | 254 | static qreal approxTransformScale(const QTransform &t); | ||
253 | 255 | | |||
254 | /** | 256 | /** | ||
255 | * Adjust the unit by pixel transformation applied to the | 257 | * Adjust the unit by pixel transformation applied to the | ||
256 | * describing object. It multiplies the pixel coefficient by the | 258 | * describing object. It multiplies the pixel coefficient by the | ||
257 | * average scale of the matrix. | 259 | * average scale of the matrix. | ||
258 | */ | 260 | */ | ||
259 | void adjustByPixelTransform(const QTransform &t); | 261 | void adjustByPixelTransform(const QTransform &t); | ||
262 | #endif | ||||
260 | 263 | | |||
261 | private: | 264 | private: | ||
262 | Type m_type; | 265 | Type m_type; | ||
263 | qreal m_pixelConversion; | 266 | qreal m_pixelConversion; | ||
264 | }; | 267 | }; | ||
265 | 268 | | |||
266 | #ifndef QT_NO_DEBUG_STREAM | 269 | #ifndef QT_NO_DEBUG_STREAM | ||
267 | KPROPERTY_EXPORT QDebug operator<<(QDebug, const KPropertyUnit &); | 270 | KPROPERTYCORE_EXPORT QDebug operator<<(QDebug, const KPropertyUnit &); | ||
268 | #endif | 271 | #endif | ||
269 | 272 | | |||
270 | Q_DECLARE_METATYPE(KPropertyUnit) | 273 | Q_DECLARE_METATYPE(KPropertyUnit) | ||
271 | Q_DECLARE_OPERATORS_FOR_FLAGS(KPropertyUnit::ListOptions) | 274 | Q_DECLARE_OPERATORS_FOR_FLAGS(KPropertyUnit::ListOptions) | ||
272 | 275 | | |||
273 | #endif | 276 | #endif |