Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix pasteinto undo

shun_iwasawaa174fa3a66cd
diff --git a/toonz/sources/toonz/celldata.cpp b/toonz/sources/toonz/celldata.cpp
index 5e0d184af..2bef12344 100644
--- a/toonz/sources/toonz/celldata.cpp
+++ b/toonz/sources/toonz/celldata.cpp
@@ -61,7 +61,8 @@ void TCellData::setCells(TXsheet *xsh, int r0, int c0, int r1, int c1) {
// data -> xsh
bool TCellData::getCells(TXsheet *xsh, int r0, int c0, int &r1, int &c1,
- bool insert, bool doZeraryClone) const {
+ bool insert, bool doZeraryClone,
+ bool skipEmptyCells) const {
int c;
r1 = r0 + m_rowCount - 1;
c1 = c0 + m_colCount - 1;
@@ -76,11 +77,13 @@ bool TCellData::getCells(TXsheet *xsh, int r0, int c0, int &r1, int &c1,
isColumnEmpty = column->isEmpty();
/*- 各セルに左上→右下で順に割り振られるIndex -*/
int cellIndex = index * m_rowCount;
- /*- セルに中身があるところまでcellIndexをインクリメント -*/
- while (cellIndex < (index + 1) * m_rowCount &&
- m_cells[cellIndex].isEmpty())
- ++cellIndex;
- /*- 選択範囲の終端 -*/
+ // increment the cellIndex and skip empty cells
+ if (skipEmptyCells) {
+ while (cellIndex < (index + 1) * m_rowCount &&
+ m_cells[cellIndex].isEmpty())
+ ++cellIndex;
+ }
+ // if the cellIndex reaches the end of the selection
if ((int)m_cells.size() <= cellIndex) // Celle vuote.
return cellSet;
/*- カラムが変更不可なら次のカラムへ -*/
@@ -152,9 +155,9 @@ void TCellData::cloneZeraryFx(int index, std::vector<TXshCell> &cells) const {
TXshZeraryFxColumn *newFxColumn = new TXshZeraryFxColumn(0);
newFxColumn->getZeraryColumnFx()->setZeraryFx(newZeraryFx);
newFxLevel->setColumn(newFxColumn);
- cells.clear();
+ // replace the zerary fx cells by the new fx
int r;
- for (r = firstNotEmptyIndex; r < (index + 1) * m_rowCount; r++)
- cells.push_back(TXshCell(newFxLevel, m_cells[r].getFrameId()));
+ for (r = firstNotEmptyIndex; r < (index + 1) * m_rowCount; r++)
+ cells[r] = TXshCell(newFxLevel, m_cells[r].getFrameId());
}
}
diff --git a/toonz/sources/toonz/celldata.h b/toonz/sources/toonz/celldata.h
index f8a9b0f3b..0556a0e48 100644
--- a/toonz/sources/toonz/celldata.h
+++ b/toonz/sources/toonz/celldata.h
@@ -40,10 +40,12 @@ public:
// data -> xsh;
/*! If insert == true insert cells and shift old one.
-If column type don't match (sound vs nto sound) don't set column cells.
-If doZeraryClone == true clone zerary cells fx.*/
+If column type don't match (sound vs not sound) don't set column cells.
+If doZeraryClone == true clone zerary cells fx.
+If skipEmptyCells == false do not skip setting empty cells in data*/
bool getCells(TXsheet *xsh, int r0, int c0, int &r1, int &c1,
- bool insert = true, bool doZeraryClone = true) const;
+ bool insert = true, bool doZeraryClone = true,
+ bool skipEmptyCells = true) const;
//! Return true if cell in TCellData can be set in \b xsh xsheet.
bool canChange(TXsheet *xsh, int c0) const;
diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cpp
index 81342c2a9..0f3e74aa7 100644
--- a/toonz/sources/toonz/cellselection.cpp
+++ b/toonz/sources/toonz/cellselection.cpp
@@ -910,7 +910,8 @@ public:
//=============================================================================
bool pasteCellsWithoutUndo(int &r0, int &c0, int &r1, int &c1,
- bool insert = true, bool doZeraryClone = true) {
+ bool insert = true, bool doZeraryClone = true,
+ bool skipEmptyCells = true) {
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
@@ -921,7 +922,8 @@ bool pasteCellsWithoutUndo(int &r0, int &c0, int &r1, int &c1,
if (r0 < 0 || c0 < 0) return false;
/*-- この中で、r1,c1はペースト範囲にあわせリサイズされる --*/
- bool ret = cellData->getCells(xsh, r0, c0, r1, c1, insert, doZeraryClone);
+ bool ret = cellData->getCells(xsh, r0, c0, r1, c1, insert, doZeraryClone,
+ skipEmptyCells);
if (!ret) return false;
// Se la selezione corrente e' TCellSelection selezione le celle copiate
@@ -992,16 +994,16 @@ public:
}
/*-- クリップボードの内容を取っておく --*/
- const QMimeData *mimeData = clipboard->mimeData();
+ QMimeData *mimeData = cloneData(clipboard->mimeData());
/*--
* ペースト前にあったセル配列をcellDataとしていったんクリップボードに入れ、ペーストさせる
* --*/
clipboard->setMimeData(cloneData(m_beforeData), QClipboard::Clipboard);
- pasteCellsWithoutUndo(r0, c0, c1, r1, true, false);
+ pasteCellsWithoutUndo(r0, c0, r1, c1, true, false, false);
/*-- クリップボードを元に戻す --*/
- clipboard->setMimeData(cloneData(mimeData), QClipboard::Clipboard);
+ clipboard->setMimeData(mimeData, QClipboard::Clipboard);
// Se le selezione corrente e' TCellSelection seleziono le celle che sono in
// oldSelection