Example #1
0
/*!
  Activate to emit highlighted().
*/
void QTextBrowser::viewportMouseMoveEvent( QMouseEvent* e)
{
#ifndef QT_NO_DRAGANDDROP
    if ( (e->state() & LeftButton) == LeftButton && !d->buttonDown.isEmpty()  ) {
	if ( ( e->globalPos() - d->lastClick ).manhattanLength() > QApplication::startDragDistance() ) {
	    QUrl url ( context(), d->buttonDown, TRUE );
	    QUriDrag* drag = new QUriDrag( this );
	    drag->setUnicodeUris( url.toString() );
	    drag->drag();
	}
	return;
    }
#endif

    if ( e->state() == 0 ) {
	QString act = anchorAt( e->pos() );
	if (d->highlight != act) {
	    if ( !act.isEmpty() ){
		emit highlighted( act );
		d->highlight = act;
	    }
	    else if ( !d->highlight.isEmpty() ) {
		emit highlighted( QString::null );
		d->highlight = QString::null;
	    }
#ifndef QT_NO_CURSOR
	    viewport()->setCursor( d->highlight.isEmpty()?arrowCursor:pointingHandCursor );
#endif
	}
    }

    QTextView::viewportMouseMoveEvent( e );
}
Example #2
0
void DirectoryView::contentsMouseMoveEvent( QMouseEvent* e )
{
    if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
        mousePressed = FALSE;
        QListViewItem *item = itemAt( contentsToViewport(presspos) );
        if ( item ) {
            QString source = fullPath(item);
            if ( QFile::exists(source) ) {
                QUriDrag* ud = new QUriDrag(viewport());
                ud->setUnicodeUris( source );
                if ( ud->drag() )
                    QMessageBox::information( this, "Drag source",
                                              QString("Delete ")+source, "Not implemented" );
            }
        }
    }
}