/* * QCameraDropSite.cpp * $Id: QCameraDropSite.cpp,v 1.4 2001/11/15 16:54:53 guenth Exp $ * * Copyright (C) 1999, 2000 Markus Janich * * 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 * * As a special exception to the GPL, the QGLViewer authors (Markus * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas * Woerner) give permission to link this program with Qt (non-)commercial * edition, and distribute the resulting executable, without including * the source code for the Qt (non-)commercial edition in the source * distribution. * */ // Description : Class QCameraDropSite // Purpose : Provides a drag'n drop area for cameras // Qt /////// #include #include #include // System /////////// // Own /////////// #include "QCameraDropSite.h" #include "QCameraDrag.h" #include "pictures/dragcamera.xpm" // Function : QCameraDropSite // Parameters: CCamera *pCamera, QWidget *parent, const char *sName // Purpose : default constructor. // Comments : See docu for details. QCameraDropSite::QCameraDropSite(QWidget *parent, const char *sName) : QLabel(parent, sName ), m_pCamera(NULL) /*********************************************************************/ { QPixmap dragCameraPix((const char **)dragcamera_xpm); if (!(dragCameraPix.isNull())) setPixmap( dragCameraPix ); else setText("Drag and Drop"); setAlignment(Qt::AlignCenter); setFrameStyle(QFrame::Raised + QFrame::WinPanel); setAcceptDrops(TRUE); } // Function : ~QCameraDropSite // Parameters: // Purpose : default destructor. // Comments : See docu for details. QCameraDropSite::~QCameraDropSite() /*********************************************************************/ { /* nothing else to do */ } // Function : dragEnterEvent // Parameters: QDragEnterEvent *pqEvent // Purpose : handles QDragEnterEvents. // Comments : See docu for details. void QCameraDropSite::dragEnterEvent(QDragEnterEvent *pqEvent) /*********************************************************************/ { if (!isEnabled()) return; if ( QCameraDrag::canDecode(pqEvent)) { pqEvent->accept(); setFrameStyle(QFrame::Sunken + QFrame::WinPanel); } } // Function : dragLeaveEvent // Parameters: QDragLeaveEvent *pqEvent // Purpose : handles QDragLeaveEvents. // Comments : See docu for details. void QCameraDropSite::dragLeaveEvent(QDragLeaveEvent *pqEvent) /*********************************************************************/ { setFrameStyle(QFrame::Raised + QFrame::WinPanel); } // Function : dropEvent // Parameters: QDropEvent *pqEvent // Purpose : handles QDropEvents. // Comments : See docu for details. void QCameraDropSite::dropEvent(QDropEvent *pqEvent) /*********************************************************************/ { CCamera cCamera; if (pqEvent->source() != this) { if ( QCameraDrag::decode(pqEvent, cCamera) ) { emit(sigCameraDropped(cCamera)); } } setFrameStyle(QFrame::Raised + QFrame::WinPanel); } // Function : mousePressEvent // Parameters: QMouseEvent *pqEvent // Purpose : handles mouse press events. // Comments : See docu for details. void QCameraDropSite::mousePressEvent(QMouseEvent *pqEvent) /*********************************************************************/ { QDragObject *pqDragObject; if (m_pCamera !=NULL) { setFrameStyle(QFrame::Sunken + QFrame::WinPanel); pqDragObject = new QCameraDrag(m_pCamera, this); pqDragObject->setPixmap(QPixmap(QCameraDrag::picture_xpm),QPoint(8,8)); pqDragObject->dragCopy(); } } // Function : mouseReleaseEvent // Parameters: QMouseEvent *pqEvent // Purpose : handles mouse release events. // Comments : See docu for details. void QCameraDropSite::mouseReleaseEvent(QMouseEvent *pqEvent) /*********************************************************************/ { setFrameStyle(QFrame::Raised + QFrame::WinPanel); }