Skip to content

Commit

Permalink
Add "Unresolve" to correction table
Browse files Browse the repository at this point in the history
When accidentally mark a row in the correction table as resolved, it can
now also be reverted. When clicking on "Unresolve" the status will be
changed to "Changed".
  • Loading branch information
schroedtert committed Nov 30, 2024
1 parent 087b8a8 commit 6cabbcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
29 changes: 24 additions & 5 deletions src/ui/main-windows/correction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ void FailedChecksTableModel::updateState(const QModelIndex &row, plausibility::C
emit layoutChanged();
}

plausibility::CheckStatus FailedChecksTableModel::getState(const QModelIndex &row) const
{
return mFailedChecks.at(row.row()).status;
}


Correction::Correction(Petrack *petrack, const PersonStorage &personStorage, QWidget *parent) :
QWidget(parent), mPetrack(petrack), mPersonStorage(personStorage), mUi(new Ui::Correction)
{
Expand Down Expand Up @@ -272,20 +278,33 @@ void Correction::openContextMenu()
return;
}

QMenu contextMenu(tr("&Correction"), this);
QAction markResolvedAction("Mark as resolved", this);
QMenu contextMenu(tr("&Correction"), this);
const auto checkStatus = getStatus(selectedIndex);
QString actionText("Mark as resolved");
auto actionStatus = plausibility::CheckStatus::Resolved;

if(checkStatus == plausibility::CheckStatus::Resolved)
{
actionText = "Unresolve";
actionStatus = plausibility::CheckStatus::Changed;
}
QAction markResolvedAction(actionText, this);
connect(
&markResolvedAction,
&QAction::triggered,
this,
[this, &selectedIndex]() { this->markResolved(selectedIndex); });
[this, &selectedIndex, &actionStatus]() { this->changeStatus(selectedIndex, actionStatus); });
contextMenu.addAction(&markResolvedAction);
contextMenu.exec(QCursor::pos());
}

void Correction::markResolved(QList<QModelIndex> pos)
plausibility::CheckStatus Correction::getStatus(QList<QModelIndex> pos) const
{
return mTableModel->getState(pos[0]);
}
void Correction::changeStatus(QList<QModelIndex> pos, plausibility::CheckStatus status)
{
mTableModel->updateState(pos[0], plausibility::CheckStatus::Resolved);
mTableModel->updateState(pos[0], status);
}

void Correction::changePersonState(size_t index)
Expand Down
20 changes: 11 additions & 9 deletions src/ui/main-windows/correction.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class FailedChecksTableModel : public QAbstractTableModel
std::vector<plausibility::FailedCheck> getFailedChecks();
const plausibility::FailedCheck &getFailedCheck(const QModelIndex &row);

void updateState(const QModelIndex &row, plausibility::CheckStatus state);
void updateState(const QModelIndex &row, plausibility::CheckStatus state);
plausibility::CheckStatus getState(const QModelIndex &row) const;
};


Expand Down Expand Up @@ -96,14 +97,15 @@ class Correction : public QWidget
std::vector<plausibility::FailedCheck> rerunChecks();

private slots:
void selectedRowChanged();
void checkButtonClicked();
void openContextMenu();
void markResolved(QList<QModelIndex> pos);
void changePersonState(size_t index);
void removePerson(size_t index);
void removePersonInFrameRange(size_t index, int startFrame, int endFrame);
void splitPerson(size_t, size_t newIndex, int frame);
void selectedRowChanged();
void checkButtonClicked();
void openContextMenu();
void changeStatus(QList<QModelIndex> pos, plausibility::CheckStatus status);
plausibility::CheckStatus getStatus(QList<QModelIndex> pos) const;
void changePersonState(size_t index);
void removePerson(size_t index);
void removePersonInFrameRange(size_t index, int startFrame, int endFrame);
void splitPerson(size_t, size_t newIndex, int frame);
};

#endif // CORRECTION_H

0 comments on commit 6cabbcb

Please sign in to comment.