/* * Copyright 2007-2008 Ben Boeckel * * This program 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, either version 3 of the License, or * (at your option) any later version. * * This program 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 this program. If not, see . */ // Header include #include "Time.h" // Pokemod includes #include "Pokemod.h" Time::Time(const Time& time) : Object("Time", time.parent(), time.id()) { *this = time; } Time::Time(const Pokemod* parent, const int id) : Object("Time", parent, id), m_name(""), m_hour(0), m_minute(0) { } Time::Time(const Time& time, const Pokemod* parent, const int id) : Object("Time", parent, id) { *this = time; } Time::Time(const QDomElement& xml, const Pokemod* parent, const int id) : Object("Time", parent, id) { load(xml, id); } void Time::validate() { if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setHour, hour); TEST(setMinute, minute); } void Time::load(const QDomElement& xml, int id) { LOAD_ID(); LOAD(QString, name); LOAD(int, hour); LOAD(int, minute); } QDomElement Time::save() const { SAVE_CREATE(); SAVE(QString, name); SAVE(int, hour); SAVE(int, minute); return xml; } void Time::setName(const QString& name) { m_name = name; emit(changed()); } void Time::setHour(const int hour) { if (24 <= hour) { emit(error(bounds("hour"))); return; } m_hour = hour; emit(changed()); } void Time::setMinute(const int minute) { if (60 <= minute) { emit(error(bounds("minute"))); return; } m_minute = minute; emit(changed()); } QString Time::name() const { return m_name; } int Time::hour() const { return m_hour; } int Time::minute() const { return m_minute; } Time& Time::operator=(const Time& rhs) { if (this == &rhs) return *this; COPY(name); COPY(hour); COPY(minute); return *this; }