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

#define ACTIVITYPAGE__H

#include "ui_activitypage.h"

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

#include <QWidget>

class Activity;
class Profile;

class QPoint;

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

	public:
		ActivityPage(QWidget* parent = NULL);

	signals:
		void selectionChanged();
		void nameChanged();
		void categoryChanged();
		void equipmentChanged();
		void temperatureChanged();
		void weatherChanged();
		void windChanged();
		void notesChanged();
		void contextMenuRequested(const QPoint&);

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

		void clear();
		void updateDetails();
		void updateCategories(Categories& cats);
		void updateEquipments(Equipments& eqs);
		Activities selectedActivities();

		void setProfile(Profile* p);

	public slots:
		void showActivity(Activity* activity);
		void showActivitiesForCategory(Category* cat);
		bool onDeleteActivity();
		void onSelectAll();

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

	protected slots:
		void on_activitiesTree_selectedActivityChanged();
		void on_activitiesTree_activityChanged(Activity*, int);

		void on_nameEdit_editingFinished();
		void on_categoryCombo_currentIndexChanged(int);
		void on_equipmentCombo_currentIndexChanged(int);
		void on_temperatureSpin_valueChanged(double);
		void on_weatherCombo_currentIndexChanged(int);
		void on_weatherDescriptionEdit_editingFinished();
		void on_notesEdit_textChanged();
		void onHeaderContextMenu(const QPoint& p);
		void onContextMenu(const QPoint& p);

	private:
		Profile* m_Profile;
};

#endif
