Commit aa6dd83e authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Git: Replace bool argument with flags

For a start, it's a single flag. Will be extended.

Also change the default for includeRemotes to false (most callers pass false)

Change-Id: I969f89a06b85a42c134c0232d2947d58fe19ea0d
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 25ddacc2
......@@ -114,7 +114,7 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory()
LogChangeDialog dialog(false, this);
dialog.setWindowTitle(tr("Select Commit"));
dialog.runDialog(workingDir, commit);
dialog.runDialog(workingDir, commit, LogChangeWidget::IncludeRemotes);
if (dialog.result() == QDialog::Rejected || dialog.commitIndex() == -1)
return;
......
......@@ -71,7 +71,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_ui->repositoryLabel->setText(tr("<b>Local repository:</b> %1").arg(
QDir::toNativeSeparators(workingDir)));
if (!m_ui->commitView->init(workingDir, QString(), false))
if (!m_ui->commitView->init(workingDir))
return;
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
......
......@@ -833,7 +833,7 @@ void GitPlugin::resetRepository()
LogChangeDialog dialog(true, Core::ICore::mainWindow());
ResetItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Undo Changes to %1").arg(QDir::toNativeSeparators(topLevel)));
if (dialog.runDialog(topLevel))
if (dialog.runDialog(topLevel, QString(), LogChangeWidget::IncludeRemotes))
m_gitClient->reset(topLevel, dialog.resetFlag(), dialog.commit());
}
......@@ -849,7 +849,7 @@ void GitPlugin::startRebase()
LogChangeDialog dialog(false, Core::ICore::mainWindow());
RebaseItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Interactive Rebase"));
if (!dialog.runDialog(topLevel, QString(), false))
if (!dialog.runDialog(topLevel))
return;
if (m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i")))
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false);
......
......@@ -98,7 +98,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
QVBoxLayout *logChangeLayout = new QVBoxLayout;
logChangeGroupBox->setLayout(logChangeLayout);
m_logChangeWidget = new LogChangeWidget;
m_logChangeWidget->init(repository, QString(), false);
m_logChangeWidget->init(repository);
connect(m_logChangeWidget, SIGNAL(doubleClicked(QString)), this, SIGNAL(show(QString)));
logChangeLayout->addWidget(m_logChangeWidget);
insertTopWidget(logChangeGroupBox);
......@@ -121,7 +121,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
void GitSubmitEditorWidget::refreshLog(const QString &repository)
{
if (m_logChangeWidget)
m_logChangeWidget->init(repository, QString(), false);
m_logChangeWidget->init(repository);
}
GitSubmitEditorPanelData GitSubmitEditorWidget::panelData() const
......
......@@ -71,13 +71,13 @@ LogChangeWidget::LogChangeWidget(QWidget *parent)
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitDoubleClicked(QModelIndex)));
}
bool LogChangeWidget::init(const QString &repository, const QString &commit, bool includeRemote)
bool LogChangeWidget::init(const QString &repository, const QString &commit, LogFlags flags)
{
if (!populateLog(repository, commit, includeRemote))
if (!populateLog(repository, commit, flags))
return false;
if (!m_model->rowCount()) {
VcsBase::VcsBaseOutputWindow::instance()->appendError(
GitPlugin::instance()->gitClient()->msgNoCommits(includeRemote));
GitPlugin::instance()->gitClient()->msgNoCommits(flags & IncludeRemotes));
return false;
}
return true;
......@@ -143,7 +143,7 @@ void LogChangeWidget::selectionChanged(const QItemSelection &selected,
}
}
bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, bool includeRemote)
bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, LogFlags flags)
{
const QString currentCommit = this->commit();
int selected = currentCommit.isEmpty() ? 0 : -1;
......@@ -155,7 +155,7 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
QStringList arguments;
arguments << QLatin1String("--max-count=40") << QLatin1String("--format=%h:%s %d");
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
if (!includeRemote)
if (!(flags & IncludeRemotes))
arguments << QLatin1String("--not") << QLatin1String("--remotes");
QString output;
if (!client->synchronousLog(repository, arguments, &output))
......@@ -231,9 +231,11 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
resize(600, 400);
}
bool LogChangeDialog::runDialog(const QString &repository, const QString &commit, bool includeRemote)
bool LogChangeDialog::runDialog(const QString &repository,
const QString &commit,
LogChangeWidget::LogFlags flags)
{
if (!m_widget->init(repository, commit, includeRemote))
if (!m_widget->init(repository, commit, flags))
return false;
if (QDialog::exec() == QDialog::Accepted) {
......
......@@ -53,9 +53,16 @@ class LogChangeWidget : public QTreeView
Q_OBJECT
public:
enum LogFlag
{
None = 0x00,
IncludeRemotes = 0x01
};
Q_DECLARE_FLAGS(LogFlags, LogFlag)
explicit LogChangeWidget(QWidget *parent = 0);
bool init(const QString &repository, const QString &commit = QString(),
bool includeRemote = true);
bool init(const QString &repository, const QString &commit = QString(), LogFlags flags = None);
QString commit() const;
int commitIndex() const;
QString earliestCommit() const;
......@@ -69,7 +76,7 @@ private slots:
private:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
bool populateLog(const QString &repository, const QString &commit, bool includeRemote);
bool populateLog(const QString &repository, const QString &commit, LogFlags flags);
const QStandardItem *currentItem(int column = 0) const;
QStandardItemModel *m_model;
......@@ -79,11 +86,12 @@ private:
class LogChangeDialog : public QDialog
{
Q_OBJECT
public:
LogChangeDialog(bool isReset, QWidget *parent);
bool runDialog(const QString &repository, const QString &commit = QString(),
bool includeRemote = true);
LogChangeWidget::LogFlags flags = LogChangeWidget::None);
QString commit() const;
int commitIndex() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment