blob: ddfd60b59cc3b10d6c5841f060aa0153ff4781ab (
plain)
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
|
#include "weathernotification.h"
using namespace sowatch;
WeatherNotification::WeatherNotification(QObject *parent) :
Notification(parent)
{
}
qreal WeatherNotification::convertTemperature(qreal temp, Unit from, Unit to)
{
if (from == to) {
return temp;
} else if (from == Celsius && to == Fahrenheit) {
return temp * (9.0f/5.0f) + 32.0f;
} else if (from == Fahrenheit && to == Celsius) {
return (temp - 32.0f) * (5.0f/9.0f);
}
}
int WeatherNotification::convertTemperature(int temp, Unit from, Unit to)
{
if (from == to) {
return temp;
} else {
return qRound(convertTemperature(static_cast<qreal>(temp), from, to));
}
}
|