From 7e946f2aa630430ed050ae0cb61beada9452404a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Sun, 28 Jun 2015 12:08:24 +0200 Subject: [PATCH] add license header and copyright --- plugins/deviceplugins/datetime/alarm.cpp | 77 ++++++++++++------- plugins/deviceplugins/datetime/alarm.h | 22 +++++- .../datetime/deviceplugindatetime.cpp | 3 - 3 files changed, 70 insertions(+), 32 deletions(-) diff --git a/plugins/deviceplugins/datetime/alarm.cpp b/plugins/deviceplugins/datetime/alarm.cpp index 31750aae..ae7b25bb 100644 --- a/plugins/deviceplugins/datetime/alarm.cpp +++ b/plugins/deviceplugins/datetime/alarm.cpp @@ -1,3 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2015 Simon Stuerz * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include "alarm.h" #include "loggingcategories.h" @@ -131,16 +151,16 @@ void Alarm::setNoon(const QDateTime &noon) m_noonOffset = calculateOffsetTime(noon); } -void Alarm::setDawn(const QDateTime &dawn) -{ - m_dawnOffset = calculateOffsetTime(dawn); -} - void Alarm::setSunset(const QDateTime &sunset) { m_sunsetOffset = calculateOffsetTime(sunset); } +void Alarm::setDawn(const QDateTime &dawn) +{ + m_dawnOffset = calculateOffsetTime(dawn); +} + void Alarm::setTimeType(const Alarm::TimeType &timeType) { m_timeType = timeType; @@ -156,10 +176,10 @@ void Alarm::setTimeType(const QString &timeType) m_timeType = TimeTypeSunrise; } else if (timeType == "noon") { m_timeType = TimeTypeNoon; - } else if (timeType == "dawn") { - m_timeType = TimeTypeDawn; } else if (timeType == "sunset") { m_timeType = TimeTypeSunset; + } else if (timeType == "dawn") { + m_timeType = TimeTypeDawn; } } @@ -182,25 +202,18 @@ bool Alarm::checkDayOfWeek(const QDateTime &dateTime) switch (offsetTime.date().dayOfWeek()) { case Qt::Monday: return monday(); - break; case Qt::Tuesday: return tuesday(); - break; case Qt::Wednesday: return wednesday(); - break; case Qt::Thursday: return thursday(); - break; case Qt::Friday: return friday(); - break; case Qt::Saturday: return saturday(); - break; case Qt::Sunday: return sunday(); - break; default: return false; } @@ -231,36 +244,36 @@ bool Alarm::checkTimeTypes(const QDateTime &dateTime) bool checkOk = false; switch (m_timeType) { case TimeTypeTime: - qCWarning(dcDateTime) << name() << "wrong time type"; + qCWarning(dcDateTime) << name() << "wrong time type. This should never happen!"; checkOk = false; break; case TimeTypeDusk: if (m_duskOffset == dateTime) { - qCDebug(dcDateTime) << name() << "match dusk with offset" << m_offset; + qCDebug(dcDateTime) << name() << "time:" << dateTime.time().toString() << "matches dusk time" << m_duskOffset.time().toString() << "with offset" << m_offset; checkOk = true; } break; case TimeTypeSunrise: if (m_sunriseOffset == dateTime) { - qCDebug(dcDateTime) << name() << "match sunrise with offset" << m_offset; + qCDebug(dcDateTime) << name() << "time:" << dateTime.time().toString() << "matches sunrise time" << m_sunriseOffset.time().toString() << "with offset" << m_offset; checkOk = true; } break; case TimeTypeNoon: if (m_noonOffset == dateTime) { - qCDebug(dcDateTime) << name() << "match noon with offset" << m_offset; - checkOk = true; - } - break; - case TimeTypeDawn: - if (m_dawnOffset == dateTime) { - qCDebug(dcDateTime) << name() << "match dawn with offset" << m_offset; + qCDebug(dcDateTime) << name() << "time:" << dateTime.time().toString() << "matches noon time" << m_noonOffset.time().toString() << "with offset" << m_offset; checkOk = true; } break; case TimeTypeSunset: if (m_sunsetOffset == dateTime) { - qCDebug(dcDateTime) << name() << "match sunset with offset" << m_offset; + qCDebug(dcDateTime) << name() << "time:" << dateTime.time().toString() << "matches sunset time" << m_sunsetOffset.time().toString() << "with offset" << m_offset; + checkOk = true; + } + break; + case TimeTypeDawn: + if (m_dawnOffset == dateTime) { + qCDebug(dcDateTime) << name() << "time:" << dateTime.time().toString() << "matches dawn time" << m_dawnOffset.time().toString() << "with offset" << m_offset; checkOk = true; } break; @@ -274,16 +287,24 @@ void Alarm::validate(const QDateTime &dateTime) { qCDebug(dcDateTime) << name() << "validate..."; - if (!checkDayOfWeek(dateTime)) + if (!checkDayOfWeek(dateTime)) { + qCDebug(dcDateTime) << name() << "check day...FAIL"; return; + } + qCDebug(dcDateTime) << name() << "check day...OK"; // check if should use the given time if (m_timeType == TimeTypeTime) { - if (!checkHour(dateTime)) + if (!checkHour(dateTime)) { + qCDebug(dcDateTime) << name() << "check hour...FAIL"; return; + } + qCDebug(dcDateTime) << name() << "check hour...OK"; - if (!checkMinute(dateTime)) + if (!checkMinute(dateTime)) { + qCDebug(dcDateTime) << name() << "check minute...FAIL"; return; + } qCDebug(dcDateTime) << name() << "time match" << QTime(hours(), minutes()).toString("hh:mm") << "with offset" << m_offset; emit alarm(); diff --git a/plugins/deviceplugins/datetime/alarm.h b/plugins/deviceplugins/datetime/alarm.h index 8c7b12c5..dc473e1c 100644 --- a/plugins/deviceplugins/datetime/alarm.h +++ b/plugins/deviceplugins/datetime/alarm.h @@ -1,3 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2015 Simon Stuerz * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #ifndef ALARM_H #define ALARM_H @@ -55,8 +75,8 @@ public: void setDusk(const QDateTime &dusk); void setSunrise(const QDateTime &sunrise); void setNoon(const QDateTime &noon); - void setDawn(const QDateTime &dawn); void setSunset(const QDateTime &sunset); + void setDawn(const QDateTime &dawn); void setTimeType(const TimeType &timeType); void setTimeType(const QString &timeType); diff --git a/plugins/deviceplugins/datetime/deviceplugindatetime.cpp b/plugins/deviceplugins/datetime/deviceplugindatetime.cpp index e9432e28..9107ddf8 100644 --- a/plugins/deviceplugins/datetime/deviceplugindatetime.cpp +++ b/plugins/deviceplugins/datetime/deviceplugindatetime.cpp @@ -450,9 +450,6 @@ void DevicePluginDateTime::onConfigValueChanged(const QString ¶mName, const } else { qCWarning(dcDateTime) << "could not set new timezone" << value.toString() << ". keeping old time zone:" << m_timeZone; } - - // update everything with the new timezone - onTimeout(); } void DevicePluginDateTime::validateTimeTypes(const QDateTime &dateTime)