/*************************************************************************** * Copyright (C) 2005 by Tavarez Arnaud Bakoula * * tbakoula@yahoo.fr * * * * 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "marksrc.h" #include "utilities.h" #include "dragmark.h" #include /*! * \brief The constructor * * It constructs an instance of the MarkSrc class * \param i the position of the source; it corresponds * with the state we want to provide * \param parent the parent widget * \param name the widget */ MarkSrc::MarkSrc( uint i, QWidget* parent, const char* name ) : QLabel( parent, name ) { moving = false; setPixmap( theIconLoader->loadIcon( stateToString( (State)i ), KIcon::Toolbar, icon_res ) ); setFixedSize( pixmap()->size() ); } /*! * \brief The destructor */ MarkSrc::~MarkSrc() { // Nothing to do } /*! * \fn MarkSrc::setState( uint state ) * Sets the state of the piece represented by this object. */ void MarkSrc::updateMe() { setPixmap( theIconLoader->loadIcon( stateToString( (State)m_state ), KIcon::Toolbar, icon_res ) ); setFixedSize( pixmap()->size() ); } /*! * The mouse press event handler. */ void MarkSrc::mousePressEvent( QMouseEvent* ) { moving = true; } /*! * The mouse release event handler. */ void MarkSrc::mouseReleaseEvent( QMouseEvent* ) { moving = false; } /*! * The mousemoveevent handler permit to create * an instance of the class DragMark which will be * drag to a MarkSrc object. */ void MarkSrc::mouseMoveEvent( QMouseEvent* ) { if ( moving ) { DragMark* d = new DragMark( (uchar)m_state, this, "mark" ); d->setPixmap( *pixmap(), QPoint(12,12) ); d->dragMove(); moving = false; } }