示例#1
0
// Eventfilter: Only needed under Windows.
// Without this, files dropped in the line edit have URL-encoding.
// This eventfilter decodes the filenames as needed by KDiff3.
bool OpenDialog::eventFilter(QObject* o, QEvent* e)
{
   if ( e->type()==QEvent::DragEnter )
   {
      QDragEnterEvent* d = static_cast<QDragEnterEvent*>(e);
      d->setAccepted( d->mimeData()->hasUrls() );
      return true;
   }
   if (e->type()==QEvent::Drop)
   {
      QDropEvent* d = static_cast<QDropEvent*>(e);

      if ( !d->mimeData()->hasUrls() )
         return false;

      QList<QUrl> lst = d->mimeData()->urls();

      if ( lst.count() > 0 )
      {
         static_cast<QLineEdit*>(o)->setText( QDir::toNativeSeparators( lst[0].toLocalFile() ) );
         static_cast<QLineEdit*>(o)->setFocus();
      }
       
      return true;
   }
   return false;
}
示例#2
0
bool KDMUsersWidget::eventFilter( QObject *, QEvent *e )
{
	if (e->type() == QEvent::DragEnter) {
		QDragEnterEvent *ee = (QDragEnterEvent *)e;
		ee->setAccepted( K3URLDrag::canDecode( ee ) );
		return true;
	}

	if (e->type() == QEvent::Drop) {
		userButtonDropEvent( (QDropEvent *)e );
		return true;
	}

	return false;
}