Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/application/LayoutReviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ LayoutReviewWidget::LayoutReviewWidget(
connect(undoShortcut, &QShortcut::activated, this, [this]() {
undoLastEdit();
});
auto* redoShortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+Shift+Z")), this);
connect(redoShortcut, &QShortcut::activated, this, [this]() {
redoLastUndo();
});

applyImportResultState();

Expand All @@ -444,17 +448,31 @@ const safecrowd::domain::ImportResult& LayoutReviewWidget::currentImportResult()
}

bool LayoutReviewWidget::undoLastEdit() {
if (undoHistory_.empty()) {
if (undoHistory_.empty() || !importResult_.layout.has_value()) {
return false;
}

redoHistory_.push_back(*importResult_.layout);
importResult_.layout = undoHistory_.back();
undoHistory_.pop_back();
importResult_.reviewStatus = safecrowd::domain::ImportReviewStatus::Pending;
applyImportResultState();
return true;
}

bool LayoutReviewWidget::redoLastUndo() {
if (redoHistory_.empty() || !importResult_.layout.has_value()) {
return false;
}

undoHistory_.push_back(*importResult_.layout);
importResult_.layout = redoHistory_.back();
redoHistory_.pop_back();
importResult_.reviewStatus = safecrowd::domain::ImportReviewStatus::Pending;
applyImportResultState();
return true;
}

void LayoutReviewWidget::handleIssueSelected(const safecrowd::domain::ImportIssue& issue) {
selectedIssueTargetId_ = issueTarget(issue);
selectedIssueCode_ = issueCodeText(issue);
Expand All @@ -480,6 +498,7 @@ void LayoutReviewWidget::handleLayoutEdited(const safecrowd::domain::FacilityLay
if (importResult_.layout.has_value()) {
undoHistory_.push_back(*importResult_.layout);
}
redoHistory_.clear();
importResult_.layout = layout;
importResult_.reviewStatus = safecrowd::domain::ImportReviewStatus::Pending;
applyImportResultState();
Expand Down
2 changes: 2 additions & 0 deletions src/application/LayoutReviewWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LayoutReviewWidget : public QWidget {

const safecrowd::domain::ImportResult& currentImportResult() const noexcept;
bool undoLastEdit();
bool redoLastUndo();

private:
enum class NavigationView {
Expand Down Expand Up @@ -61,6 +62,7 @@ class LayoutReviewWidget : public QWidget {
std::function<void(const safecrowd::domain::ImportResult&)> approvalHandler_{};
std::function<void(const safecrowd::domain::ImportResult&)> reimportHandler_{};
std::vector<safecrowd::domain::FacilityLayout2D> undoHistory_{};
std::vector<safecrowd::domain::FacilityLayout2D> redoHistory_{};
WorkspaceShell* shell_{nullptr};
LayoutPreviewWidget* preview_{nullptr};
QLabel* inspectorTitleLabel_{nullptr};
Expand Down
Loading
Loading