forked from qt-creator/qt-creator
Gerrit: Disable buttons while fetch operation is in progress.
Gerrit operations should not be started in parallel since they use FETCH_HEAD, which can cause mix-ups. Change-Id: Icb421c8065f680a4bb93acd63e1ffe6309ce774a Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
ef65ce480d
commit
45b4ff4e74
@@ -104,6 +104,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
|
|||||||
, m_queryLineEdit(new QueryValidatingLineEdit)
|
, m_queryLineEdit(new QueryValidatingLineEdit)
|
||||||
, m_filterLineEdit(new Utils::FilterLineEdit)
|
, m_filterLineEdit(new Utils::FilterLineEdit)
|
||||||
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Close))
|
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Close))
|
||||||
|
, m_fetchRunning(false)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Gerrit %1@%2").arg(p->user, p->host));
|
setWindowTitle(tr("Gerrit %1@%2").arg(p->user, p->host));
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
@@ -266,6 +267,14 @@ const QStandardItem *GerritDialog::currentItem(int column) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GerritDialog::updateButtons()
|
||||||
|
{
|
||||||
|
const bool enabled = !m_fetchRunning && m_treeView->selectionModel()->currentIndex().isValid();
|
||||||
|
m_displayButton->setEnabled(enabled);
|
||||||
|
m_applyButton->setEnabled(enabled);
|
||||||
|
m_checkoutButton->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void GerritDialog::slotCurrentChanged()
|
void GerritDialog::slotCurrentChanged()
|
||||||
{
|
{
|
||||||
const QModelIndex current = m_treeView->selectionModel()->currentIndex();
|
const QModelIndex current = m_treeView->selectionModel()->currentIndex();
|
||||||
@@ -276,9 +285,27 @@ void GerritDialog::slotCurrentChanged()
|
|||||||
} else {
|
} else {
|
||||||
m_detailsBrowser->setText(QString());
|
m_detailsBrowser->setText(QString());
|
||||||
}
|
}
|
||||||
m_displayButton->setEnabled(valid);
|
updateButtons();
|
||||||
m_applyButton->setEnabled(valid);
|
}
|
||||||
m_checkoutButton->setEnabled(valid);
|
|
||||||
|
void GerritDialog::fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change)
|
||||||
|
{
|
||||||
|
// Disable buttons to prevent parallel gerrit operations which can cause mix-ups.
|
||||||
|
m_fetchRunning = true;
|
||||||
|
updateButtons();
|
||||||
|
const QString toolTip = tr("Fetching \"%1\"...").arg(change->title);
|
||||||
|
m_displayButton->setToolTip(toolTip);
|
||||||
|
m_applyButton->setToolTip(toolTip);
|
||||||
|
m_checkoutButton->setToolTip(toolTip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GerritDialog::fetchFinished()
|
||||||
|
{
|
||||||
|
m_fetchRunning = false;
|
||||||
|
updateButtons();
|
||||||
|
m_displayButton->setToolTip(QString());
|
||||||
|
m_applyButton->setToolTip(QString());
|
||||||
|
m_checkoutButton->setToolTip(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ signals:
|
|||||||
void fetchApply(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
void fetchApply(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
||||||
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||||
|
void fetchFinished();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotCurrentChanged();
|
void slotCurrentChanged();
|
||||||
void slotDoubleClicked(const QModelIndex &);
|
void slotDoubleClicked(const QModelIndex &);
|
||||||
@@ -98,6 +102,7 @@ private:
|
|||||||
const QStandardItem *currentItem(int column = 0) const;
|
const QStandardItem *currentItem(int column = 0) const;
|
||||||
QPushButton *addActionButton(const QString &text, const char *buttonSlot);
|
QPushButton *addActionButton(const QString &text, const char *buttonSlot);
|
||||||
void updateCompletions(const QString &query);
|
void updateCompletions(const QString &query);
|
||||||
|
void updateButtons();
|
||||||
|
|
||||||
const QSharedPointer<GerritParameters> m_parameters;
|
const QSharedPointer<GerritParameters> m_parameters;
|
||||||
QSortFilterProxyModel *m_filterModel;
|
QSortFilterProxyModel *m_filterModel;
|
||||||
@@ -112,6 +117,7 @@ private:
|
|||||||
QPushButton *m_applyButton;
|
QPushButton *m_applyButton;
|
||||||
QPushButton *m_checkoutButton;
|
QPushButton *m_checkoutButton;
|
||||||
QPushButton *m_refreshButton;
|
QPushButton *m_refreshButton;
|
||||||
|
bool m_fetchRunning;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -372,6 +372,9 @@ void GerritPlugin::openView()
|
|||||||
this, SLOT(fetchApply(QSharedPointer<Gerrit::Internal::GerritChange>)));
|
this, SLOT(fetchApply(QSharedPointer<Gerrit::Internal::GerritChange>)));
|
||||||
connect(gd, SIGNAL(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>)),
|
connect(gd, SIGNAL(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>)),
|
||||||
this, SLOT(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>)));
|
this, SLOT(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>)));
|
||||||
|
connect(this, SIGNAL(fetchStarted(QSharedPointer<Gerrit::Internal::GerritChange>)),
|
||||||
|
gd, SLOT(fetchStarted(QSharedPointer<Gerrit::Internal::GerritChange>)));
|
||||||
|
connect(this, SIGNAL(fetchFinished()), gd, SLOT(fetchFinished()));
|
||||||
m_dialog = gd;
|
m_dialog = gd;
|
||||||
}
|
}
|
||||||
const Qt::WindowStates state = m_dialog.data()->windowState();
|
const Qt::WindowStates state = m_dialog.data()->windowState();
|
||||||
@@ -442,6 +445,8 @@ void GerritPlugin::fetch(const QSharedPointer<Gerrit::Internal::GerritChange> &c
|
|||||||
|
|
||||||
FetchContext *fc = new FetchContext(change, repository, git,
|
FetchContext *fc = new FetchContext(change, repository, git,
|
||||||
m_parameters, FetchMode(mode), this);
|
m_parameters, FetchMode(mode), this);
|
||||||
|
connect(fc, SIGNAL(destroyed(QObject*)), this, SIGNAL(fetchFinished()));
|
||||||
|
emit fetchStarted(change);
|
||||||
fc->start();
|
fc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ public slots:
|
|||||||
void fetchApply(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
void fetchApply(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||||
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||||
|
void fetchFinished();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void openView();
|
void openView();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user