/* ============================================================
 * File  : tetrahedron.cpp
 * Author: Stephane Gibault
 * Date  : Sun Feb 4 2007
 * Description :
 *
 * 
 *  (C) 2007 by Stephane Gibault
 *
 * 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, 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.
 *
 * ============================================================ */
#include <QtGui>
#include "diapo.h"

diapo::diapo ( QWidget * parent )
    : QLabel(parent)
{
	//myparent = parent;
	this->setMouseTracking(true);
	this->setScaledContents(true);
	this->setAutoFillBackground(false);
}

/*void diapo::mousePressEvent ( QMouseEvent * event ) 
{
}

void diapo::mouseReleaseEvent ( QMouseEvent * event )  
{
}*/

void diapo::leaveEvent ( QEvent * event )
{
	if ( this->width() == 107 )
	{
		this->setGeometry( this->geometry().left() + 5, 0, 97, 77);
	}
}

void diapo::mouseMoveEvent ( QMouseEvent * event )
{
	if ( this->width() == 97 )
	{
		this->setGeometry( this->geometry().left() - 5, 0, 107, 87);
	}
	if (!(event->buttons() & Qt::LeftButton)) return;
	//
	QMimeData *mimedata = new QMimeData;
	mimedata->setText("$$DRAGINTO$$$");
	QDrag *drag = new QDrag(this);
 	drag->setMimeData(mimedata);
	drag->setPixmap(*this->pixmap());
	drag->exec(Qt::MoveAction);
}

Qt::DropActions diapo::supportedDropActions () const
{
	// returns what actions are supported when dropping
	return Qt::CopyAction | Qt::MoveAction;
}

