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

#define SPINBOXDELEGATE__H

#include <QStyledItemDelegate>
#include <QString>

class QWidget;
class QSize;

class SpinBoxDelegate : public QStyledItemDelegate
{
	public:
		explicit SpinBoxDelegate(QObject* parent, int min = 0, int max = 100, int singleStep = 1, const QString& prefix = QString(), const QString& suffix = QString());

	public:
		void setEditorData(QWidget* editor, const QModelIndex& index) const;
		void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
		void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
		QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
		QSize sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const { return QSize(0, 22); }

	private:
		int m_Min;
		int m_Max;
		int m_SingleStep;
		QString m_Prefix;
		QString m_Suffix;
};

#endif
