/*! Notify change of image in \b fid: update icon and notify level change. */ void TTool::notifyImageChanged(const TFrameId &fid) { onImageChanged(); if (!m_application) return; m_application->getCurrentScene()->setDirtyFlag(true); if (m_application->getCurrentFrame()->isEditingLevel()) { TXshLevel *xl = m_application->getCurrentLevel()->getLevel(); if (!xl) return; TXshSimpleLevel *sl = xl->getSimpleLevel(); if (!sl) return; sl->setDirtyFlag(true); IconGenerator::instance()->invalidate(sl, fid); IconGenerator::instance()->invalidateSceneIcon(); } else { int row = m_application->getCurrentFrame()->getFrame(); int col = m_application->getCurrentColumn()->getColumnIndex(); if (col < 0) return; TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet(); if (!xsh) return; TXshCell cell = xsh->getCell(row, col); TXshSimpleLevel *sl = cell.getSimpleLevel(); if (sl) { IconGenerator::instance()->invalidate(sl, fid); IconGenerator::instance()->invalidateSceneIcon(); sl->setDirtyFlag(true); } } m_application->getCurrentLevel()->notifyLevelChange(); }
void CellsMover::emptyColumns(int c) const { std::set<int> ii; for (int i = 0; i < m_colCount; i++) ii.insert(c + i); ColumnCmd::deleteColumns(ii, false, true); TXsheet *xsh = getXsheet(); for (int i = 0; i < m_colCount; i++) xsh->insertColumn(c); }
void Stage::visit(Visitor &visitor, const VisitArgs &args) { ToonzScene *scene = args.m_scene; TXsheet *xsh = args.m_xsh; int row = args.m_row; int col = args.m_col; const OnionSkinMask *osm = args.m_osm; bool camera3d = args.m_camera3d; int xsheetLevel = args.m_xsheetLevel; bool isPlaying = args.m_isPlaying; StageBuilder sb; sb.m_vs = &visitor.m_vs; TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId(); TStageObject *camera = xsh->getStageObject(cameraId); TAffine cameraAff = camera->getPlacement(row); double z = camera->getZ(row); sb.m_cameraPlacement = ZPlacement(cameraAff, z); sb.m_camera3d = camera3d; sb.m_currentColumnIndex = col; sb.m_xsheetLevel = xsheetLevel; sb.m_onionSkinMask = *osm; Player::m_onionSkinFrontSize = 0; Player::m_onionSkinBackSize = 0; sb.addFrame(sb.m_players, scene, xsh, row, 0, args.m_onlyVisible, args.m_checkPreviewVisibility); updateOnionSkinSize(sb.m_players); sb.visit(sb.m_players, visitor, isPlaying); }
bool CellsMover::canMoveCells(const TPoint &pos) { TXsheet *xsh = getXsheet(); if (pos.x < 0) return false; if (pos.x != m_startPos.x) { int count = 0; // controlla il tipo int i = 0; while (i < m_rowCount * m_colCount) { TXshColumn::ColumnType srcType = getColumnTypeFromCell(i); int dstIndex = pos.x + i; TXshColumn *dstColumn = xsh->getColumn(dstIndex); if (srcType == TXshColumn::eZeraryFxType) return false; if (dstColumn && !dstColumn->isEmpty() && dstColumn->getColumnType() != srcType) return false; if (!dstColumn || dstColumn->isLocked() == false) count++; i += m_rowCount; } if (count == 0) return false; } if ((m_qualifiers & CellsMover::eInsertCells) || (m_qualifiers & CellsMover::eOverwriteCells)) return true; int count = 0; for (int i = 0; i < m_colCount; i++) { for (int j = 0; j < m_rowCount; j++) { if (!xsh->getCell(pos.y + j, pos.x + i).isEmpty()) return false; count++; } } if (count == 0) return false; return true; }
bool LevelMoverTool::canMoveColumns(const TPoint &pos) { TXsheet *xsh = getViewer()->getXsheet(); if (pos.x < 0) return false; if (pos.x != m_lastPos.x) { int count = 0; // controlla il tipo for (int i = 0; i < m_range.lx; i++) { int srcIndex = m_lastPos.x + i; int dstIndex = pos.x + i; TXshColumn *srcColumn = xsh->getColumn(srcIndex); if (srcColumn && srcColumn->isLocked()) continue; TXshColumn *dstColumn = xsh->getColumn(dstIndex); TXshColumn::ColumnType srcType = TXshColumn::eLevelType; if (srcColumn) srcType = srcColumn->getColumnType(); if (srcType == TXshColumn::eZeraryFxType) return false; /* qDebug() << "check: " << srcIndex << ":" << (srcColumn ? QString::number(srcType) : "empty") << " => " << dstIndex << ":" << (dstColumn ? QString::number(dstColumn->getColumnType()) : "empty"); */ if (dstColumn && !dstColumn->isEmpty() && dstColumn->getColumnType() != srcType) { return false; } if (!dstColumn || dstColumn->isLocked() == false) { count++; } } if (count == 0) return false; } return true; }
void SkeletonTool::magicLink(int index) { if (index < 0 || index >= (int)m_magicLinks.size()) return; HookData h0 = m_magicLinks[index].m_h0; HookData h1 = m_magicLinks[index].m_h1; TTool::Application *app = TTool::getApplication(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); int columnIndex = app->getCurrentColumn()->getColumnIndex(); TStageObjectId id = TStageObjectId::ColumnId(columnIndex); TStageObject *obj = xsh->getStageObject(id); int parentColumnIndex = h1.m_columnIndex; TStageObjectId parentId = TStageObjectId::ColumnId(parentColumnIndex); std::string parentHandle = h1.getHandle(); std::string handle = ""; if (h0.m_columnIndex < 0) { handle = obj->getHandle(); } else { handle = h0.getHandle(); } //TUndoManager *undoManager = TUndoManager::manager(); //undoManager->beginBlock(); TStageObjectCmd::setHandle(id, handle, app->getCurrentXsheet()); TStageObjectCmd::setParent(id, parentId, parentHandle, app->getCurrentXsheet()); //undoManager->endBlock(); }
//!Build the scene fx for each node below the xsheet one. //!Remember that left xsheet ports must not be expanded. void MultimediaRenderer::Imp::scanSceneForLayers() { //Retrieve the terminal fxs (ie, fxs which are implicitly //connected to the xsheet one) TXsheet *xsh = m_scene->getXsheet(); TFxSet *fxs = xsh->getFxDag()->getTerminalFxs(); //Examine all of them and - eventually - expand left xsheet //ports (ie fx nodes who allow implicit overlaying) for (int i = 0; i < fxs->getFxCount(); ++i) { TFx *fx = fxs->getFx(i); TFxPort *leftXSheetPort; retry: if (!fx) continue; leftXSheetPort = fx->getXsheetPort(); if (!leftXSheetPort) { m_fxsToRender.addFx(fx); continue; } //If the leftXSheetPort is not connected, retry on port 0 if (leftXSheetPort->isConnected()) m_fxsToRender.addFx(fx); else { fx = fx->getInputPort(0)->getFx(); goto retry; } } }
void StudioPaletteCmd::updateAllLinkedStyles(TPaletteHandle *paletteHandle, TXsheetHandle *xsheetHandle) { if (!xsheetHandle) return; TXsheet *xsheet = xsheetHandle->getXsheet(); if (!xsheet) return; ToonzScene *scene = xsheet->getScene(); if (!scene) return; // emit signal only if something changed bool somethingChanged = false; StudioPalette *sp = StudioPalette::instance(); TLevelSet *levelSet = scene->getLevelSet(); for (int i = 0; i < levelSet->getLevelCount(); i++) { TXshLevel *xl = levelSet->getLevel(i); TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : 0; if (!sl) continue; TPalette *palette = sl->getPalette(); if (palette) { somethingChanged = somethingChanged | sp->updateLinkedColors(palette); if (sl->getType() == TZP_XSHLEVEL) { std::vector<TFrameId> fids; sl->getFids(fids); std::vector<TFrameId>::iterator it; for (it = fids.begin(); it != fids.end(); ++it) { TFrameId fid = *it; std::string id = sl->getImageId(fid); } } } } if (!paletteHandle || !paletteHandle->getPalette()) return; if (somethingChanged) paletteHandle->notifyColorStyleChanged(); }
void TKeyframeSelection::setKeyframes() { TApp *app = TApp::instance(); TXsheetHandle *xsheetHandle = app->getCurrentXsheet(); TXsheet *xsh = xsheetHandle->getXsheet(); TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId(); if (isEmpty()) return; Position pos = *m_positions.begin(); int row = pos.first; int col = pos.second; TStageObjectId id = col < 0 ? cameraId : TStageObjectId::ColumnId(col); TStageObject *pegbar = xsh->getStageObject(id); if (!pegbar) return; if (pegbar->isKeyframe(row)) { TStageObject::Keyframe key = pegbar->getKeyframe(row); pegbar->removeKeyframeWithoutUndo(row); UndoRemoveKeyFrame *undo = new UndoRemoveKeyFrame(id, row, key, xsheetHandle); undo->setObjectHandle(app->getCurrentObject()); TUndoManager::manager()->add(undo); } else { pegbar->setKeyframeWithoutUndo(row); UndoSetKeyFrame *undo = new UndoSetKeyFrame(id, row, xsheetHandle); undo->setObjectHandle(app->getCurrentObject()); TUndoManager::manager()->add(undo); } TApp::instance()->getCurrentScene()->setDirtyFlag(true); TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false); }
void ShiftTraceTool::updateBox() { if (0 <= m_ghostIndex && m_ghostIndex < 2 && m_row[m_ghostIndex] >= 0) { int col = TApp::instance()->getCurrentColumn()->getColumnIndex(); int row = m_row[m_ghostIndex]; TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(row, col); TXshSimpleLevel *sl = cell.getSimpleLevel(); if (sl) { m_dpiAff = getDpiAffine(sl, cell.m_frameId); TImageP img = cell.getImage(false); if (img) { if (TRasterImageP ri = img) { TRasterP ras = ri->getRaster(); m_box = (convert(ras->getBounds()) - ras->getCenterD()) * ri->getSubsampling(); } else if (TToonzImageP ti = img) { TRasterP ras = ti->getRaster(); m_box = (convert(ras->getBounds()) - ras->getCenterD()) * ti->getSubsampling(); } else if (TVectorImageP vi = img) { m_box = vi->getBBox(); } } } } }
void FilmstripFrames::onFrameSwitched() { // no. interferische con lo shift-click per la selezione. // m_selection->selectNone(); TApp *app = TApp::instance(); TFrameHandle *fh = app->getCurrentFrame(); TFrameId fid; if (fh->isEditingLevel()) fid = fh->getFid(); else { TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); int col = app->getCurrentColumn()->getColumnIndex(); int row = fh->getFrame(); if (row < 0 || col < 0) return; TXshCell cell = xsh->getCell(row, col); if (cell.isEmpty()) return; fid = cell.getFrameId(); } int index = fid2index(fid); if (index >= 0) { exponeFrame(index); // clear selection and select only the destination frame select(index, ONLY_SELECT); } update(); }
void ColumnCmd::resequence(int index) { if (!canResequence(index)) return; TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshColumn *column = xsh->getColumn(index); assert(column); TXshLevelColumn *lcolumn = column->getLevelColumn(); assert(lcolumn); int r0 = 0, r1 = -1; lcolumn->getRange(r0, r1); assert(r0 <= r1); TXshCell cell = lcolumn->getCell(r0); assert(!cell.isEmpty()); TXshChildLevel *xl = cell.m_level->getChildLevel(); assert(xl); TXsheet *childXsh = xl->getXsheet(); int frameCount = childXsh->getFrameCount(); if (frameCount < 1) frameCount = 1; TUndoManager::manager()->add(new ResequenceUndo(index, frameCount)); lcolumn->clearCells(r0, r1 - r0 + 1); for (int i = 0; i < frameCount; i++) { cell.m_frameId = TFrameId(i + 1); lcolumn->setCell(r0 + i, cell); } xsh->updateFrameCount(); TApp::instance()->getCurrentScene()->setDirtyFlag(true); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
void FunctionViewer::refreshModel() { TXsheet *xsh = m_xshHandle ? m_xshHandle->getXsheet() : 0; m_functionGraph->getModel()->refreshData(xsh); if (xsh) { int rowCount = xsh->getFrameCount(); m_numericalColumns->setRowCount(rowCount); m_numericalColumns->updateAll(); ToonzScene *scene = xsh->getScene(); if (!scene) // This seems wrong. It should rather be return; // asserted - though I'm not touching it now... TFilePath scenePath = scene->getScenePath().getParentDir(); if (scene->isUntitled()) scenePath = TProjectManager::instance()->getCurrentProject()->getScenesPath(); m_treeView->setCurrentScenePath(scenePath); int distance, offset; scene->getProperties()->getMarkers(distance, offset); m_numericalColumns->setMarkRow(distance, offset); } m_treeView->updateAll(); m_toolbar->setCurve(0); }
void FunctionViewer::showEvent(QShowEvent *) { refreshModel(); // Connect handles bool ret = true; if (m_xshHandle) { ret = connect(m_xshHandle, SIGNAL(xsheetChanged()), this, SLOT(refreshModel())) && ret; ret = connect(m_xshHandle, SIGNAL(xsheetSwitched()), this, SLOT(rebuildModel())) && ret; } if (m_frameHandle) ret = connect(m_frameHandle, SIGNAL(frameSwitched()), this, SLOT(propagateExternalSetFrame())) && ret; if (m_objectHandle) { ret = connect(m_objectHandle, SIGNAL(objectSwitched()), this, SLOT(onStageObjectSwitched())) && ret; ret = connect(m_objectHandle, SIGNAL(objectChanged(bool)), this, SLOT(onStageObjectChanged(bool))) && ret; } if (m_fxHandle) ret = connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched())) && ret; // display animated channels when the scene is switched if (m_sceneHandle) ret = connect(m_sceneHandle, SIGNAL(sceneSwitched()), m_treeView, SLOT(displayAnimatedChannels())) && ret; assert(ret); m_treeView->setExpanded(m_treeView->model()->index(0, 0), true); m_treeView->setExpanded(m_treeView->model()->index(1, 0), true); FunctionTreeModel *ftm = static_cast<FunctionTreeModel *>(m_treeView->model()); if (m_objectHandle) { assert(m_xshHandle); TXsheet *xsh = m_xshHandle->getXsheet(); const TStageObjectId &objId = m_objectHandle->getObjectId(); ftm->setCurrentStageObject((objId == TStageObjectId::NoneId) ? (TStageObject *)0 : xsh->getStageObject(objId)); } if (m_fxHandle) ftm->setCurrentFx(m_fxHandle->getFx()); }
void LayerHeaderPanel::mouseReleaseEvent(QMouseEvent *event) { TApp *app = TApp::instance(); TXsheet *xsh = m_viewer->getXsheet(); int col, totcols = xsh->getColumnCount(); bool sound_changed = false; if (m_doOnRelease != 0 && totcols > 0) { for (col = 0; col < totcols; col++) { if (!xsh->isColumnEmpty(col)) { TXshColumn *column = xsh->getColumn(col); if (m_doOnRelease == ToggleAllPreviewVisible) { column->setPreviewVisible(!column->isPreviewVisible()); } else if (m_doOnRelease == ToggleAllTransparency) { column->setCamstandVisible(!column->isCamstandVisible()); if (column->getSoundColumn()) sound_changed = true; } else if (m_doOnRelease == ToggleAllLock) { column->lock(!column->isLocked()); } } } if (sound_changed) { app->getCurrentXsheet()->notifyXsheetSoundChanged(); } app->getCurrentScene()->notifySceneChanged(); app->getCurrentXsheet()->notifyXsheetChanged(); } m_viewer->updateColumnArea(); update(); m_doOnRelease = 0; }
void redo() const override { int ca = m_cellsMover.getStartPos().x; int cb = m_cellsMover.getPos().x; int colCount = m_cellsMover.getColumnCount(); if (ca != cb) { if (m_cellsMover.m_uffa & 1) m_cellsMover.emptyColumns(ca); if (m_cellsMover.m_uffa & 2) m_cellsMover.restoreColumns(cb); } if ((m_cellsMover.getQualifiers() & CellsMover::eCopyCells) == 0 && (m_cellsMover.getQualifiers() & CellsMover::eOverwriteCells) == 0) m_cellsMover.undoMoveCells(m_cellsMover.getStartPos()); if (m_cellsMover.getQualifiers() & CellsMover::eOverwriteCells) { // rimuove le celle vecchie int c, ra = m_cellsMover.getStartPos().y, rowCount = m_cellsMover.getRowCount(); TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); for (c = ca; c < ca + colCount; c++) xsh->clearCells(ra, c, rowCount); } m_cellsMover.moveCells(); TApp::instance()->getCurrentXsheet()->getXsheet()->updateFrameCount(); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); if (m_cellsMover.getColumnTypeFromCell(0) == TXshColumn::eSoundType) TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged(); }
void TApp::onSplineChanged() { if (m_currentObject->isSpline()) { TXsheet *xsh = m_currentXsheet->getXsheet(); TStageObject *currentObject = xsh->getStageObject(m_currentObject->getObjectId()); currentObject->setOffset(currentObject->getOffset()); //invalidate currentObject } }
void undo() const override { TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); for (int i = 0; i < (int)m_oldFrames.size(); i++) { xsh->setCell(m_r0 + i, m_col, m_oldFrames[i]); } xsh->updateFrameCount(); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
void RowArea::mousePressEvent(QMouseEvent *event) { m_viewer->setQtModifiers(event->modifiers()); if (event->button() == Qt::LeftButton) { bool playRangeModifierisClicked = false; TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); TPoint pos(event->pos().x(), event->pos().y()); int row = m_viewer->yToRow(pos.y); QRect visibleRect = visibleRegion().boundingRect(); int playR0, playR1, step; XsheetGUI::getPlayRange(playR0, playR1, step); bool playRangeEnabled = playR0 <= playR1; if (!playRangeEnabled) { TXsheet *xsh = m_viewer->getXsheet(); playR1 = xsh->getFrameCount() - 1; playR0 = 0; } if (playR1 == -1) { //getFrameCount = 0 i.e. xsheet is empty setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); } else if (m_xa <= pos.x && pos.x <= m_xa + 10 && (row == playR0 || row == playR1)) { if (!playRangeEnabled) XsheetGUI::setPlayRange(playR0, playR1, step); setDragTool(XsheetGUI::DragTool::makePlayRangeModifierTool(m_viewer)); playRangeModifierisClicked = true; } else setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); //when shift+click the row area, select a single row region in the cell area if (!playRangeModifierisClicked && 0 != (event->modifiers() & Qt::ShiftModifier)) { int filledCol; for (filledCol = xsh->getColumnCount() - 1; filledCol >= 0; filledCol--) { TXshColumn *currentColumn = xsh->getColumn(filledCol); if (!currentColumn) continue; if (!currentColumn->isEmpty()) break; } m_viewer->getCellSelection()->selectNone(); m_viewer->getCellSelection()->selectCells(row, 0, row, tmax(0, filledCol)); m_viewer->updateCellRowAree(); } m_viewer->dragToolClick(event); event->accept(); } // left-click // pan by middle-drag else if (event->button() == Qt::MidButton) { m_pos = event->pos(); m_isPanning = true; } }
void TCellKeyframeSelection::selectCellKeyframe(int row, int col) { m_cellSelection->selectCell(row, col); TXsheet *xsh = m_xsheetHandle->getXsheet(); TStageObjectId id = col < 0 ? TStageObjectId::CameraId(0) : TStageObjectId::ColumnId(col); TStageObject *stObj = xsh->getStageObject(id); m_keyframeSelection->clear(); if (stObj->isKeyframe(row)) m_keyframeSelection->select(row, col); }
// return true iff column ancestorIndex is column descentIndex or its parent or the parent of the parent, etc. bool isAncestorOf(int ancestorIndex, int descendentIndex) { TStageObjectId ancestorId = TStageObjectId::ColumnId(ancestorIndex); TStageObjectId descendentId = TStageObjectId::ColumnId(descendentIndex); TXsheet *xsh = TTool::getApplication()->getCurrentXsheet()->getXsheet(); while (descendentId != ancestorId && descendentId.isColumn()) descendentId = xsh->getStageObjectParent(descendentId); return descendentId == ancestorId; }
void CellsMover::getCells(std::vector<TXshCell> &cells, int r, int c) const { for (int i = 0; i < (int)cells.size(); i++) cells[i] = TXshCell(); TXsheet *xsh = getXsheet(); for (int i = 0; i < m_colCount; i++) { TXshColumn *column = xsh->getColumn(c + i); if (column && column->isLocked()) continue; xsh->getCells(r, c + i, m_rowCount, &cells[m_rowCount * i]); } }
//----------------------------------------------------------------------------- // pasteColumnsAbove will insert columns after the last column in the selection void TColumnSelection::pasteColumnsAbove() { std::set<int> indices; if (isEmpty()) { // in case that no columns are selected TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); indices.insert(xsh->getFirstFreeColumnIndex()); } else indices.insert(*m_indices.rbegin() + 1); ColumnCmd::pasteColumns(indices); }
void redo() const override { TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); xsh->insertColumn(m_columnIndex); int frameCount = m_childLevel->getXsheet()->getFrameCount(); if (frameCount < 1) frameCount = 1; for (int r = 0; r < frameCount; r++) xsh->setCell(r, m_columnIndex, TXshCell(m_childLevel.getPointer(), TFrameId(r + 1))); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
void redo() const override { TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); int r0, r1; xsh->getCellRange(m_col, r0, r1); if (r0 <= r1) { xsh->clearCells(r0, m_col, r1 - r0 + 1); xsh->updateFrameCount(); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); } }
ClearColumnCellsUndo(int col) : m_col(col), m_r0(0) { TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); int r0, r1; xsh->getCellRange(col, r0, r1); m_r0 = r0; if (r0 > r1) return; for (int r = r0; r <= r1; r++) { m_oldFrames.push_back(xsh->getCell(r, col)); } }
// // xsheet <- cells // void CellsMover::setCells(const std::vector<TXshCell> &cells, int r, int c) const { TXsheet *xsh = getXsheet(); for (int i = 0; i < m_colCount; i++) { TXshColumn *column = xsh->getColumn(c + i); if (column) // skip if columns is locked or doesn't support cells operation if (column->getCellColumn() == 0 || column->isLocked()) continue; xsh->setCells(r, c + i, m_rowCount, &cells[m_rowCount * i]); } }
// isTotallyEmptyColumn == column empty, no fx bool LevelMoverTool::isTotallyEmptyColumn(int col) const { if (col < 0) return false; TXsheet *xsh = getViewer()->getXsheet(); TXshColumn *column = xsh->getColumn(col); if (!column) return true; if (!column->isEmpty()) return false; if (column->getFx()->getOutputConnectionCount() != 0) return false; // bisogna controllare lo stage object return true; }
bool changeFrameSkippingHolds(QKeyEvent *e) { if ((e->modifiers() & Qt::ShiftModifier) == 0 || e->key() != Qt::Key_Down && e->key() != Qt::Key_Up) return false; TApp *app = TApp::instance(); TFrameHandle *fh = app->getCurrentFrame(); if (!fh->isEditingScene()) return false; int row = fh->getFrame(); int col = app->getCurrentColumn()->getColumnIndex(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(row, col); if (e->key() == Qt::Key_Down) { if (cell.isEmpty()) { int r0, r1; if (xsh->getCellRange(col, r0, r1)) { while (row <= r1 && xsh->getCell(row, col).isEmpty()) row++; if (xsh->getCell(row, col).isEmpty()) return false; } else return false; } else { while (xsh->getCell(row, col) == cell) row++; } } else { // Key_Up while (row >= 0 && xsh->getCell(row, col) == cell) row--; if (row < 0) return false; cell = xsh->getCell(row, col); while (row > 0 && xsh->getCell(row - 1, col) == cell) row--; } fh->setFrame(row); return true; }
void CellsMover::undoMoveCells(const TPoint &pos) const { TXsheet *xsh = getXsheet(); int r = pos.y; int c = pos.x; if (m_qualifiers & eInsertCells) { for (int i = 0; i < m_colCount; i++) xsh->removeCells(r, c + i, m_rowCount); } else { for (int i = 0; i < m_colCount; i++) xsh->clearCells(r, c + i, m_rowCount); if (m_qualifiers & eOverwriteCells) setCells(m_oldCells, r, c); } }