Changeset View
Changeset View
Standalone View
Standalone View
src/KPropertyUnit_p.cpp
Show All 16 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | * Boston, MA 02110-1301, USA. | 19 | * Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "KPropertyUnit_p.h" | 22 | #include "KPropertyUnit_p.h" | ||
23 | #include "kproperty_debug.h" | 23 | #include "kproperty_debug.h" | ||
24 | 24 | | |||
25 | #ifdef KPROPERTY_WIDGET | ||||
25 | #include <QTransform> | 26 | #include <QTransform> | ||
27 | #endif | ||||
28 | | ||||
26 | #include <QLocale> | 29 | #include <QLocale> | ||
27 | 30 | | |||
28 | #include <cmath> | 31 | #include <cmath> | ||
29 | 32 | | |||
30 | // ensure the same order as in KPropertyUnit::Unit | 33 | // ensure the same order as in KPropertyUnit::Unit | ||
31 | static const char* const unitNameList[KPropertyUnit::TypeCount] = | 34 | static const char* const unitNameList[KPropertyUnit::TypeCount] = | ||
32 | { | 35 | { | ||
33 | "mm", | 36 | "mm", | ||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Line(s) | 342 | { | |||
365 | else if (type == QLatin1String("rad")) | 368 | else if (type == QLatin1String("rad")) | ||
366 | return val * 180 / M_PI; | 369 | return val * 180 / M_PI; | ||
367 | else if (type == QLatin1String("grad")) | 370 | else if (type == QLatin1String("grad")) | ||
368 | return val * 0.9; | 371 | return val * 0.9; | ||
369 | 372 | | |||
370 | return defaultVal; | 373 | return defaultVal; | ||
371 | } | 374 | } | ||
372 | 375 | | |||
376 | #ifdef KPROPERTY_WIDGET | ||||
373 | qreal KPropertyUnit::approxTransformScale(const QTransform &t) | 377 | qreal KPropertyUnit::approxTransformScale(const QTransform &t) | ||
374 | { | 378 | { | ||
375 | return std::sqrt(t.determinant()); | 379 | return std::sqrt(t.determinant()); | ||
376 | } | 380 | } | ||
377 | 381 | | |||
378 | void KPropertyUnit::adjustByPixelTransform(const QTransform &t) | 382 | void KPropertyUnit::adjustByPixelTransform(const QTransform &t) | ||
379 | { | 383 | { | ||
380 | m_pixelConversion *= approxTransformScale(t); | 384 | m_pixelConversion *= approxTransformScale(t); | ||
381 | } | 385 | } | ||
386 | #endif | ||||
382 | 387 | | |||
383 | #ifndef QT_NO_DEBUG_STREAM | 388 | #ifndef QT_NO_DEBUG_STREAM | ||
384 | QDebug operator<<(QDebug debug, const KPropertyUnit &unit) | 389 | QDebug operator<<(QDebug debug, const KPropertyUnit &unit) | ||
385 | { | 390 | { | ||
386 | #ifndef NDEBUG | 391 | #ifndef NDEBUG | ||
387 | debug.nospace() << unit.symbol(); | 392 | debug.nospace() << unit.symbol(); | ||
388 | #else | 393 | #else | ||
389 | Q_UNUSED(unit); | 394 | Q_UNUSED(unit); | ||
390 | #endif | 395 | #endif | ||
391 | return debug.space(); | 396 | return debug.space(); | ||
392 | 397 | | |||
393 | } | 398 | } | ||
394 | #endif | 399 | #endif |