示例#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);
}
示例#2
0
void SeView::dropEvent(QDropEvent * e)
{
    QString str, tmp;
    bool lastPage = false;
    if (e->mimeData()->hasFormat("page/magic"))
    {
        e->setDropAction(Qt::MoveAction);
        e->accept();
        // HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV.
        // It's the one and only reason why to include QApplication here.
        // But sadly this destroys our normal Cursors
        // Fixed at least in Qt-4.4.2
//		QApplication::restoreOverrideCursor();
        str = e->mimeData()->text();
        ClearPix();
        if (str.startsWith("1"))
        {
            int a = rowAt(e->pos().y());
            int b = columnAt(e->pos().x());
            int p;
            tmp = str.remove(0,1);
            if ((a == -1) || (b == -1))
                return;
            if (a == rowCount()-1)
            {
                emit NewPage(MaxC+1, tmp);
                return;
            }
            p = GetPage(a, b, &lastPage);
            if (columnCount() == 1)
            {
                if ((a % 2) == 0)
                    emit NewPage(p, tmp);
                else
                {
                    emit UseTemp(tmp, p);
                    QTableWidgetItem* ite = item(a, b);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
            else
            {
                if ((b % 2) == 0)
                {
                    if (lastPage)
                        emit NewPage(p+1, tmp);
                    else
                        emit NewPage(p, tmp);
                }
                else
                {
                    emit UseTemp(tmp, p);
                    QTableWidgetItem* ite = item(a, b);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
        }
        if (str.startsWith("2"))
        {
            int st = str.indexOf(" ");
            int en = str.indexOf(" ", st+1);
            tmp = str.mid(en+1);
            int dr = str.mid(st, en-st).toInt();
            int a = rowAt(e->pos().y());
            int b = columnAt(e->pos().x());
            int p;
            if ((a == -1) || (b == -1))
                return;
            QTableWidgetItem* ite = item(a, b);
            p = GetPage(a, b, &lastPage);
            if (a == rowCount()-1)
            {
                emit movePage(dr, p+1);
                return;
            }
            if (columnCount() == 1)
            {
                if ((a % 2) == 0)
                    emit movePage(dr, p);
                else
                {
                    emit UseTemp(tmp, p);
                    if (ite == 0)
                        return;
                    SeItem* it = (SeItem*)ite;
                    it->pageName = tmp;
                }
                return;
            }
            else
            {
                if ((b % 2) == 0)
                    emit movePage(dr, lastPage ? p+1 : p);
                else
                {
                    emit UseTemp(tmp, p);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
        }
    }
}
示例#3
0
int TableWidgetItem::type ( lua_State * L ) // const int
{
	QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
	Util::push( L, lhs->type() );
	return 1;
}