Example #1
0
void TabBar::mouseMoveEvent(QMouseEvent *event)
{
	if(!(event->buttons() & Qt::LeftButton))
		return;
	if((event->pos() - drag_pos).manhattanLength() < DRAG_OFFSET)
        return;
	fn_begin;
	event->accept();
    QDrag *drag = new QDrag(this);
	/*DEBUG*/
	drag->setObjectName("drag");
	connect(drag, SIGNAL(destroyed()), twutil, SLOT(dumpDestroyed()));
    QMimeData *mimedata = new QMimeData();
    QWidget *widget = currentWidget();
    mimedata->setData("action", "window_drag");
    drag->setMimeData(mimedata);

	QPixmap pixmap = QPixmap::grabWidget(widget).scaledToWidth(
			PIXMAP_MAXWIDTH(widget->width()), Qt::SmoothTransformation);
	DragPixmap *dragpixmap = new DragPixmap(pixmap, PIXMAP_OPACITY, widget);
	connect(drag, SIGNAL(destroyed()), dragpixmap, SLOT(deleteLater()));
	dragpixmap->setObjectName("dragpixmap");
	connect(dragpixmap, SIGNAL(destroyed()), twutil, SLOT(dumpDestroyed()));
    dragpixmap->show();

    drag->exec();
	emit widgetDnD(currentWidget(), drag->target());
	QTabBar::mouseMoveEvent(event);
	fn_end;
}
void QuickLaunchButton::mouseMoveEvent(QMouseEvent *e)
{
    if (!(e->buttons() & Qt::LeftButton))
    {
        return;
    }

    if ((e->pos() - mDragStart).manhattanLength() < QApplication::startDragDistance())
    {
        return;
    }

    if (e->modifiers() != Qt::ControlModifier)
    {
        return;
    }

    QDrag *drag = new QDrag(this);
    ButtonMimeData *mimeData = new ButtonMimeData();
    mimeData->setButton(this);
    drag->setMimeData(mimeData);

    drag->exec(Qt::MoveAction);

    // Icon was droped outside the panel, remove button
    if (!drag->target())
    {
        selfRemove();
    }
}
void ColumnDropCSVView::mousePressEvent(QMouseEvent *press)
{
	QModelIndex atClick = indexAt(press->pos());
	if (!atClick.isValid() || atClick.row())
		return;

	QRect indexRect = visualRect(atClick);
	QPixmap pix(indexRect.width(), indexRect.height());
	pix.fill(QColor(0,0,0,0));
	render(&pix, QPoint(0, 0),QRegion(indexRect));

	QDrag *drag = new QDrag(this);
	QMimeData *mimeData = new QMimeData;
	mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
	mimeData->setData(subsurface_index, QString::number(atClick.column()).toUtf8());
	drag->setPixmap(pix);
	drag->setMimeData(mimeData);
	if (drag->exec() != Qt::IgnoreAction){
		QObject *target = drag->target();
		if (target->objectName() ==  "qt_scrollarea_viewport")
			target = target->parent();
		if (target != drag->source())
			model()->setData(atClick, QString());
	}
}
Example #4
0
void PanelBrowserMenu::dragObjectDestroyed(QObject* o)
{
    QDrag* drag = dynamic_cast<QDrag*>(o);
    if (drag && drag->target() != this)
    {
        close();
    }
}
Example #5
0
void QLineEditPrivate::drag()
{
    Q_Q(QLineEdit);
    dndTimer.stop();
    QMimeData *data = new QMimeData;
    data->setText(control->selectedText());
    QDrag *drag = new QDrag(q);
    drag->setMimeData(data);
    Qt::DropAction action = drag->start();
    if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
        control->removeSelection();
}
Example #6
0
// Start a drag.
void QsciScintillaQt::StartDrag()
{
    inDragDrop = ddDragging;

    QDrag *qdrag = new QDrag(qsb);
    qdrag->setMimeData(mimeSelection(drag));

# if QT_VERSION >= 0x040300
    Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction);
# else
    Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif

    // Remove the dragged text if it was a move to another widget or
    // application.
    if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
        ClearSelection();

    SetDragPosition(QSCI_SCI_NAMESPACE(SelectionPosition)());
    inDragDrop = ddNone;
}
void PersistentState::timerEvent(QTimerEvent *e) {
	if (e->timerId() == _dragStartTimer.timerId()) {
        _dragStartTimer.stop();

		_mousePressed = false;
		QMimeData *data = createMimeDataFromSelection();
		
		QDrag *drag = new QDrag(editor());
		drag->setMimeData(data);
		
		Qt::DropActions actions = Qt::CopyAction;
		if (!editor()->isReadOnly())
			actions |= Qt::MoveAction;
			
		Qt::DropAction action = drag->start(actions);
		
		if (action == Qt::MoveAction && drag->target() != editor())
			_persistentCursor.removeSelectedText();

	}
}
Example #8
0
void ToolBar::mouseMoveEvent(QMouseEvent *event)
{
    QToolBar::mouseMoveEvent(event);
    QAction *action  = this->actionAt(m_dragPos);

    if (event->buttons() & Qt::LeftButton && action && isEdited()) {
        qint32 distance = (event->pos() - m_dragPos).manhattanLength();
        if (distance > QApplication::startDragDistance() ) {

            QDrag *drag = new QDrag(this);
            MimeDataObject *mimeData = new MimeDataObject();

            mimeData->setObject(action);
            drag->setMimeData(mimeData);

            if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
                if (drag->target() != this || action->isSeparator())
                    this->removeAction(action);
            return;
        }
    }
}
// Start a drag.
void ScintillaQt::StartDrag()
{
    inDragDrop = ddDragging;

    QDrag *qdrag = new QDrag(qsb);
    qdrag->setMimeData(mimeSelection(drag));

# if QT_VERSION >= 0x040300
    // The default action is to copy so that the cursor is correct when over
    // another widget or application (when we have no control over it).  We
    // make sure it is correct over ourself in the event handlers.
    Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction);
# else
    Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif

    // Remove the dragged text if it was a move to another widget or
    // application.
    if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
        ClearSelection();

    SetDragPosition(SelectionPosition());
    inDragDrop = ddNone;
}
Example #10
0
void MouseNavigator::startDrag()
{
    // reset states
    mLMBPressed = false;
    mInLMBDoubleClick = false;
    mDragStartPossible = false;

    // create data
    QMimeData* dragData = mView->selectionAsMimeData();
    if( ! dragData )
        return;

    QDrag* drag = new QDrag( mView );
    drag->setMimeData( dragData );

    Qt::DropActions request = (mView->isReadOnly()||mView->isOverwriteMode()) ? Qt::CopyAction : Qt::CopyAction|Qt::MoveAction;
    Qt::DropAction dropAction = drag->exec( request );

    if( dropAction == Qt::MoveAction )
    {
        AbstractByteArrayView* targetByteArrayView = qobject_cast<AbstractByteArrayView*>( drag->target() );
        // Not inside this widget itself?
        if( ! targetByteArrayView
            || targetByteArrayView->byteArrayModel() != mView->byteArrayModel() )
            mView->removeSelectedData();
    }
}