/***************************************************************************
 *   Copyright (C) 2010 by Volker Lanz <vl@fidra.de>                       *
 *                                                                         *
 *   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 2 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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
 ***************************************************************************/

#if !defined(ATHLETELOG__H)

#define ATHLETELOG__H

#include "core/types.h"
#include "core/dbitem.h"

#include <qglobal.h>
#include <QDate>
#include <QPixmap>
#include <QString>

class QSqlQuery;

class Profile;

class AthleteLog : public DbItem
{
	friend class Profile;

	public:
		AthleteLog();
		AthleteLog(const QSqlQuery& query, Profile* profile);

	public:
		bool serialize();
		static bool list(Profile* profile, AthleteLogs& result);

		const QDate& date() const { return m_Date; }
		quint32 weight() const { return m_Weight; }
		quint32 bodyFatPercent() const { return m_BodyFatPercent; }
		quint32 restingHeartRate() const { return m_RestingHeartRate; }
		quint32 maxHeartRate() const { return m_MaxHeartRate; }
		quint32 bloodPressureSystolic() const { return m_BloodPressureSystolic; }
		quint32 bloodPressureDiastolic() const { return m_BloodPressureDiastolic; }
		quint32 energyConsumption() const { return m_EnergyConsumption; }
		quint32 sleepDuration() const { return m_SleepDuration; }
		const QString& notes() const { return m_Notes; }
		const QPixmap& photo() const { return m_Photo; }

		void setDate(const QDate& d) { m_Date = d; setDirty(true); }
		void setWeight(quint32 val) { m_Weight = val; setDirty(true); }
		void setBodyFatPercent(quint32 val) { m_BodyFatPercent = val; setDirty(true); }
		void setRestingHeartRate(quint32 val) { m_RestingHeartRate = val; setDirty(true); }
		void setMaxHeartRate(quint32 val) { m_MaxHeartRate = val; setDirty(true); }
		void setBloodPressureSystolic(quint32 val) { m_BloodPressureSystolic = val; setDirty(true); }
		void setBloodPressureDiastolic(quint32 val) { m_BloodPressureDiastolic = val; setDirty(true); }
		void setEnergyConsumption(quint32 val) { m_EnergyConsumption = val; setDirty(true); }
		void setSleepDuration(quint32 val) { m_SleepDuration = val; setDirty(true); }
		void setNotes(const QString& s) { m_Notes = s; setDirty(true); }
		void setPhoto(const QPixmap p) { m_Photo = p; setDirty(true); }

	protected:
		Profile* profile() { return m_Profile; }
		void setProfile(Profile* p) { m_Profile = p; setDirty(true); }

	private:
		Profile* m_Profile;
		QDate m_Date;
		quint32 m_Weight;
		quint32 m_BodyFatPercent;
		quint32 m_RestingHeartRate;
		quint32 m_MaxHeartRate;
		quint32 m_BloodPressureSystolic;
		quint32 m_BloodPressureDiastolic;
		quint32 m_EnergyConsumption;
		quint32 m_SleepDuration; ///< in minutes
		QString m_Notes;
		QPixmap m_Photo;
};

#endif
