Warning, file /plasma/kdeplasma-addons/applets/weather/plugin/util.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef UTIL_H
0008 #define UTIL_H
0009 
0010 // KF
0011 #include <KUnitConversion/Converter>
0012 // Qt
0013 #include <QObject>
0014 
0015 class Util : public QObject
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     explicit Util(QObject *parent = nullptr);
0021 
0022 public:
0023     enum Status {
0024         Normal = 0,
0025         Connecting,
0026         NeedsConfiguration,
0027         Timeout,
0028     };
0029     Q_ENUM(Status);
0030 
0031 public:
0032     /**
0033      * Returns the @p iconName if the current icon theme contains an icon with that name,
0034      * otherwise returns "weather-not-available" (expecting the icon theme to have that in any case).
0035      */
0036     Q_INVOKABLE QString existingWeatherIconName(const QString &iconName) const;
0037 
0038     Q_INVOKABLE QString temperatureToDisplayString(int displayUnitType, double value, int valueUnitType, bool rounded = false, bool degreesOnly = false) const;
0039     Q_INVOKABLE QString valueToDisplayString(int displayUnitType, double value, int valueUnitType, int precision = 0) const;
0040     Q_INVOKABLE QString percentToDisplayString(double value) const;
0041 
0042     static QString nameFromUnitId(KUnitConversion::UnitId unitId);
0043 
0044 private:
0045     static KUnitConversion::Converter m_converter;
0046 };
0047 
0048 #endif