#ifndef INTERVAL_DIALOG_H
#define INTERVAL_DIALOG_H

#include "qt_version.h"

#if QT_VERSION < 0x040000
#include <qmainwindow.h>
#include <qpushbutton.h>
#include "QbTimeWidgets.h"
#else
#include <QMainWindow>
#include <QPushButton>
#include "QbTimeWidgets_qt4.h"
#endif

#include "IntervalSlider.h"

class IntervalDialog : public QMainWindow
{
	Q_OBJECT

	public:
		
		IntervalDialog(QWidget* parent);
		
		void setAsTimeInterval(double tmin, double tmax, double currentTmin, double currentTmax);
		
		void setAsXInterval(double tmin, double tmax, double currentTmin, double currentTmax);
		
	signals:
		
		void rescale(double tmin, double tmax);
		
	public slots:
		
		void apply();
		
		void updateFields(double start, double end);
		
		void updateSlider();
		
		void dismiss();
		
		void reset();
		
	protected:
		
		QWidget * tAxisWidget;
		QWidget * xAxisWidget;
		
		QbDateTimeWidget * startTimeWidget;
		QbDateTimeWidget * endTimeWidget;
		QguWLinput * startXWidget;
		QguWLinput * endXWidget;
		IntervalSlider * slider;
		
		bool isTimeInterval;
		
	protected slots:
		
		void closeEvent(QCloseEvent * e)
		{
#if QT_VERSION < 0x040000
			hide();
#else
			setVisible(false);
#endif
		}
};

#endif
