Merge pull request #883 from manongjohn/autorenumber_column

Autorenumber column
This commit is contained in:
manongjohn 2022-01-31 18:24:16 -05:00 committed by GitHub
commit f877ebbba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 0 deletions

View file

@ -433,6 +433,9 @@ class RenumberUndo::RedoNotifier final : public TUndo {
}
int getSize() const override { return sizeof(*this); }
QString getHistoryString() override { return QObject::tr("Autorenumber"); }
int getHistoryType() override { return HistoryType::Xsheet; }
};
class RenumberUndo::UndoNotifier final : public TUndo {
@ -443,6 +446,9 @@ class RenumberUndo::UndoNotifier final : public TUndo {
}
int getSize() const override { return sizeof(*this); }
QString getHistoryString() override { return QObject::tr("Autorenumber"); }
int getHistoryType() override { return HistoryType::Xsheet; }
};
//=============================================================================

View file

@ -805,6 +805,31 @@ void TColumnSelection::reframeWithEmptyInbetweens() {
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
//=============================================================================
void TColumnSelection::renumberColumns() {
if (isEmpty()) return;
int rowCount =
TApp::instance()->getCurrentXsheet()->getXsheet()->getFrameCount();
std::vector<int> colIndeces;
std::set<int>::const_iterator it;
TUndoManager *undoManager = TUndoManager::manager();
undoManager->beginBlock();
for (it = m_indices.begin(); it != m_indices.end(); it++) {
TCellSelection selection;
selection.selectCells(0, *it, rowCount, *it);
selection.dRenumberCells();
}
undoManager->endBlock();
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
//*********************************************************************************
// Reset Step Cells command
//*********************************************************************************

View file

@ -94,6 +94,7 @@ void TColumnSelection::enableCommands() {
enableCommand(this, MI_Reframe4, &TColumnSelection::reframe4Cells);
enableCommand(this, MI_ReframeWithEmptyInbetweens,
&TColumnSelection::reframeWithEmptyInbetweens);
enableCommand(this, MI_Autorenumber, &TColumnSelection::renumberColumns);
}
//-----------------------------------------------------------------------------

View file

@ -53,6 +53,8 @@ public:
void reframe4Cells() { reframeCells(4); }
void reframeWithEmptyInbetweens();
void renumberColumns();
};
#endif // TCELLSELECTION_H

View file

@ -2919,6 +2919,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
}
menu.addMenu(reframeSubMenu);
menu.addAction(cmdManager->getAction(MI_AutoInputCellNumber));
menu.addAction(cmdManager->getAction(MI_Autorenumber));
}
if (containsRasterLevel(m_viewer->getColumnSelection())) {