bool TXsheet::setCell(int row, int col, const TXshCell &cell) { if (row < 0 || col < 0) return false; bool wasColumnEmpty = isColumnEmpty(col); TXshCellColumn *cellColumn; if (!cell.isEmpty()) { TXshLevel *level = cell.m_level.getPointer(); assert(level); int levelType = level->getType(); TXshColumn::ColumnType type = TXshColumn::eLevelType; if (levelType == SND_XSHLEVEL) type = TXshColumn::eSoundType; else if (levelType == SND_TXT_XSHLEVEL) type = TXshColumn::eSoundTextType; else if (levelType == PLT_XSHLEVEL) type = TXshColumn::ePaletteType; else if (levelType == ZERARYFX_XSHLEVEL) type = TXshColumn::eZeraryFxType; else if (levelType == MESH_XSHLEVEL) type = TXshColumn::eMeshType; cellColumn = touchColumn(col, type)->getCellColumn(); } else { TXshColumn *column = getColumn(col); cellColumn = column ? column->getCellColumn() : 0; } if (!cellColumn || cellColumn->isLocked()) return false; cellColumn->setXsheet(this); if (!cellColumn->setCell(row, cell)) { if (wasColumnEmpty) { removeColumn(col); insertColumn(col); } return false; } TFx *fx = cellColumn->getFx(); if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0 && cellColumn->getPaletteColumn() == 0) getFxDag()->addToXsheet(fx); if (cell.isEmpty()) updateFrameCount(); else if (row >= m_imp->m_frameCount) m_imp->m_frameCount = row + 1; TNotifier::instance()->notify(TXsheetChange()); return true; }
bool TXsheet::setCells(int row, int col, int rowCount, const TXshCell cells[]) { static const TXshCell emptyCell; int i = 0; while (i < rowCount && cells[i].isEmpty()) i++; // inserito da Elisa verso novembre 2009. // cosi' ha il difetto che se assegno celle vuote non fa nulla // per ora lo commento. bisogna indagare se questo rompe qualcosa // ho modificato il seguito per gestire il caso in cui i>=rowCount // => niente livelli dentro cells // if(i>=rowCount) // return false; TXshColumn::ColumnType type = TXshColumn::eLevelType; if (i < rowCount) { TXshLevel *level = cells[i].m_level.getPointer(); int levelType = level->getType(); if (levelType == SND_XSHLEVEL) type = TXshColumn::eSoundType; else if (levelType == SND_TXT_XSHLEVEL) type = TXshColumn::eSoundTextType; else if (levelType == PLT_XSHLEVEL) type = TXshColumn::ePaletteType; else if (levelType == ZERARYFX_XSHLEVEL) type = TXshColumn::eZeraryFxType; else if (levelType == MESH_XSHLEVEL) type = TXshColumn::eMeshType; } bool wasColumnEmpty = isColumnEmpty(col); TXshCellColumn *column = touchColumn(col, type)->getCellColumn(); if (!column) return false; int oldColRowCount = column->getMaxFrame() + 1; bool ret = column->setCells(row, rowCount, cells); if (!ret || column->isLocked()) { if (wasColumnEmpty) { removeColumn(col); insertColumn(col); } return false; } int newColRowCount = column->getMaxFrame() + 1; TFx *fx = column->getFx(); if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0) getFxDag()->addToXsheet(fx); column->setXsheet(this); if (newColRowCount > m_imp->m_frameCount) m_imp->m_frameCount = newColRowCount; else { if (oldColRowCount == m_imp->m_frameCount && newColRowCount < m_imp->m_frameCount) updateFrameCount(); } return true; }