#ifndef IMAGE_VIEW_H
#define IMAGE_VIEW_H

#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include "qad_export.h"


class QAD_EXPORT ImageView: public QGraphicsView
{
	Q_OBJECT
	Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
public:
	ImageView(QWidget * parent = 0);
	~ImageView();

	void setImage(const QImage & i);
	void setImage(const QByteArray & i);
	QByteArray image() const {return im_data;}
	QPixmap pixmap() const;

	void clear();

private:
	void mouseDoubleClickEvent(QMouseEvent * e);
	void mousePressEvent(QMouseEvent * e);
	void mouseMoveEvent(QMouseEvent * e);
//	void wheelEvent(QWheelEvent * e);
	bool eventFilter(QObject * o, QEvent * e);
	void adjustView();

	QGraphicsPixmapItem item;
	QByteArray im_data;
	QPoint prev_pos;
	bool autofit_;


public slots:
	void autofit();
	void setPixmap(QPixmap pixmap);

signals:
	void clicked(QPointF, Qt::MouseButtons);

};

#endif // IMAGE_VIEW_H
