コード例 #1
0
ファイル: ShowColRowDialog.cpp プロジェクト: KDE/calligra
void ShowColRow::slotOk()
{
    Region region;
    for (unsigned int i = 0; i < (unsigned int)list->count(); i++) {
        if (list->item(i)->isSelected()) {
            if (typeShow == Column) {
                region.add(QRect(listInt.at(i), 1, 1, KS_rowMax));
            }
            if (typeShow == Row) {
                region.add(QRect(1, listInt.at(i), KS_colMax, 1));
            }
        }
    }

    HideShowManipulator* manipulator = new HideShowManipulator();
    manipulator->setSheet(m_selection->activeSheet());
    if (typeShow == Column) {
        manipulator->setManipulateColumns(true);
    }
    if (typeShow == Row) {
        manipulator->setManipulateRows(true);
    }
    manipulator->setReverse(true);
    manipulator->add(region);
    manipulator->execute(m_selection->canvas());

    accept();
}
コード例 #2
0
ファイル: Headers.cpp プロジェクト: KDE/koffice
void KCRowHeader::equalizeRow(double resize)
{
    if (resize != 0.0) {
        ResizeRowManipulator* command = new ResizeRowManipulator();
        command->setSheet(m_pView->activeSheet());
        command->setSize(qMax(qreal(2.0), resize));
        command->add(*m_pView->selection());
        if (!command->execute())
            delete command;
    } else { // hide
        HideShowManipulator* command = new HideShowManipulator();
        command->setSheet(m_pView->activeSheet());
        command->setManipulateRows(true);
        command->add(*m_pView->selection());
        if (!command->execute())
            delete command;
    }
}
コード例 #3
0
ファイル: Headers.cpp プロジェクト: KDE/koffice
void KCRowHeader::mouseReleaseEvent(QMouseEvent * _ev)
{
    if (!m_cellToolIsActive)
        return;
    m_pView->disableAutoScroll();
    if (m_lSize)
        m_lSize->hide();

    m_bMousePressed = false;

    if (!m_pView->koDocument()->isReadWrite())
        return;

    register KCSheet * const sheet = m_pView->activeSheet();
    if (!sheet)
        return;

    double ev_PosY = m_pView->zoomHandler()->unzoomItY(_ev->pos().y()) + m_pCanvas->yOffset();

    if (m_bResize) {
        // Remove size indicator painted by paintSizeIndicator
        if (m_rubberband) {
            delete m_rubberband;
            m_rubberband = 0;
        }

        int start = m_iResizedRow;
        int end = m_iResizedRow;
        QRect rect;
        rect.setCoords(1, m_iResizedRow, KS_colMax, m_iResizedRow);
        if (m_pView->selection()->isRowSelected()) {
            if (m_pView->selection()->contains(QPoint(1, m_iResizedRow))) {
                start = m_pView->selection()->lastRange().top();
                end = m_pView->selection()->lastRange().bottom();
                rect = m_pView->selection()->lastRange();
            }
        }

        double height = 0.0;
        double y = sheet->rowPosition(m_iResizedRow);
        if (ev_PosY - y <= 0.0)
            height = 0.0;
        else
            height = ev_PosY - y;

        if (height != 0.0) {
            ResizeRowManipulator* command = new ResizeRowManipulator();
            command->setSheet(sheet);
            command->setSize(height);
            command->add(KCRegion(rect, sheet));
            if (!command->execute())
                delete command;
        } else { // hide
            HideShowManipulator* command = new HideShowManipulator();
            command->setSheet(sheet);
            command->setManipulateRows(true);
            command->add(KCRegion(rect, sheet));
            if (!command->execute())
                delete command;
        }
        delete m_lSize;
        m_lSize = 0;
    } else if (m_bSelection) {
        QRect rect = m_pView->selection()->lastRange();

        // TODO: please don't remove. Right now it's useless, but it's for a future feature
        // Norbert
        bool m_frozen = false;
        if (m_frozen) {
            kDebug(36001) << "selected: T" << rect.top() << " B" << rect.bottom();

            int i;
            QList<int> hiddenRows;

            for (i = rect.top(); i <= rect.bottom(); ++i) {
                if (sheet->rowFormat(i)->isHidden()) {
                    hiddenRows.append(i);
                }
            }

            if (hiddenRows.count() > 0) {
                if (m_pView->selection()->isColumnSelected()) {
                    KMessageBox::error(this, i18n("Area is too large."));
                    return;
                }

                HideShowManipulator* command = new HideShowManipulator();
                command->setSheet(sheet);
                command->setManipulateRows(true);
                command->setReverse(true);
                command->add(*m_pView->selection());
                command->execute();
            }
        }
    }

    m_bSelection = false;
    m_bResize = false;
}