bool QLineEdit::event( QEvent * e ) { #if 0 // it works, but we'll wait with enabling it. if ( !e ) return QWidget::event( e ); if ( e->type() == Event_DragEnter ) { if ( ((QDragEnterEvent *) e)->provides( "text/plain" ) ) { ((QDragEnterEvent *) e)->accept( rect() ); return TRUE; } } else if ( e->type() == Event_DragLeave ) { return TRUE; } else if ( e->type() == Event_Drop ) { QDropEvent * de = (QDropEvent *) e; QString str; if ( QTextDrag::decode( de, str ) ) { if ( !hasMarkedText() ) { int margin = frame() ? 2 : 0; setCursorPosition( xPosToCursorPos( &tbuf[(int)offset], fontMetrics(), de->pos().x() - margin, width() - 2*margin ) ); } insert( str ); de->accept(); } else { de->ignore(); } return TRUE; } #endif return QWidget::event( e ); }
/** Redefined to forward events to children. */ bool TabPlaylist::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::DragEnter) { event->accept(); return true; } else if (event->type() == QEvent::Drop) { QDropEvent *de = static_cast<QDropEvent*>(event); if (de->source() == NULL) { // Drag & Drop comes from another application but has landed in the playlist area de->ignore(); QDropEvent *d = new QDropEvent(de->pos(), de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); _mainWindow->dispatchDrop(d); return true; } else { if (obj == cornerWidget()) { auto p = this->addPlaylist(); p->forceDrop(de); } else { currentPlayList()->forceDrop(de); } return true; } } return QTabWidget::eventFilter(obj, event); }
bool ArticleViewPrivate::eventFilter(QObject * obj, QEvent * event) { //qDebug() << "eventFilter" << obj << event; const AbstractBibliographicModel * model = qobject_cast< const AbstractBibliographicModel * >(view ? origin(view->model()) : 0); // Only filter the view's events if (model && obj == view->viewport()) { switch (event->type()) { case QEvent::DragMove: case QEvent::DragEnter: { QDropEvent * e = static_cast< QDropEvent * >(event); if ((dropping = model->acceptsDrop(e->mimeData()))) { view->viewport()->update(); e->accept(); } else { e->ignore(); } //qDebug() << "---" << dropping; return true; break; } case QEvent::DragLeave: dropping = false; view->viewport()->update(); break; case QEvent::Drop: dropping = false; view->viewport()->update(); break; default: break; } } return QObject::eventFilter(obj, event); }