Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
void KCColumnHeader::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;

    if (m_bResize) {
        double dWidth = m_pView->zoomHandler()->unzoomItX(width());
        double ev_PosX;

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

        int start = m_iResizedColumn;
        int end   = m_iResizedColumn;
        QRect rect;
        rect.setCoords(m_iResizedColumn, 1, m_iResizedColumn, KS_rowMax);
        if (m_pView->selection()->isColumnSelected()) {
            if (m_pView->selection()->contains(QPoint(m_iResizedColumn, 1))) {
                start = m_pView->selection()->lastRange().left();
                end   = m_pView->selection()->lastRange().right();
                rect  = m_pView->selection()->lastRange();
            }
        }

        double width = 0.0;
        double x;

        if (sheet->layoutDirection() == Qt::RightToLeft)
            ev_PosX = dWidth - m_pView->zoomHandler()->unzoomItX(_ev->pos().x()) + m_pCanvas->xOffset();
        else
            ev_PosX = m_pView->zoomHandler()->unzoomItX(_ev->pos().x()) + m_pCanvas->xOffset();

        x = sheet->columnPosition(m_iResizedColumn);

        if (ev_PosX - x <= 0.0)
            width = 0.0;
        else
            width = ev_PosX - x;

        if (width != 0.0) {
            KCResizeColumnManipulator* command = new KCResizeColumnManipulator();
            command->setSheet(sheet);
            command->setSize(width);
            command->add(KCRegion(rect, sheet));
            if (!command->execute())
                delete command;
        } else { // hide
            HideShowManipulator* command = new HideShowManipulator();
            command->setSheet(sheet);
            command->setManipulateColumns(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: L" << rect.left() << " R" << rect.right();

            int i;
            QList<int> hiddenCols;

            for (i = rect.left(); i <= rect.right(); ++i) {
                if (sheet->columnFormat(i)->isHidden()) {
                    hiddenCols.append(i);
                }
            }

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

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

    m_bSelection = false;
    m_bResize = false;
}
Exemplo n.º 3
0
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;
}