void ResizeColumn::slotOk() { double width = m_pWidth->value(); //Don't generate a resize, when there isn't a change or the change is only a rounding issue if (fabs(width - columnWidth) > DBL_EPSILON) { ResizeColumnManipulator* manipulator = new ResizeColumnManipulator(); manipulator->setSheet(m_selection->activeSheet()); manipulator->setSize(width); manipulator->add(*m_selection); manipulator->execute(m_selection->canvas()); } accept(); }
void ColumnHeader::equalizeColumn(double resize) { if (resize != 0.0) { ResizeColumnManipulator* command = new ResizeColumnManipulator(); command->setSheet(m_pCanvas->activeSheet()); command->setSize(qMax(2.0, resize)); command->add(*m_pCanvas->selection()); if (!command->execute()) delete command; } else { // hide HideShowManipulator* command = new HideShowManipulator(); command->setSheet(m_pCanvas->activeSheet()); command->setManipulateColumns(true); command->add(*m_pCanvas->selection()); if (!command->execute()) delete command; } }
void ColumnHeader::mouseRelease(KoPointerEvent * _ev) { if (!m_cellToolIsActive) return; m_pCanvas->disableAutoScroll(); if (m_lSize) m_lSize->hide(); m_bMousePressed = false; register Sheet * const sheet = m_pCanvas->activeSheet(); if (!sheet) return; if (m_bResize) { double dWidth = m_pCanvas->zoomHandler()->unzoomItX(width()); double ev_PosX; // Remove size indicator painted by paintSizeIndicator removeSizeIndicator(); QRect rect; rect.setCoords(m_iResizedColumn, 1, m_iResizedColumn, KS_rowMax); if (m_pCanvas->selection()->isColumnSelected()) { if (m_pCanvas->selection()->contains(QPoint(m_iResizedColumn, 1))) { rect = m_pCanvas->selection()->lastRange(); } } double width = 0.0; double x; if (sheet->layoutDirection() == Qt::RightToLeft) ev_PosX = dWidth - m_pCanvas->zoomHandler()->unzoomItX(_ev->pos().x()) + m_pCanvas->xOffset(); else ev_PosX = m_pCanvas->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) { ResizeColumnManipulator* command = new ResizeColumnManipulator(); command->setSheet(sheet); command->setSize(width); command->add(Region(rect, sheet)); if (!command->execute()) delete command; } else { // hide HideShowManipulator* command = new HideShowManipulator(); command->setSheet(sheet); command->setManipulateColumns(true); command->add(Region(rect, sheet)); if (!command->execute()) delete command; } delete m_lSize; m_lSize = 0; } else if (m_bSelection) { QRect rect = m_pCanvas->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_pCanvas->selection()->isRowSelected()) { KMessageBox::error(0 /* XXX TODO this */, i18n("Area is too large.")); return; } HideShowManipulator* command = new HideShowManipulator(); command->setSheet(sheet); command->setManipulateColumns(true); command->setReverse(true); command->add(*m_pCanvas->selection()); command->execute(); } } } m_bSelection = false; m_bResize = false; }