/*
    QAD - Qt ADvanced

    Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser 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 Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef QPICONFIGVALUEWIDGET_H
#define QPICONFIGVALUEWIDGET_H

#include "colorbutton.h"
#include "ecombobox.h"
#include "float.h"
#include "limits.h"
#include "qad_widgets_export.h"
#include "qipedit.h"
#include "qpiconfig.h"
#include "qpointedit.h"
#include "qrectedit.h"
#include "qvariantedit.h"

#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QSpinBox>


class QAD_WIDGETS_EXPORT ConfigValueWidget: public QWidget {
	Q_OBJECT
	friend class QPIConfigWidget;
	friend class QPIConfigNewDialog;

public:
	ConfigValueWidget(QWidget * parent = 0);
	~ConfigValueWidget() { hide(); }

	void setType(const QString & t);
	void setValue(const QString & v);
	void setEntry(QPIConfig::Entry * e) {
		value     = e->value();
		full_name = e->_full_name;
		comment   = e->comment();
		setType(e->type());
	}

private:
	void hideAll() {
		w_string.hide();
		w_list.hide();
		w_bool.hide();
		w_integer.hide();
		w_float.hide();
		w_color.hide();
		w_rect.hide();
		w_point.hide();
		w_ip.hide();
		w_enum.hide();
		w_path.hide();
	}

	QString type, value, full_name, comment;
	bool active;
	QBoxLayout lay;
	CLineEdit w_string;
	StringListEdit w_list;
	ColorButton w_color;
	QCheckBox w_bool;
	QSpinBox w_integer;
	QDoubleSpinBox w_float;
	QRectEdit w_rect;
	QPointEdit w_point;
	QIPEdit w_ip;
	QComboBox w_enum;
	PathEdit w_path;

private slots:
	void valueChanged();

signals:
	void changed(ConfigValueWidget *, QString);
};

#endif // QPICONFIGVALUEWIDGET_H
