/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2012  Georg Rudoy
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 **********************************************************************/

#pragma once

#include <QObject>
#include <QHash>
#include "message.h"

class QAbstractItemModel;
class QStandardItemModel;
class QStandardItem;

namespace LeechCraft
{
namespace Snails
{
	class MailModelManager : public QObject
	{
		Q_OBJECT

		QStandardItemModel *Model_;
		QHash<QByteArray, QStandardItem*> MailID2Item_;

		QStringList CurrentFolder_;
	public:
		enum MailColumns
		{
			From,
			Subj,
			Date,
			Size,
			Max
		};

		enum MailRole
		{
			ID = Qt::UserRole + 1,
			Sort,
			ReadStatus
		};

		MailModelManager (QObject* = 0);

		QAbstractItemModel* GetModel () const;
		void UpdateReadStatus (const QByteArray&, bool);

		void SetCurrentFolder (const QStringList&);
	public slots:
		void clear ();

		void appendMessages (const QList<Message_ptr>&);
		void replaceMessages (const QList<Message_ptr>&);
	};
}
}
