Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
4637d562
Commit
4637d562
authored
Jun 18, 2009
by
dt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't ask to reload the file, if the user uses git/undo or git/revert.
Simply do it. Task-Nr: 254558
parent
69d04bc0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
26 deletions
+67
-26
src/plugins/coreplugin/filemanager.cpp
src/plugins/coreplugin/filemanager.cpp
+30
-0
src/plugins/coreplugin/filemanager.h
src/plugins/coreplugin/filemanager.h
+19
-0
src/plugins/git/gitclient.cpp
src/plugins/git/gitclient.cpp
+1
-0
src/plugins/git/gitplugin.cpp
src/plugins/git/gitplugin.cpp
+11
-1
src/plugins/perforce/perforceplugin.cpp
src/plugins/perforce/perforceplugin.cpp
+2
-11
src/plugins/subversion/subversionplugin.cpp
src/plugins/subversion/subversionplugin.cpp
+4
-14
No files found.
src/plugins/coreplugin/filemanager.cpp
View file @
4637d562
...
...
@@ -602,3 +602,33 @@ QList<IFile *> FileManager::managedFiles(const QString &fileName) const
}
return
result
;
}
FileChangeBlocker
::
FileChangeBlocker
(
const
QString
&
fileName
)
:
m_reload
(
false
)
{
Core
::
FileManager
*
fm
=
Core
::
ICore
::
instance
()
->
fileManager
();
m_files
=
fm
->
managedFiles
(
fileName
);
foreach
(
Core
::
IFile
*
file
,
m_files
)
fm
->
blockFileChange
(
file
);
}
FileChangeBlocker
::~
FileChangeBlocker
()
{
Core
::
IFile
::
ReloadBehavior
tempBehavior
=
Core
::
IFile
::
ReloadAll
;
Core
::
FileManager
*
fm
=
Core
::
ICore
::
instance
()
->
fileManager
();
foreach
(
Core
::
IFile
*
file
,
m_files
)
{
if
(
m_reload
)
file
->
modified
(
&
tempBehavior
);
fm
->
unblockFileChange
(
file
);
}
}
void
FileChangeBlocker
::
setModifiedReload
(
bool
b
)
{
m_reload
=
b
;
}
bool
FileChangeBlocker
::
modifiedReload
()
const
{
return
m_reload
;
}
src/plugins/coreplugin/filemanager.h
View file @
4637d562
...
...
@@ -136,6 +136,25 @@ private:
bool
m_blockActivated
;
};
/*! The FileChangeBlocker blocks all change notifications to all IFile * that
match the given filename. And unblocks in the destructor.
To also reload the IFile in the destructor class set modifiedReload to true
*/
class
CORE_EXPORT
FileChangeBlocker
{
public:
FileChangeBlocker
(
const
QString
&
fileName
);
~
FileChangeBlocker
();
void
setModifiedReload
(
bool
reload
);
bool
modifiedReload
()
const
;
private:
QList
<
IFile
*>
m_files
;
bool
m_reload
;
Q_DISABLE_COPY
(
FileChangeBlocker
);
};
}
// namespace Core
#endif // FILEMANAGER_H
src/plugins/git/gitclient.cpp
View file @
4637d562
...
...
@@ -42,6 +42,7 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/filemanager.h>
#include <texteditor/itexteditor.h>
#include <utils/qtcassert.h>
#include <vcsbase/vcsbaseeditor.h>
...
...
src/plugins/git/gitplugin.cpp
View file @
4637d562
...
...
@@ -553,7 +553,14 @@ void GitPlugin::undoFileChanges()
QFileInfo
fileInfo
=
currentFile
();
QString
fileName
=
fileInfo
.
fileName
();
QString
workingDirectory
=
fileInfo
.
absolutePath
();
m_gitClient
->
checkout
(
workingDirectory
,
fileName
);
Core
::
FileChangeBlocker
fcb
(
fileInfo
.
filePath
());
fcb
.
setModifiedReload
(
true
);
QString
errorMessage
;
if
(
!
m_gitClient
->
synchronousCheckout
(
workingDirectory
,
QStringList
()
<<
fileName
,
&
errorMessage
))
m_outputWindow
->
append
(
errorMessage
);
}
void
GitPlugin
::
undoProjectChanges
()
...
...
@@ -583,6 +590,9 @@ void GitPlugin::unstageFile()
void
GitPlugin
::
revertFile
()
{
const
QFileInfo
fileInfo
=
currentFile
();
Core
::
FileChangeBlocker
fcb
(
fileInfo
.
filePath
());
fcb
.
setModifiedReload
(
true
);
m_gitClient
->
revert
(
QStringList
(
fileInfo
.
absoluteFilePath
()));
}
...
...
src/plugins/perforce/perforceplugin.cpp
View file @
4637d562
...
...
@@ -444,18 +444,9 @@ void PerforcePlugin::revertCurrentFile()
return
;
}
Core
::
FileManager
*
fm
=
Core
::
ICore
::
instance
()
->
fileManager
();
QList
<
Core
::
IFile
*>
files
=
fm
->
managedFiles
(
fileName
);
foreach
(
Core
::
IFile
*
file
,
files
)
{
fm
->
blockFileChange
(
file
);
}
Core
::
FileChangeBlocker
fcb
(
fileName
);
fcb
.
setModifiedReload
(
true
);
PerforceResponse
result2
=
runP4Cmd
(
QStringList
()
<<
QLatin1String
(
"revert"
)
<<
fileName
,
QStringList
(),
CommandToWindow
|
StdOutToWindow
|
StdErrToWindow
|
ErrorToWindow
);
Core
::
IFile
::
ReloadBehavior
tempBehavior
=
Core
::
IFile
::
ReloadAll
;
foreach
(
Core
::
IFile
*
file
,
files
)
{
file
->
modified
(
&
tempBehavior
);
fm
->
unblockFileChange
(
file
);
}
}
void
PerforcePlugin
::
diffCurrentFile
()
...
...
src/plugins/subversion/subversionplugin.cpp
View file @
4637d562
...
...
@@ -611,10 +611,8 @@ void SubversionPlugin::revertCurrentFile()
QMessageBox
::
Yes
,
QMessageBox
::
No
)
==
QMessageBox
::
No
)
return
;
Core
::
FileManager
*
fm
=
Core
::
ICore
::
instance
()
->
fileManager
();
QList
<
Core
::
IFile
*>
files
=
fm
->
managedFiles
(
file
);
foreach
(
Core
::
IFile
*
file
,
files
)
fm
->
blockFileChange
(
file
);
Core
::
FileChangeBlocker
fcb
(
file
);
// revert
args
.
clear
();
...
...
@@ -622,16 +620,8 @@ void SubversionPlugin::revertCurrentFile()
args
.
append
(
file
);
const
SubversionResponse
revertResponse
=
runSvn
(
args
,
subversionShortTimeOut
,
true
);
if
(
revertResponse
.
error
)
{
foreach
(
Core
::
IFile
*
file
,
files
)
fm
->
unblockFileChange
(
file
);
return
;
}
Core
::
IFile
::
ReloadBehavior
tempBehavior
=
Core
::
IFile
::
ReloadAll
;
foreach
(
Core
::
IFile
*
file
,
files
)
{
file
->
modified
(
&
tempBehavior
);
fm
->
unblockFileChange
(
file
);
if
(
!
revertResponse
.
error
)
{
fcb
.
setModifiedReload
(
true
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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