/***************************************************************************
 *   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            *
 ***************************************************************************/

#include "veneer/messagebox.h"

#include <kmessagebox.h>

#include <QDebug>
#include <QString>
#include <QStringList>
#include <QWidget>
#include <QMessageBox>

namespace Veneer
{
	int messageBoxQuestionYesNo(QWidget* parent, const QString& text, const QString& caption, const QString& textYes, const QString& textNo, const QString& dontAskAgainName)
	{
		int result = KMessageBox::questionYesNo(parent,
				text,
				caption,
				KGuiItem(textYes, KStandardGuiItem::yes().iconName()),
				KGuiItem(textNo, KStandardGuiItem::no().iconName()),
				dontAskAgainName);

		return result == KMessageBox::Yes ? QMessageBox::Yes : QMessageBox::No;
	}

	int messageBoxQuestionYesNoCancel(QWidget* parent, const QString& text, const QString& caption, const QString& textYes, const QString& textNo, const QString& textCancel, const QString& dontAskAgainName)
	{
		switch(KMessageBox::questionYesNoCancel(parent,
				text,
				caption,
				KGuiItem(textYes, KStandardGuiItem::yes().iconName()),
				KGuiItem(textNo, KStandardGuiItem::no().iconName()),
				KGuiItem(textCancel, KStandardGuiItem::cancel().iconName()),
				dontAskAgainName))
		{
			case KMessageBox::Yes:
				return QMessageBox::Yes;

			case KMessageBox::No:
				return QMessageBox::No;

			default:
				break;
		}

		return QMessageBox::Cancel;
	}

	int messageBoxQuestionYesNoList(QWidget* parent, const QString& text, const QStringList& list, const QString& caption, const QString& textContinue, const QString& textCancel, const QString& dontAskAgainName)
	{
		int result = KMessageBox::questionYesNoList(parent,
				text,
				list,
				caption,
				KGuiItem(textContinue, KStandardGuiItem::yes().iconName()),
				KGuiItem(textCancel, KStandardGuiItem::no().iconName()),
				dontAskAgainName);

		return result == KMessageBox::Yes ? QMessageBox::Yes : QMessageBox::No;
	}

	void messageBoxInformation(QWidget* parent, const QString& text, const QString& caption, const QString& dontShowAgainName )
	{
		KMessageBox::information(parent, text, caption, dontShowAgainName);
	}

	void messageBoxError(QWidget* parent, const QString& text, const QString& caption)
	{
		KMessageBox::error(parent, text, caption);
	}

}
