summaryrefslogtreecommitdiff
path: root/src/plugins/git/gitclient.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2010-12-09 15:53:45 +0100
committerTobias Hunger <tobias.hunger@nokia.com>2010-12-09 16:41:32 +0100
commit827800c2c4aff6f45cc239d7077e4d3d9c5b1ad1 (patch)
treedfd57e5382dd18de7332e2d0f9ecbbe314f045a2 /src/plugins/git/gitclient.cpp
parent1312a04221e98db436c55bc2df09c8b8435c5d03 (diff)
downloadqt-creator-827800c2c4aff6f45cc239d7077e4d3d9c5b1ad1.tar.gz
Git: Allow for pretty format selection in git show
Allow for pretty format selection in git show. Save selected value and default to "email". Task-number: QTCREATORBUG-3341
Diffstat (limited to 'src/plugins/git/gitclient.cpp')
-rw-r--r--src/plugins/git/gitclient.cpp84
1 files changed, 71 insertions, 13 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index f9d91c97b0..09a3b504f0 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -63,6 +63,7 @@
#include <QtCore/QDir>
#include <QtCore/QSignalMapper>
+#include <QtGui/QComboBox>
#include <QtGui/QMainWindow> // for msg box parent
#include <QtGui/QMessageBox>
#include <QtGui/QToolButton>
@@ -121,19 +122,42 @@ public:
m_ignoreSpaces->setCheckable(true);
m_ignoreSpaces->setChecked(m_settings->ignoreSpaceChangesInDiff);
connect(m_ignoreSpaces, SIGNAL(toggled(bool)), this, SLOT(testForArgumentsChanged()));
+
+ m_prettyFormat = new QComboBox;
+ m_prettyFormat->setToolTip(tr("Select the pretty printing format"));
+ m_prettyFormat->addItem(tr("oneline"), QLatin1String("oneline"));
+ m_prettyFormat->addItem(tr("short"), QLatin1String("short"));
+ m_prettyFormat->addItem(tr("medium"), QLatin1String("medium"));
+ m_prettyFormat->addItem(tr("full"), QLatin1String("full"));
+ m_prettyFormat->addItem(tr("fuller"), QLatin1String("fuller"));
+ m_prettyFormat->addItem(tr("email"), QLatin1String("email"));
+ m_prettyFormat->addItem(tr("raw"), QLatin1String("raw"));
+ layout->addWidget(m_prettyFormat);
+ m_prettyFormat->setCurrentIndex(m_settings->showPrettyFormat);
+ m_prettyFormat->setVisible(false);
+ connect(m_prettyFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(testForArgumentsChanged()));
}
QStringList arguments() const
{
- QStringList args = m_diffArgs;
-
- args.removeAll(QLatin1String("--patience"));
- args.removeAll(QLatin1String("--ignore-space-change"));
+ QStringList args;
+ foreach (const QString &arg, m_diffArgs) {
+ if (arg == QLatin1String("--patience")
+ || arg == QLatin1String("--ignore-space-change")
+ || arg.startsWith(QLatin1String("--pretty="))
+ || arg.startsWith(QLatin1String("--format=")))
+ continue;
+ args.append(arg);
+ }
- if (m_patience->isChecked())
+ if (m_patience->isChecked() && m_patience->isVisible())
args.prepend(QLatin1String("--patience"));
- if (m_ignoreSpaces->isChecked())
+ if (m_ignoreSpaces->isChecked() && m_ignoreSpaces->isVisible())
args.prepend(QLatin1String("--ignore-space-change"));
+ if (m_prettyFormat->isVisible()) {
+ args.prepend(QString::fromLatin1("--pretty=")
+ + m_prettyFormat->itemData(m_prettyFormat->currentIndex()).toString());
+ }
return args;
}
@@ -141,6 +165,7 @@ public:
void testForArgumentsChanged() {
m_settings->diffPatience = m_patience->isChecked();
m_settings->ignoreSpaceChangesInDiff = m_ignoreSpaces->isChecked();
+ m_settings->showPrettyFormat = m_prettyFormat->currentIndex();
QStringList newArguments = arguments();
@@ -151,9 +176,10 @@ public:
redoCommand();
}
-private:
+protected:
QToolButton *m_patience;
QToolButton *m_ignoreSpaces;
+ QComboBox *m_prettyFormat;
};
class GitCommitDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
@@ -216,6 +242,30 @@ private:
const QString m_branchName;
};
+class GitShowArgumentsWidget : public BaseGitDiffArgumentsWidget
+{
+public:
+ GitShowArgumentsWidget(Git::Internal::GitSettings *settings,
+ Git::Internal::GitClient *client, const QString &directory,
+ const QStringList &args, const QString &id) :
+ BaseGitDiffArgumentsWidget(settings, client, directory, args),
+ m_id(id)
+ {
+ m_patience->setVisible(false);
+ m_ignoreSpaces->setVisible(false);
+ m_prettyFormat->setVisible(true);
+ }
+
+ void redoCommand()
+ {
+ m_client->show(m_workingDirectory, m_id, m_diffArgs);
+ }
+
+private:
+ const QString m_id;
+};
+
+
class GitBlameArgumentsWidget : public Git::Internal::BaseGitArgumentsWidget
{
public:
@@ -631,7 +681,7 @@ static inline QString msgCannotShow(const QString &sha)
return GitClient::tr("Cannot describe '%1'.").arg(sha);
}
-void GitClient::show(const QString &source, const QString &id)
+void GitClient::show(const QString &source, const QString &id, const QStringList &args)
{
if (Git::Constants::debug)
qDebug() << "show" << source << id;
@@ -640,14 +690,22 @@ void GitClient::show(const QString &source, const QString &id)
return;
}
- QStringList arguments;
- arguments << QLatin1String("show") << QLatin1String(noColorOption) << id;
-
+ QStringList userArgs = args;
const QString title = tr("Git Show %1").arg(id);
const QString editorId = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_ID);
VCSBase::VCSBaseEditor *editor = findExistingVCSEditor("show", id);
- if (!editor)
- editor = createVCSEditor(editorId, title, source, true, "show", id, 0);
+ if (!editor) {
+ GitShowArgumentsWidget *argWidget =
+ new GitShowArgumentsWidget(&m_settings, this, source,
+ QStringList(), id);
+ userArgs = argWidget->arguments();
+ editor = createVCSEditor(editorId, title, source, true, "show", id, argWidget);
+ }
+
+ QStringList arguments;
+ arguments << QLatin1String("show") << QLatin1String(noColorOption);
+ arguments.append(userArgs);
+ arguments << id;
const QFileInfo sourceFi(source);
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();