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

#define ACTIVITYTREE__H

#include "core/types.h"

#include <QTreeView>

#include <qglobal.h>

class ActivityModel;

class ActivityTree : public QTreeView
{
	Q_OBJECT

	public:
		enum ActivityCols
		{
			dateCol = 0,
			nameCol = 1,
			distanceCol = 2,
			durationCol = 3,
			avgPaceCol = 4,
			avgSpeedCol = 5,
			maxSpeedCol = 6,
			energyConsCol = 7,
			avgHRCol = 8,
			maxHRCol = 9,
			avgCadenceCol = 10,
			ascentCol = 11,
			descentCol = 12,

			lastActivityCol
		};

	public:
		ActivityTree(QWidget* parent = NULL);

	signals:
		void selectedActivityChanged();
		void activityChanged(Activity*, int column);

	public:
		Activities selectedActivities();

		void add(Activity* a);
		void remove(Activity* a);
		void clear();
		void selectActivity(const Activity* a);
		void selectFirstActivity();

	public slots:
		void onSelectionChanged(const QItemSelection&, const QItemSelection&);
		void activityChanged();
		void onDataChanged(const QModelIndex& from, const QModelIndex&);

	protected:
		ActivityModel* sourceModel();
		const ActivityModel* sourceModel() const;
};

#endif
