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

#define EDITPROFILECATEGORIESPAGE__H

#include <QWidget>

#include "ui_editprofilecategoriespage.h"

#include "core/category.h"

#include <QSet>

class Profile;

class QTreeWidgetItem;

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

	public:
		EditProfileCategoriesPage(QWidget* parent = NULL);

	signals:
		void modified();

	public:
		void setupPage(Profile* profile);
		void setupConnections();
		bool accept();
		void reject() {}

	protected:
		QTreeWidgetItem* createCategoryTreeNode(Category& c);

		void updateAndAddCategories(QTreeWidgetItem* item, Category* parent = NULL);
		void reCategorizeActivities(Category* c);
		void removeDeletedCategories(Categories& cats);

	protected slots:
		void onAddCategoryButton(bool);
		void onRemoveCategoryButton(bool);
		void onCategoryItemChanged(QTreeWidgetItem* item, int col);
		void onCategorySelectionChanged();

	private:
		Profile* m_Profile;
		QSet<Category*> m_DeletedCategories;
};

#endif
