Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
pushbutton.cpp
Go to the documentation of this file.
1 #include <QDebug>
2 #include <QDropEvent>
3 #include <QFileInfo>
4 #include <QMessageBox>
5 #include <QMimeData>
6 
7 #include "pushbutton.h"
8 
9 PushButton::PushButton( QWidget *parent ) : QPushButton( parent ) {
10 }
11 
13 }
14 
15 void PushButton::dropEvent( QDropEvent *event ) {
16  /* qDebug() << event; */
17  qDebug( ) << "drop event " << event;
18  qDebug( ) << "text?" << event->mimeData( )->text( );
19  /* if (not event->mimeData()->hasText()) return; */
20  if( event->mimeData( )->hasText( ) ) {
21  QString text = event->mimeData( )->text( );
22  if( text == "item" or text == "item2" ) {
23  emit item( text );
24  }
25  QString filePath = text.remove( "file:///" );
26 
27  QFileInfo info( filePath );
28  if( info.isFile( ) ) {
29  emit pixmap( QPixmap( filePath ) );
30  }
31  if( info.isDir( ) ) {
32  emit file( filePath );
33  }
34  return;
35  }
36 }
37 
38 void PushButton::dragEnterEvent( QDragEnterEvent *event ) {
39  /* qDebug() << "drag enter"; */
40  event->accept( );
41 }
42 
43 void PushButton::dragMoveEvent( QDragMoveEvent *event ) {
44  Q_UNUSED( event )
45  /* qDebug() << "drag move"; */
46 }
47 
48 void PushButton::dragLeaveEvent( QDragLeaveEvent *event ) {
49  Q_UNUSED( event )
50  /* qDebug() << "drag leave"; */
51 }
virtual void dragLeaveEvent(QDragLeaveEvent *event) override
Definition: pushbutton.cpp:48
PushButton(QWidget *parent=0)
Definition: pushbutton.cpp:9
void file(const QString &text)
virtual void dragMoveEvent(QDragMoveEvent *event) override
Definition: pushbutton.cpp:43
void item(const QString &text)
virtual void dragEnterEvent(QDragEnterEvent *event) override
Definition: pushbutton.cpp:38
virtual void dropEvent(QDropEvent *event) override
Definition: pushbutton.cpp:15
void pixmap(const QPixmap &pix)