Skip to content

Commit

Permalink
Fix work in progress not updated when reset
Browse files Browse the repository at this point in the history
  • Loading branch information
francescmm committed Feb 25, 2020
1 parent d28cf00 commit 79650b2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions big_widgets/GitQlientRepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ GitQlientRepo::GitQlientRepo(const QString &repoPath, QWidget *parent)
connect(mHistoryWidget, &HistoryWidget::signalUpdateUi, this, &GitQlientRepo::updateUiFromWatcher);
connect(mHistoryWidget, &HistoryWidget::signalShowFileHistory, this, &GitQlientRepo::showFileHistory);
connect(mHistoryWidget, &HistoryWidget::signalOpenFileCommit, this, &GitQlientRepo::loadFileDiff);
connect(mHistoryWidget, &HistoryWidget::signalUpdateWip, this, &GitQlientRepo::updateWip);

connect(mDiffWidget, &DiffWidget::signalShowFileHistory, this, &GitQlientRepo::showFileHistory);
connect(mDiffWidget, &DiffWidget::signalDiffEmpty, mControls, &Controls::disableDiff);
Expand Down Expand Up @@ -330,6 +331,13 @@ void GitQlientRepo::showPreviousView()
mControls->toggleButton(mPreviousView.first);
}

void GitQlientRepo::updateWip()
{
mHistoryWidget->resetWip();
mGitLoader.get()->updateWipRevision();
mHistoryWidget->updateUiFromWatcher();
}

void GitQlientRepo::openCommitDiff()
{
const auto currentSha = mHistoryWidget->getCurrentSha();
Expand Down
1 change: 1 addition & 0 deletions big_widgets/GitQlientRepo.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class GitQlientRepo : public QFrame
void showBlameView();
void showDiffView();
void showPreviousView();
void updateWip();

// End of MainWindow refactor
bool isMatch(const QString &sha, const QString &f, int cn, const QMap<QString, bool> &sm);
Expand Down
8 changes: 7 additions & 1 deletion big_widgets/HistoryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ HistoryWidget::HistoryWidget(const QSharedPointer<RevisionsCache> &cache, const
connect(mCommitWidget, &WorkInProgressWidget::signalChangesCommitted, this, &HistoryWidget::signalChangesCommitted);
connect(mCommitWidget, &WorkInProgressWidget::signalCheckoutPerformed, this, &HistoryWidget::signalUpdateUi);
connect(mCommitWidget, &WorkInProgressWidget::signalShowFileHistory, this, &HistoryWidget::signalShowFileHistory);
connect(mCommitWidget, &WorkInProgressWidget::signalUpdateWip, this, &HistoryWidget::signalUpdateWip);

connect(mRevisionWidget, &CommitInfoWidget::signalOpenFileCommit, this, &HistoryWidget::signalOpenFileCommit);
connect(mRevisionWidget, &CommitInfoWidget::signalShowFileHistory, this, &HistoryWidget::signalShowFileHistory);
Expand Down Expand Up @@ -107,13 +108,18 @@ HistoryWidget::~HistoryWidget()
void HistoryWidget::clear()
{
mRepositoryView->clear();
resetWip();
mBranchesWidget->clear();
mCommitWidget->clear();
mRevisionWidget->clear();

mCommitStackedWidget->setCurrentIndex(mCommitStackedWidget->currentIndex());
}

void HistoryWidget::resetWip()
{
mCommitWidget->clear();
}

void HistoryWidget::reload()
{
mBranchesWidget->showBranches();
Expand Down
2 changes: 2 additions & 0 deletions big_widgets/HistoryWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class HistoryWidget : public QFrame
void signalShowFileHistory(const QString &fileName);
void signalOpenFileCommit(const QString &currentSha, const QString &previousSha, const QString &file);
void signalAllBranchesActive(bool showAll);
void signalUpdateWip();

public:
explicit HistoryWidget(const QSharedPointer<RevisionsCache> &cache, const QSharedPointer<GitBase> git,
QWidget *parent = nullptr);
~HistoryWidget();
void clear();
void resetWip();
void reload();
void updateUiFromWatcher();
void focusOnCommit(const QString &sha);
Expand Down
7 changes: 3 additions & 4 deletions commits/WorkInProgressWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ void WorkInProgressWidget::resetFile(QListWidgetItem *item)
{
QScopedPointer<GitLocal> git(new GitLocal(mGit));
const auto ret = git->resetFile(item->toolTip());

if (ret.success)
emit signalCheckoutPerformed(ret.success);

const auto revInfo = mCache->getCommitInfo(mCurrentSha);
const auto files = mCache->getRevisionFile(mCurrentSha, revInfo.parent(0));

Expand Down Expand Up @@ -238,6 +234,9 @@ void WorkInProgressWidget::resetFile(QListWidgetItem *item)
}
}
}

if (ret.success)
emit signalUpdateWip();
}

void WorkInProgressWidget::insertFilesInList(const RevisionFiles &files, QListWidget *fileList)
Expand Down
1 change: 1 addition & 0 deletions commits/WorkInProgressWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class WorkInProgressWidget : public QWidget
void signalChangesCommitted(bool commited);
void signalCheckoutPerformed(bool success);
void signalShowFileHistory(const QString &fileName);
void signalUpdateWip();

public:
explicit WorkInProgressWidget(const QSharedPointer<RevisionsCache> &cache, const QSharedPointer<GitBase> &git,
Expand Down

0 comments on commit 79650b2

Please sign in to comment.