00001 /*************************************************************************** 00002 ** 00003 ** This file is part of geopsy. 00004 ** 00005 ** This file may be distributed and/or modified under the terms of the 00006 ** GNU General Public License version 2 or 3 as published by the Free 00007 ** Software Foundation and appearing in the file LICENSE.GPL included 00008 ** in the packaging of this file. 00009 ** 00010 ** This file is distributed in the hope that it will be useful, but WITHOUT 00011 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 ** more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 ** 00018 ** See http://www.geopsy.org for more information. 00019 ** 00020 ** Created : 2004-03-07 00021 ** Authors: 00022 ** Marc Wathelet 00023 ** Marc Wathelet (ULg, Liège, Belgium) 00024 ** Marc Wathelet (LGIT, Grenoble, France) 00025 ** 00026 ***************************************************************************/ 00027 00028 #ifndef SigSelectionDnD_H 00029 #define SigSelectionDnD_H 00030 00031 #include <QtGui> 00032 00033 #include <GeopsyCore.h> 00034 00035 class SigSelectionDnD : public QObject 00036 { 00037 Q_OBJECT 00038 public: 00039 SigSelectionDnD(QWidget * eventSource); 00040 00041 bool eventFilter(QObject *, QEvent * event); 00042 void setDragEnabled(bool b) {_dragEnabled=b;} 00043 void setDropEnabled(bool b); 00044 QWidget * source() {return _src;} 00045 public slots: 00046 void enableFilter(); 00047 void disableFilter(); 00048 signals: 00049 void getSelection(SubSignalPool& sel); 00050 void selectionDropped(const SubSignalPool& sel); 00051 protected: 00052 virtual bool dragEnterEvent(QDragEnterEvent * e); 00053 virtual bool dragMoveEvent(QDragMoveEvent * e); 00054 virtual bool dropEvent(QDropEvent * e); 00055 virtual bool mousePressEvent(QMouseEvent * e); 00056 virtual bool mouseReleaseEvent(QMouseEvent * e); 00057 virtual bool mouseMoveEvent(QMouseEvent * e); 00058 00059 QWidget * _src; 00060 QPoint _mousePressPos; 00061 bool _dropEnabled; 00062 bool _dragEnabled; 00063 enum DragState {Idle, Pressed, Dragging}; 00064 DragState _state; 00065 bool _filterEnabled; 00066 }; 00067 00068 #endif