/trunk/Scribus/scribus/canvasgesture_columnresize.cpp |
---|
18,6 → 18,7 |
#include "pageitem_table.h" |
#include "scribusdoc.h" |
#include "scribusview.h" |
#include "undomanager.h" |
#include "canvasgesture_columnresize.h" |
60,6 → 61,10 |
else |
strategy = PageItem_Table::ResizeFollowing; |
UndoTransaction activeTransaction; |
if (UndoManager::undoEnabled()) |
activeTransaction = UndoManager::instance()->beginTransaction(table()->getUName(), table()->getUPixmap(), Um::TableColumnWidth, QString(), Um::ITable); |
table()->doc()->dontResize = true; |
table()->resizeColumn(m_column, gridPoint.x() - table()->columnPosition(m_column), strategy); |
if (strategy == PageItem_Table::MoveFollowing) |
72,6 → 77,9 |
table()->doc()->setRedrawBounding(table()); |
table()->update(); |
if (activeTransaction) |
activeTransaction.commit(); |
m_view->stopGesture(); |
} |
/trunk/Scribus/scribus/canvasgesture_rowresize.cpp |
---|
18,6 → 18,7 |
#include "pageitem_table.h" |
#include "scribusdoc.h" |
#include "scribusview.h" |
#include "undomanager.h" |
#include "canvasgesture_rowresize.h" |
60,6 → 61,10 |
else |
strategy = PageItem_Table::ResizeFollowing; |
UndoTransaction activeTransaction; |
if (UndoManager::undoEnabled()) |
activeTransaction = UndoManager::instance()->beginTransaction(table()->getUName(), table()->getUPixmap(), Um::TableRowHeight, QString(), Um::ITable); |
table()->doc()->dontResize = true; |
table()->resizeRow(m_row, gridPoint.y() - table()->rowPosition(m_row), strategy); |
if (strategy == PageItem_Table::MoveFollowing) |
72,6 → 77,9 |
table()->doc()->setRedrawBounding(table()); |
table()->update(); |
if (activeTransaction) |
activeTransaction.commit(); |
m_view->stopGesture(); |
} |
/trunk/Scribus/scribus/pageitem_table.cpp |
---|
758,7 → 758,16 |
if (!validRow(row)) |
return; |
if (UndoManager::undoEnabled()) |
{ |
SimpleState *ss = new SimpleState(Um::TableRowHeight, QString(), Um::IResize); |
ss->set("TABLE_ROW_HEIGHT"); |
ss->set("ROW", row); |
ss->set("OLD_ROW_HEIGHT", rowHeight(row)); |
ss->set("NEW_ROW_HEIGHT", height); |
ss->set("ROW_RESIZE_STRATEGY", strategy == MoveFollowing ? 0 : 1); |
undoManager->action(this, ss); |
} |
if (strategy == MoveFollowing) |
resizeRowMoveFollowing(row, height); |
else if (strategy == ResizeFollowing) |
820,7 → 829,16 |
if (!validColumn(column)) |
return; |
if (UndoManager::undoEnabled()) |
{ |
SimpleState *ss = new SimpleState(Um::TableColumnWidth, QString(), Um::IResize); |
ss->set("TABLE_COLUMN_WIDTH"); |
ss->set("COLUMN", column); |
ss->set("OLD_COLUMN_WIDTH", columnWidth(column)); |
ss->set("NEW_COLUMN_WIDTH", width); |
ss->set("COLUMN_RESIZE_STRATEGY", strategy == MoveFollowing ? 0 : 1); |
undoManager->action(this, ss); |
} |
if (strategy == MoveFollowing) |
resizeColumnMoveFollowing(column, width); |
else if (strategy == ResizeFollowing) |
2181,6 → 2199,16 |
restoreTableStyleReset(simpleState, isUndo); |
doUpdate = true; |
} |
else if (simpleState->contains("TABLE_ROW_HEIGHT")) |
{ |
restoreTableRowHeight(simpleState, isUndo); |
doUpdate = true; |
} |
else if (simpleState->contains("TABLE_COLUMN_WIDTH")) |
{ |
restoreTableColumnWidth(simpleState, isUndo); |
doUpdate = true; |
} |
else |
{ |
PageItem::restore(state, isUndo); |
2490,4 → 2518,36 |
{ |
QString restoredStyle = state->get(isUndo ? "OLD_STYLE" : "NEW_STYLE"); |
setStyle(restoredStyle); |
} |
} |
void PageItem_Table::restoreTableRowHeight(SimpleState *state, bool isUndo) |
{ |
int row = state->getInt("ROW"); |
ResizeStrategy strategy = state->getInt("ROW_RESIZE_STRATEGY") == 0 ? MoveFollowing : ResizeFollowing; |
if (isUndo) |
{ |
double oldHeight = state->getDouble("OLD_ROW_HEIGHT"); |
resizeRow(row, oldHeight, strategy); |
} |
else |
{ |
double newHeight = state->getDouble("NEW_ROW_HEIGHT"); |
resizeRow(row, newHeight, strategy); |
} |
} |
void PageItem_Table::restoreTableColumnWidth(SimpleState *state, bool isUndo) |
{ |
int column = state->getInt("COLUMN"); |
ResizeStrategy strategy = state->getInt("COLUMN_RESIZE_STRATEGY") == 0 ? MoveFollowing : ResizeFollowing; |
if (isUndo) |
{ |
double oldWidth = state->getDouble("OLD_COLUMN_WIDTH"); |
resizeColumn(column, oldWidth, strategy); |
} |
else |
{ |
double newWidth = state->getDouble("NEW_COLUMN_WIDTH"); |
resizeColumn(column, newWidth, strategy); |
} |
} |
/trunk/Scribus/scribus/pageitem_table.h |
---|
699,6 → 699,12 |
// Undo/redo unsetStyle action |
void restoreTableStyleReset(SimpleState *state, bool isUndo); |
// Undo/redo row height action |
void restoreTableRowHeight(SimpleState *state, bool isUndo); |
// Undo/redo column widht action |
void restoreTableColumnWidth(SimpleState *state, bool isUndo); |
private: |
//<<Data we need to save |
/// List of rows of cells in the table. |
/trunk/Scribus/scribus/scribusdoc.cpp |
---|
8687,6 → 8687,10 |
const qreal rowHeight = dialog->rowHeight(); |
QScopedValueRollback<bool> dontResizeRb(dontResize, true); |
UndoTransaction activeTransaction; |
m_updateManager.setUpdatesDisabled(); |
if (UndoManager::undoEnabled()) |
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::TableRowHeight, item->itemName(), Um::ITable); |
if (appMode == modeEditTable) |
{ |
if (table->selectedCells().isEmpty()) |
8711,12 → 8715,12 |
for (int row = 0; row < table->rows(); ++row) |
table->resizeRow(row, rowHeight / unitRatio()); |
} |
delete dialog; |
table->adjustTable(); |
table->update(); |
if (activeTransaction) |
activeTransaction.commit(); |
m_updateManager.setUpdatesEnabled(); |
changed(); |
} |
8737,6 → 8741,11 |
const qreal columnWidth = dialog->columnWidth(); |
QScopedValueRollback<bool> dontResizeRb(dontResize, true); |
UndoTransaction activeTransaction; |
m_updateManager.setUpdatesDisabled(); |
if (UndoManager::undoEnabled()) |
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::TableColumnWidth, item->itemName(), Um::ITable); |
if (appMode == modeEditTable) |
{ |
if (table->selectedCells().isEmpty()) |
8766,6 → 8775,9 |
table->adjustTable(); |
table->update(); |
if (activeTransaction) |
activeTransaction.commit(); |
m_updateManager.setUpdatesEnabled(); |
changed(); |
} |