Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
f84c2285
Commit
f84c2285
authored
Nov 18, 2010
by
Tobias Hunger
Browse files
Git: Add options to diff editor
parent
fcdd588b
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
src/plugins/git/gitclient.cpp
View file @
f84c2285
This diff is collapsed.
Click to expand it.
src/plugins/git/gitclient.h
View file @
f84c2285
/**************************************************************************
/**************************************************************************
**
** 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
...
...
src/plugins/git/giteditor.h
View file @
f84c2285
...
...
@@ -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
);
...
...
src/plugins/git/gitplugin.cpp
View file @
f84c2285
...
...
@@ -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
()
...
...
src/plugins/git/gitsettings.cpp
View file @
f84c2285
...
...
@@ -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
;
}
...
...
src/plugins/git/gitsettings.h
View file @
f84c2285
...
...
@@ -59,7 +59,8 @@ struct GitSettings
bool
pullRebase
;
bool
promptToSubmit
;
bool
omitAnnotationDate
;
bool
ignoreSpaceChanges
;
bool
ignoreSpaceChangesInDiff
;
bool
ignoreSpaceChangesInBlame
;
bool
diffPatience
;
bool
winSetHomeEnvironment
;
QString
gitkOptions
;
...
...
src/plugins/git/gitversioncontrol.cpp
View file @
f84c2285
...
...
@@ -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
;
}
...
...
src/plugins/git/settingspage.cpp
View file @
f84c2285
...
...
@@ -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
;
}
...
...
src/plugins/git/settingspage.ui
View file @
f84c2285
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
3
61
</width>
<width>
3
90
</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
"
patience diff
"
algorithm
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"pullRebaseCheckBox"
>
<property
name=
"text"
>
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
f84c2285
...
...
@@ -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
);
...
...
src/plugins/texteditor/basetexteditor.h
View file @
f84c2285
...
...
@@ -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
;
...
...
src/plugins/vcsbase/vcsbaseeditor.cpp
View file @
f84c2285
...
...
@@ -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
{
...
...
src/plugins/vcsbase/vcsbaseeditor.h
View file @
f84c2285
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment