void TocDlg::moveDownPage()
{
    if (curPage+1<=pageCount) {
        curPage += 1;
    } else {
        curPage = 1;
    }

    movePage();
}
void TocDlg::moveUpPage()
{
    if (curPage-1 >= 1) {
        curPage -= 1;
    } else {
        curPage = pageCount;
    }

    movePage();
}
Beispiel #3
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;
            }
        }
    }
}