/***************************************************************************
 *   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(ATHLETELOGPAGE__H)

#define ATHLETELOGPAGE__H

#include "ui_athletelogpage.h"

#include "core/category.h"
#include "core/equipment.h"

#include <QWidget>

class Profile;
class AthleteLog;

class QPoint;

class AthleteLogPage: public QWidget, public Ui::AthleteLogPage
{
	Q_OBJECT

	public:
		AthleteLogPage(QWidget* parent = NULL);

	signals:
		void selectedAthleteLogChanged(AthleteLog*);
		void athleteLogChanged();
		void dateChanged();
		void weightChanged();
		void bodyFatPercentageChanged();
		void restingHeartRateChanged();
		void maxHeartRateChanged();
		void bloodPressureSystolicChanged();
		void bloodPressureDiastolicChanged();
		void energyConsumptionChanged();
		void sleepDurationChanged();
		void notesChanged();
		void photoChanged();
		void contextMenuRequested(const QPoint&);

	public:
		void loadConfig();
		void saveConfig();

		void clear();

		void setProfile(Profile* p);

		AthleteLogs selectedAthleteLogs();

	public slots:
		bool on_removeAthleteLogButton_clicked(bool);
		void onContextMenu(const QPoint& p);
		void onSelectAll();

	protected:
		void init();
		void setupConnections();
		void initTree();

	protected slots:
		void onHeaderContextMenu(const QPoint& p);
		void on_athleteLogTree_selectedAthleteLogChanged();
		void on_athleteLogTree_athleteLogChanged(AthleteLog* a, int col);
		void on_addAthleteLogButton_clicked(bool);

		void on_athleteLogDateEdit_dateChanged(const QDate& date);
		void on_weightSpin_valueChanged(double val);
		void on_bodyFatSpin_valueChanged(int val);
		void on_hrRestingSpin_valueChanged(int val);
		void on_hrMaxSpin_valueChanged(int val);
		void on_bpSystolicSpin_valueChanged(int val);
		void on_bpDiastolicSpin_valueChanged(int val);
		void on_energyConsumptionSpin_valueChanged(int val);
		void on_sleepDurationTime_timeChanged(const QTime& time);
		void on_athleteLogNotesEdit_textChanged();
		void on_athleteLogPhotoButton_clicked(bool);

	private:
		Profile* m_Profile;
};

#endif
