call diff list in user model move row move col
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
d45e8fd56d
commit
d73b5ff12d
@@ -1020,12 +1020,24 @@ impl UserModel {
|
|||||||
column: i32,
|
column: i32,
|
||||||
delta: i32,
|
delta: i32,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
self.model.move_column_action(sheet, column, delta)
|
let diff_list = vec![Diff::MoveColumn {
|
||||||
|
sheet,
|
||||||
|
column,
|
||||||
|
delta,
|
||||||
|
}];
|
||||||
|
self.push_diff_list(diff_list);
|
||||||
|
self.model.move_column_action(sheet, column, delta)?;
|
||||||
|
self.evaluate_if_not_paused();
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves a row vertically and adjusts formulas
|
/// Moves a row vertically and adjusts formulas
|
||||||
pub fn move_row_action(&mut self, sheet: u32, row: i32, delta: i32) -> Result<(), String> {
|
pub fn move_row_action(&mut self, sheet: u32, row: i32, delta: i32) -> Result<(), String> {
|
||||||
self.model.move_row_action(sheet, row, delta)
|
let diff_list = vec![Diff::MoveRow { sheet, row, delta }];
|
||||||
|
self.push_diff_list(diff_list);
|
||||||
|
self.model.move_row_action(sheet, row, delta)?;
|
||||||
|
self.evaluate_if_not_paused();
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the width of a group of columns in a single diff list
|
/// Sets the width of a group of columns in a single diff list
|
||||||
@@ -2308,6 +2320,21 @@ impl UserModel {
|
|||||||
self.model.delete_row_style(*sheet, *row)?;
|
self.model.delete_row_style(*sheet, *row)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Diff::MoveColumn {
|
||||||
|
sheet,
|
||||||
|
column,
|
||||||
|
delta,
|
||||||
|
} => {
|
||||||
|
// For undo, we apply the opposite move
|
||||||
|
self.model
|
||||||
|
.move_column_action(*sheet, *column + *delta, -*delta)?;
|
||||||
|
needs_evaluation = true;
|
||||||
|
}
|
||||||
|
Diff::MoveRow { sheet, row, delta } => {
|
||||||
|
// For undo, we apply the opposite move
|
||||||
|
self.model.move_row_action(*sheet, *row + *delta, -*delta)?;
|
||||||
|
needs_evaluation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needs_evaluation {
|
if needs_evaluation {
|
||||||
@@ -2515,6 +2542,18 @@ impl UserModel {
|
|||||||
} => {
|
} => {
|
||||||
self.model.delete_row_style(*sheet, *row)?;
|
self.model.delete_row_style(*sheet, *row)?;
|
||||||
}
|
}
|
||||||
|
Diff::MoveColumn {
|
||||||
|
sheet,
|
||||||
|
column,
|
||||||
|
delta,
|
||||||
|
} => {
|
||||||
|
self.model.move_column_action(*sheet, *column, *delta)?;
|
||||||
|
needs_evaluation = true;
|
||||||
|
}
|
||||||
|
Diff::MoveRow { sheet, row, delta } => {
|
||||||
|
self.model.move_row_action(*sheet, *row, *delta)?;
|
||||||
|
needs_evaluation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,16 @@ pub(crate) enum Diff {
|
|||||||
new_scope: Option<u32>,
|
new_scope: Option<u32>,
|
||||||
new_formula: String,
|
new_formula: String,
|
||||||
},
|
},
|
||||||
|
MoveColumn {
|
||||||
|
sheet: u32,
|
||||||
|
column: i32,
|
||||||
|
delta: i32,
|
||||||
|
},
|
||||||
|
MoveRow {
|
||||||
|
sheet: u32,
|
||||||
|
row: i32,
|
||||||
|
delta: i32,
|
||||||
|
},
|
||||||
// FIXME: we are missing SetViewDiffs
|
// FIXME: we are missing SetViewDiffs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user