summaryrefslogtreecommitdiff
path: root/libsowatch/weathernotification.cpp
blob: 9c9c2e8359e7cc3639a18ea33b333292eebb657c (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
30
31
32
33
34
35
36
#include "weathernotification.h"

using namespace sowatch;

WeatherNotification::WeatherNotification(QObject *parent) :
    Notification(parent)
{
}

Notification::Priority WeatherNotification::priority() const
{
	return Silent;
}

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);
	} else {
		return 0.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));
	}
}