Commit f84c2285 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: Add options to diff editor

parent fcdd588b
This diff is collapsed.
/**************************************************************************
/**************************************************************************
**
** This file is part of Qt Creator
**
......@@ -37,8 +37,10 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QErrorMessage;
class QSignalMapper;
class QDebug;
......@@ -91,7 +93,7 @@ public:
void graphLog(const QString &workingDirectory, const QString &branch);
void log(const QString &workingDirectory, const QStringList &fileNames,
bool enableAnnotationContextMenu = false);
void blame(const QString &workingDirectory, const QString &fileName,
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
const QString &revision = QString(), int lineNumber = -1);
void checkout(const QString &workingDirectory, const QString &file);
void checkoutBranch(const QString &workingDirectory, const QString &branch);
......@@ -229,12 +231,15 @@ private slots:
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
private:
VCSBase::VCSBaseEditor *findExistingVCSEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const;
VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind,
QString title,
const QString &source,
bool setSourceCodec,
const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const;
QString title,
const QString &source,
bool setSourceCodec,
const char *registerDynamicProperty,
const QString &dynamicPropertyValue,
QWidget *configWidget) const;
GitCommand *createCommand(const QString &workingDirectory,
VCSBase::VCSBaseEditor* editor = 0,
......@@ -288,6 +293,28 @@ private:
bool m_hasCachedGitVersion;
};
class BaseGitArgumentsWidget : public QWidget {
Q_OBJECT
public:
BaseGitArgumentsWidget(GitSettings *settings,
GitClient *client, const QString &directory,
const QStringList &args);
virtual QStringList arguments() const = 0;
virtual void redoCommand() = 0;
protected slots:
virtual void testForArgumentsChanged() = 0;
protected:
GitClient *m_client;
const QString m_workingDirectory;
QStringList m_diffArgs;
GitSettings *m_settings;
};
} // namespace Internal
} // namespace Git
......
......@@ -47,7 +47,7 @@ class GitEditor : public VCSBase::VCSBaseEditor
public:
explicit GitEditor(const VCSBase::VCSBaseEditorParameters *type,
QWidget *parent);
QWidget *parent);
public slots:
void setPlainTextDataFiltered(const QByteArray &a);
......
......@@ -596,7 +596,7 @@ void GitPlugin::blameFile()
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
const int lineNumber = VCSBase::VCSBaseEditor::lineNumberOfCurrentEditor(state.currentFile());
m_gitClient->blame(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), lineNumber);
m_gitClient->blame(state.currentFileTopLevel(), QStringList(), state.relativeCurrentFile(), QString(), lineNumber);
}
void GitPlugin::logProject()
......
......@@ -44,7 +44,8 @@ static const char timeoutKeyC[] = "TimeOut";
static const char pullRebaseKeyC[] = "PullRebase";
static const char promptToSubmitKeyC[] = "PromptForSubmit";
static const char omitAnnotationDateKeyC[] = "OmitAnnotationDate";
static const char ignoreSpaceChangesC[] = "SpaceIgnorantBlame";
static const char ignoreSpaceChangesBlameKeyC[] = "SpaceIgnorantBlame";
static const char ignoreSpaceChangesDiffKeyC[] = "SpaceIgnorantDiff";
static const char diffPatienceKeyC[] = "DiffPatience";
static const char winSetHomeEnvironmentKeyC[] = "WinSetHomeEnvironment";
static const char gitkOptionsKeyC[] = "GitKOptions";
......@@ -69,7 +70,8 @@ GitSettings::GitSettings() :
pullRebase(bool(defaultPullRebase)),
promptToSubmit(true),
omitAnnotationDate(false),
ignoreSpaceChanges(true),
ignoreSpaceChangesInDiff(false),
ignoreSpaceChangesInBlame(true),
diffPatience(true),
winSetHomeEnvironment(false)
{
......@@ -85,7 +87,8 @@ void GitSettings::fromSettings(QSettings *settings)
pullRebase = settings->value(QLatin1String(pullRebaseKeyC), bool(defaultPullRebase)).toBool();
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
omitAnnotationDate = settings->value(QLatin1String(omitAnnotationDateKeyC), false).toBool();
ignoreSpaceChanges = settings->value(QLatin1String(ignoreSpaceChangesC), true).toBool();
ignoreSpaceChangesInDiff = settings->value(QLatin1String(ignoreSpaceChangesDiffKeyC), true).toBool();
ignoreSpaceChangesInBlame = settings->value(QLatin1String(ignoreSpaceChangesBlameKeyC), true).toBool();
diffPatience = settings->value(QLatin1String(diffPatienceKeyC), true).toBool();
winSetHomeEnvironment = settings->value(QLatin1String(winSetHomeEnvironmentKeyC), false).toBool();
gitkOptions = settings->value(QLatin1String(gitkOptionsKeyC)).toString();
......@@ -102,7 +105,8 @@ void GitSettings::toSettings(QSettings *settings) const
settings->setValue(QLatin1String(pullRebaseKeyC), pullRebase);
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
settings->setValue(QLatin1String(omitAnnotationDateKeyC), omitAnnotationDate);
settings->setValue(QLatin1String(ignoreSpaceChangesC), ignoreSpaceChanges);
settings->setValue(QLatin1String(ignoreSpaceChangesDiffKeyC), ignoreSpaceChangesInDiff);
settings->setValue(QLatin1String(ignoreSpaceChangesBlameKeyC), ignoreSpaceChangesInBlame);
settings->setValue(QLatin1String(diffPatienceKeyC), diffPatience);
settings->setValue(QLatin1String(winSetHomeEnvironmentKeyC), winSetHomeEnvironment);
settings->setValue(QLatin1String(gitkOptionsKeyC), gitkOptions);
......@@ -114,7 +118,9 @@ bool GitSettings::equals(const GitSettings &s) const
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount
&& timeoutSeconds == s.timeoutSeconds && promptToSubmit == s.promptToSubmit
&& pullRebase == s.pullRebase
&& omitAnnotationDate == s.omitAnnotationDate && ignoreSpaceChanges == s.ignoreSpaceChanges
&& omitAnnotationDate == s.omitAnnotationDate
&& ignoreSpaceChangesInBlame == s.ignoreSpaceChangesInBlame
&& ignoreSpaceChangesInDiff == s.ignoreSpaceChangesInDiff
&& diffPatience == s.diffPatience && winSetHomeEnvironment == s.winSetHomeEnvironment
&& gitkOptions == s.gitkOptions;
}
......
......@@ -59,7 +59,8 @@ struct GitSettings
bool pullRebase;
bool promptToSubmit;
bool omitAnnotationDate;
bool ignoreSpaceChanges;
bool ignoreSpaceChangesInDiff;
bool ignoreSpaceChangesInBlame;
bool diffPatience;
bool winSetHomeEnvironment;
QString gitkOptions;
......
......@@ -232,7 +232,7 @@ bool GitVersionControl::managesDirectory(const QString &directory, QString *topL
bool GitVersionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
gitClient()->blame(fi.absolutePath(), fi.fileName(), QString(), line);
gitClient()->blame(fi.absolutePath(), QStringList(), fi.fileName(), QString(), line);
return true;
}
......
......@@ -73,9 +73,6 @@ GitSettings SettingsPageWidget::settings() const
rc.timeoutSeconds = m_ui.timeoutSpinBox->value();
rc.pullRebase = m_ui.pullRebaseCheckBox->isChecked();
rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
rc.omitAnnotationDate = m_ui.omitAnnotationDataCheckBox->isChecked();
rc.ignoreSpaceChanges = m_ui.spaceIgnorantBlameCheckBox->isChecked();
rc.diffPatience = m_ui.diffPatienceCheckBox->isChecked();
rc.winSetHomeEnvironment = m_ui.winHomeCheckBox->isChecked();
rc.gitkOptions = m_ui.gitkOptionsLineEdit->text().trimmed();
return rc;
......@@ -89,9 +86,6 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
m_ui.timeoutSpinBox->setValue(s.timeoutSeconds);
m_ui.pullRebaseCheckBox->setChecked(s.pullRebase);
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
m_ui.omitAnnotationDataCheckBox->setChecked(s.omitAnnotationDate);
m_ui.spaceIgnorantBlameCheckBox->setChecked(s.ignoreSpaceChanges);
m_ui.diffPatienceCheckBox->setChecked(s.diffPatience);
m_ui.winHomeCheckBox->setChecked(s.winSetHomeEnvironment);
m_ui.gitkOptionsLineEdit->setText(s.gitkOptions);
}
......@@ -108,9 +102,7 @@ QString SettingsPageWidget::searchKeywords() const
<< ' ' << m_ui.timeoutLabel->text()
<< ' ' << m_ui.promptToSubmitCheckBox->text()
<< ' ' << m_ui.promptToSubmitCheckBox->text()
<< ' ' << m_ui.omitAnnotationDataCheckBox->text()
<< ' ' << m_ui.environmentGroupBox->title()
<< ' ' << m_ui.spaceIgnorantBlameCheckBox->text();
<< ' ' << m_ui.environmentGroupBox->title();
rc.remove(QLatin1Char('&'));
return rc;
}
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>361</width>
<width>390</width>
<height>444</height>
</rect>
</property>
......@@ -128,27 +128,6 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="omitAnnotationDataCheckBox">
<property name="text">
<string>Omit date from blame output</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="spaceIgnorantBlameCheckBox">
<property name="text">
<string>Ignore whitespace changes in blame and diff</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="diffPatienceCheckBox">
<property name="text">
<string>Use &quot;patience diff&quot; algorithm</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="pullRebaseCheckBox">
<property name="text">
......
......@@ -5927,7 +5927,7 @@ BaseTextEditorEditable::BaseTextEditorEditable(BaseTextEditor *editor)
QWidget *w = new QWidget;
l->setMargin(0);
l->setContentsMargins(5, 0, 5, 0);
l->addStretch(0);
// l->addStretch(0);
l->addWidget(m_cursorPositionLabel);
w->setLayout(l);
......
......@@ -573,7 +573,7 @@ public:
inline QByteArray saveState() const { return e->saveState(); }
inline bool restoreState(const QByteArray &state) { return e->restoreState(state); }
QWidget *toolBar();
virtual QWidget *toolBar();
// ITextEditor
int find(const QString &string) const;
......
......@@ -131,7 +131,6 @@ VCSBaseDiffEditorEditable::VCSBaseDiffEditorEditable(VCSBaseEditor *e, const VCS
m_diffFileBrowseComboBox(new QComboBox(m_toolBar))
{
m_diffFileBrowseComboBox->setMinimumContentsLength(20);
m_diffFileBrowseComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
// Make the combo box prefer to expand
QSizePolicy policy = m_diffFileBrowseComboBox->sizePolicy();
policy.setHorizontalPolicy(QSizePolicy::Expanding);
......@@ -163,6 +162,8 @@ struct VCSBaseEditorPrivate
QString m_annotatePreviousRevisionTextFormat;
QString m_copyRevisionTextFormat;
bool m_fileLogAnnotateEnabled;
QToolBar *m_toolBar;
QWidget *m_configurationWidget;
};
VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type) :
......@@ -170,7 +171,9 @@ VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type)
m_cursorLine(-1),
m_annotateRevisionTextFormat(VCSBaseEditor::tr("Annotate \"%1\"")),
m_copyRevisionTextFormat(VCSBaseEditor::tr("Copy \"%1\"")),
m_fileLogAnnotateEnabled(false)
m_fileLogAnnotateEnabled(false),
m_toolBar(0),
m_configurationWidget(0)
{
}
......@@ -325,6 +328,8 @@ TextEditor::BaseTextEditorEditable *VCSBaseEditor::createEditableInterface()
} else {
editable = new VCSBaseEditorEditable(this, d->m_parameters);
}
d->m_toolBar = qobject_cast<QToolBar *>(editable->toolBar());
// Pass on signals.
connect(this, SIGNAL(describeRequested(QString,QString)),
editable, SIGNAL(describeRequested(QString,QString)));
......@@ -829,6 +834,30 @@ QString VCSBaseEditor::getTitleId(const QString &workingDirectory,
return rc;
}
bool VCSBaseEditor::setConfigurationWidget(QWidget *w)
{
if (!d->m_toolBar || d->m_configurationWidget)
return false;
d->m_configurationWidget = w;
if (contentType() == AnnotateOutput) {
QList<QAction *> actions = d->m_toolBar->actions();
Q_ASSERT(actions.count() >= 1);
QWidget *spacer = new QWidget(d->m_toolBar);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
QAction *configAction = d->m_toolBar->insertWidget(actions.at(0), w);
d->m_toolBar->insertWidget(configAction, spacer);
} else {
d->m_toolBar->addWidget(w);
}
return true;
}
QWidget *VCSBaseEditor::configurationWidget() const
{
return d->m_configurationWidget;
}
// Find the complete file from a diff relative specification.
QString VCSBaseEditor::findDiffFile(const QString &f, Core::IVersionControl *control /* = 0 */) const
{
......
......@@ -178,6 +178,10 @@ public:
static QString getTitleId(const QString &workingDirectory,
const QStringList &fileNames,
const QString &revision = QString());
bool setConfigurationWidget(QWidget *w);
QWidget *configurationWidget() const;
signals:
// These signals also exist in the opaque editable (IEditor) that is
// handled by the editor manager for convenience. They are emitted
......
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