Esempio n. 1
0
void SeView::mouseMoveEvent(QMouseEvent* e)
{
	if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
	{
		Mpressed = false;
		int a = rowAt(e->pos().y());
		int b = columnAt(e->pos().x());
		if ((a != -1) && (b != -1))
		{
			QTableWidgetItem* ite = item(a, b);
			if (ite != 0)
			{
				if (ite->type() == 1002)
				{
					SeItem* it = (SeItem*)ite;
					QString str(it->pageName);
					bool dummy;
					int p = GetPage(a, b, &dummy);
					QString tmp;
					QMimeData *mimeData = new QMimeData;
					mimeData->setData("page/magic", "2 "+tmp.setNum(p).toLocal8Bit()+" "+str.toLocal8Bit());
					mimeData->setText("2 "+tmp.setNum(p)+" "+str);
					QDrag *dr = new QDrag(this);
					dr->setMimeData(mimeData);
					const QPixmap& pm = loadIcon("doc.png");
					dr->setDragCursor(pm, Qt::CopyAction);
					dr->setDragCursor(pm, Qt::MoveAction);
					dr->exec(Qt::CopyAction | Qt::MoveAction);
					QApplication::setOverrideCursor(Qt::ArrowCursor);
				}
			}
		}
	}
	QTableWidget::mouseMoveEvent(e);
}
Esempio n. 2
0
void DeviceExplorerView::startDrag(Qt::DropActions)
{
  QModelIndexList indexes = selectedDraggableIndexes();
  if (indexes.count() > 0)
  {
    QMimeData* data = QTreeView::model()->mimeData(indexes);
    if (!data)
      return;

    QDrag* drag = new QDrag(this);
    drag->setMimeData(data);
    drag->setPixmap(QPixmap());
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::CopyAction);
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::MoveAction);
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::LinkAction);
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::ActionMask);
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::IgnoreAction);
    drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::TargetMoveAction);

    drag->exec();
  }
}
Esempio n. 3
0
void SeList::mouseMoveEvent(QMouseEvent* e)
{
	if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
	{
		Mpressed = false;
		QListWidgetItem *i = itemAt(Mpos);
		if (i)
		{
			QMimeData *mimeData = new QMimeData;
			mimeData->setData("page/magic", "1"+i->text().toLocal8Bit());
			mimeData->setText("1"+i->text());
			QDrag *dr = new QDrag(this);
			dr->setMimeData(mimeData);
			const QPixmap& pm = loadIcon("doc.png");
			dr->setDragCursor(pm, Qt::CopyAction);
			dr->setDragCursor(pm, Qt::MoveAction);
			dr->exec(Qt::CopyAction | Qt::MoveAction);
			QApplication::setOverrideCursor(Qt::ArrowCursor);
		}
	}
}
void
View::DragMeepleLabel::mouseMoveEvent( QMouseEvent * inEvent )
{
	if ( !( inEvent->buttons() & Qt::LeftButton ) )
	{
		return;
	}
	if ( (inEvent->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
	{
		return;
	}

	QDrag * drag = new QDrag( this );
	Dragging::PieceData * dragData = new Dragging::PieceData( mMeeple );
	drag->setMimeData( dragData );
	drag->setPixmap( mPixmap );
	drag->setDragCursor( getEmptyPixmap(), Qt::MoveAction );
	drag->setHotSpot( QPoint( Gui::kMeepleWidth / 2, Gui::kMeepleHeight / 2 ) );

	drag->exec( Qt::MoveAction );
}
Esempio n. 5
0
//ドラッグ
void MapFrame::drag()
{
    Map*            pMap = app.getMap();
    IntsecCommon*   pic = pMap->getIntsecCommon();
    Intsec*         pIntsec;
    Intsec*         pIntsecReplCon;
    QPixmap         pixmapDrag;

//  qDebug("MapFrame::drag start");
    _clickDrag = false;

    //交差点ドラッグ開始、なしならスクロール
    _dragType = scroll;
    pIntsec = getIntsecAt(_clickDragX, _clickDragY);
    if (pIntsec != NULL)
    {
        //交差点モードなら交差点移動、表示変更後にフラグ指定でないと画面がずれる
        if (app.getMainWindow()->getEditMode() == MainWindow::intsec)
        {
            changeShowSelect(pIntsec->getIntsecId(), MAP_NOID, MAP_NOID);
            pixmapDrag = *(pIntsec->getPixmapLabel());
            _dragRoadX = getViewX(pIntsec->getMapPosX());
            _dragRoadY = getViewY(pIntsec->getMapPosY());
            _dragType = intsec;
        }

        //単路モードなら単路新規作成、表示変更後にフラグ指定でないと画面がずれる
        else if (app.getMainWindow()->getEditMode() == MainWindow::road)
        {
            changeShowSelect(pIntsec->getIntsecId(), MAP_NOID, MAP_NOID);
            pixmapDrag = *(pic->getLabelPixmap(pic->getLabelPixmapId(INTSEC_LT_DEST)));
            _dragRoadX = _dragRoadConX = getViewX(pIntsec->getMapPosX());
            _dragRoadY = _dragRoadConY = getViewY(pIntsec->getMapPosY());
            _dragType = road;
        }

        //単路付け替えモードなら選択単路を付け替え
        else if (app.getMainWindow()->getEditMode() == MainWindow::roadRepl)
        {
            if (_intsecIdSelect == MAP_NOID || _intsecIdDest == MAP_NOID || _roadIdSelect == MAP_NOID)
                return;
            if     (pIntsec->getIntsecId() == _intsecIdSelect)
                _intsecIdReplCon = _intsecIdDest;
            else if (pIntsec->getIntsecId() == _intsecIdDest)
                _intsecIdReplCon = _intsecIdSelect;
            else
                return;
            pixmapDrag = *(pIntsec->getPixmapLabel());
            pIntsecReplCon = pMap->getIntsec(_intsecIdReplCon);
            _dragRoadX    = getViewX(pIntsec->getMapPosX());
            _dragRoadY    = getViewY(pIntsec->getMapPosY());
            _dragRoadConX = getViewX(pIntsecReplCon->getMapPosX());
            _dragRoadConY = getViewY(pIntsecReplCon->getMapPosY());
            _dragType = roadRepl;
        }
    }

    //ドラッグ情報設定
    if (_dragType == scroll)
    {
        _intsecIdDrag = MAP_NOID;
        _offsetDragX = _offsetDragY = 0;
        _scrollBeginMapX = app.getViewMapX();
        _scrollBeginMapY = app.getViewMapY();
    }
    else
    {
        _intsecIdDrag = pIntsec->getIntsecId();
        _offsetDragX = _clickDragX - getViewX(pIntsec->getMapPosX());
        _offsetDragY = _clickDragY - getViewY(pIntsec->getMapPosY());
//      qDebug("MapFrame::mouseMoveEvent %d (%d,%d) = (%d,%d) - (%d,%d)",
//             _intsecIdDrag, _offsetDragX, _offsetDragY, _clickDragX, _clickDragY,
//             getViewX(pIntsec->getMapPosX()), getViewY(pIntsec->getMapPosY()));
    }
    QByteArray itemData;
    QMimeData *mimeData = new QMimeData;
    mimeData->setData(ITEM_MINETYPE, itemData);

    //ドラッグ中表示設定、 デフォルト pixmap の□は消せない、透明色ファイルを置いても透明にならない
//  qDebug("MapFrame::mouseMoveEvent setPixmap intsecId=%d", pIntsec->getIntsecId());
    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    QPoint pointHotSpot;
    if (_dragType == scroll)
    {

#ifdef USE_QT5
        if (!pixmapDrag)
        {
            //pixmapDrag = QPixmap(width(), height());
            pixmapDrag = QPixmap(1, 1);
        }
#endif //USE_QT5

        drag->setPixmap(pixmapDrag);
        drag->setDragCursor(QPixmap(":/images/scroll_cursor.png"), Qt::MoveAction);
    }
    else
    {
        drag->setPixmap(pixmapDrag);
        pointHotSpot.setX(_clickDragX - pIntsec->getLabelPosX());
        pointHotSpot.setY(_clickDragY - pIntsec->getLabelPosY());
//      qDebug("MapFrame::drag hotspot(%d, %d) = click(%d, %d) - label(%d, %d)",
//             pointHotSpot.x(), pointHotSpot.y(), _clickDragX, _clickDragY,
//             pIntsec->getLabelPosX(), pIntsec->getLabelPosY());
        drag->setHotSpot(pointHotSpot);
        if (pIntsec->getIntsecId() == _intsecIdSelect)
            pIntsec->showLabel(INTSEC_LT_SELECT, true);
        else
            pIntsec->showLabel(INTSEC_LT_DEST,   true);
    }

    //ドラッグ移動/終了、dragオブジェクト削除不可、ドラッグ種別クリア後再描画
    drag->exec(Qt::MoveAction, Qt::MoveAction);
    _dragWholePixmap = QPixmap();
    if (_dragType == scroll)
    {
        _dragType = none;
        unsetCursor();
    }
    else
    {
        _dragType = none;
        showIntsec(pIntsec);        //これがないと一瞬灰色
        repaintAll(true);
    }
//  qDebug("mousepress end %d", childLabel->getIntsecId());
}