Skip to content
GitLab
Menu
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
046e1882
Commit
046e1882
authored
Dec 03, 2008
by
hjk
Browse files
Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta
parents
4ad0b966
d8bc36eb
Changes
21
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/editormanager/editormanager.cpp
View file @
046e1882
...
...
@@ -1003,29 +1003,32 @@ bool EditorManager::saveFile(IEditor *editor)
return
success
;
}
namespace
{
enum
ReadOnlyAction
{
RO_Cancel
,
RO_OpenSCC
,
RO_MakeWriteable
,
RO_SaveAs
};
}
static
ReadOnlyAction
promptReadOnly
(
const
QString
&
fileName
,
bool
hasSCC
,
QWidget
*
parent
)
EditorManager
::
ReadOnlyAction
EditorManager
::
promptReadOnlyFile
(
const
QString
&
fileName
,
const
IVersionControl
*
versionControl
,
QWidget
*
parent
,
bool
displaySaveAsButton
)
{
QMessageBox
msgBox
(
QMessageBox
::
Question
,
QObject
::
tr
(
"File is Read Only"
),
QObject
::
tr
(
"The file %1 is read only."
).
arg
(
fileName
),
QMessageBox
::
Cancel
,
parent
);
QPushButton
*
sccButton
=
0
;
if
(
hasSCC
)
sccButton
=
msgBox
.
addButton
(
QObject
::
tr
(
"Open with SCC"
),
QMessageBox
::
AcceptRole
);
if
(
versionControl
&&
versionControl
->
supportsOperation
(
IVersionControl
::
OpenOperation
))
sccButton
=
msgBox
.
addButton
(
QObject
::
tr
(
"Open with VCS (%1)"
).
arg
(
versionControl
->
name
()),
QMessageBox
::
AcceptRole
);
QPushButton
*
makeWritableButton
=
msgBox
.
addButton
(
QObject
::
tr
(
"Make writable"
),
QMessageBox
::
AcceptRole
);
QPushButton
*
saveAsButton
=
msgBox
.
addButton
(
QObject
::
tr
(
"Save as ..."
),
QMessageBox
::
ActionRole
);
if
(
hasSCC
)
msgBox
.
setDefaultButton
(
sccButton
);
else
msgBox
.
setDefaultButton
(
makeWritableButton
);
QPushButton
*
saveAsButton
=
0
;
if
(
displaySaveAsButton
)
msgBox
.
addButton
(
QObject
::
tr
(
"Save as ..."
),
QMessageBox
::
ActionRole
);
msgBox
.
setDefaultButton
(
sccButton
?
sccButton
:
makeWritableButton
);
msgBox
.
exec
();
QAbstractButton
*
clickedButton
=
msgBox
.
clickedButton
();
if
(
clickedButton
==
sccButton
)
return
RO_Open
SCC
;
return
RO_Open
VCS
;
if
(
clickedButton
==
makeWritableButton
)
return
RO_MakeWriteable
;
if
(
clickedButton
==
saveAsButton
)
...
...
@@ -1042,8 +1045,8 @@ EditorManager::makeEditorWritable(IEditor *editor)
IFile
*
file
=
editor
->
file
();
const
QString
&
fileName
=
file
->
fileName
();
switch
(
promptReadOnly
(
fileName
,
versionControl
,
m_d
->
m_core
->
mainWindow
()))
{
case
RO_Open
SCC
:
switch
(
promptReadOnly
File
(
fileName
,
versionControl
,
m_d
->
m_core
->
mainWindow
()
,
true
))
{
case
RO_Open
VCS
:
if
(
!
versionControl
->
vcsOpen
(
fileName
))
{
QMessageBox
::
warning
(
m_d
->
m_core
->
mainWindow
(),
tr
(
"Failed!"
),
tr
(
"Could not open the file for edit with SCC."
));
return
Failed
;
...
...
src/plugins/coreplugin/editormanager/editormanager.h
View file @
046e1882
...
...
@@ -55,6 +55,7 @@ class IEditorFactory;
class
MimeType
;
class
IFile
;
class
IMode
;
class
IVersionControl
;
enum
MakeWritableResult
{
OpenedWithVersionControl
,
...
...
@@ -159,6 +160,16 @@ public:
QString
defaultExternalEditor
()
const
;
QString
externalEditorHelpText
()
const
;
// Helper to display a message dialog when encountering a read-only
// file, prompting the user about how to make it writeable.
enum
ReadOnlyAction
{
RO_Cancel
,
RO_OpenVCS
,
RO_MakeWriteable
,
RO_SaveAs
};
static
ReadOnlyAction
promptReadOnlyFile
(
const
QString
&
fileName
,
const
IVersionControl
*
versionControl
,
QWidget
*
parent
,
bool
displaySaveAsButton
=
false
);
signals:
void
currentEditorChanged
(
Core
::
IEditor
*
editor
);
void
editorCreated
(
Core
::
IEditor
*
editor
,
const
QString
&
fileName
);
...
...
src/plugins/coreplugin/iversioncontrol.h
View file @
046e1882
...
...
@@ -45,51 +45,53 @@ class CORE_EXPORT IVersionControl : public QObject
{
Q_OBJECT
public:
enum
Operation
{
AddOperation
,
DeleteOperation
,
OpenOperation
};
IVersionControl
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{}
virtual
~
IVersionControl
()
{}
// Returns wheter files in this directory should be managed with this
virtual
QString
name
()
const
=
0
;
// Enable the VCS, that is, make its menu actions visible.
virtual
bool
isEnabled
()
const
=
0
;
virtual
void
setEnabled
(
bool
enabled
)
=
0
;
// Returns whether files in this directory should be managed with this
// version control.
virtual
bool
managesDirectory
(
const
QString
&
filename
)
const
=
0
;
// This function should return the topmost directory, for
// which this IVersionControl should be used.
// The VCSManager assumes that all files in the returned directory
// are managed by the same IVersionControl
// This function should return the topmost directory, for which this
// IVersionControl should be used. The VCSManager assumes that all files
// in the returned directory are managed by the same IVersionControl
// Note that this is used as an optimization, so that the VCSManager
// doesn't need to call managesDirectory(..) for each directory
// This function is called after finding out that the directory is managed
by
// a specific version control
// This function is called after finding out that the directory is managed
//
by
a specific version control
.
virtual
QString
findTopLevelForDirectory
(
const
QString
&
directory
)
const
=
0
;
// Called prior to save, if the file is read only.
// Should be implemented if the scc requires a operation before editing the file
// E.g. p4 edit
// Note: The EditorManager calls this for the editors
// Called to query whether a VCS supports the respective operations.
virtual
bool
supportsOperation
(
Operation
operation
)
const
=
0
;
// Called prior to save, if the file is read only. Should be implemented
// if the scc requires a operation before editing the file, e.g. 'p4 edit'
// Note: The EditorManager calls this for the editors.
virtual
bool
vcsOpen
(
const
QString
&
fileName
)
=
0
;
// Called after a file has been added to a project
// If the version control needs to know which files it needs to track
// you should reimplement this function
// E.g. p4 add, cvs add, svn add
// Note: This function should be called from IProject subclasses after files
// are added to the project
// Called after a file has been added to a project If the version control
// needs to know which files it needs to track you should reimplement this
// function, e.g. 'p4 add', 'cvs add', 'svn add'.
// Note: This function should be called from IProject subclasses after
// files are added to the project
virtual
bool
vcsAdd
(
const
QString
&
filename
)
=
0
;
// Called after a file has been removed from the project (if the user
wants)
//
E
.g. p4 delete, svn delete
// You probably want to call
Scc
Manager::showDeleteDialog, which asks the
user to
// confirm the deletion
// Called after a file has been removed from the project (if the user
//
wants), e
.g.
'
p4 delete
'
,
'
svn delete
'.
// You probably want to call
Vcs
Manager::showDeleteDialog, which asks the
//
user to
confirm the deletion
virtual
bool
vcsDelete
(
const
QString
&
filename
)
=
0
;
// TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
// virtual bool sccManaged(const QStryng &filename) = 0;
// TODO
// we probably want to have a function supports( enum Operation ) or
// something which describes which "kind" of revision control system it is.
// That is to check wheter a given operation is needed.
// But well I don't know yet how all different version control systems work
};
}
// namespace Core
...
...
src/plugins/coreplugin/vcsmanager.cpp
View file @
046e1882
...
...
@@ -45,8 +45,18 @@
#include <QtCore/QFileInfo>
#include <QtGui/QMessageBox>
enum
{
debug
=
0
};
namespace
Core
{
typedef
QList
<
IVersionControl
*>
VersionControlList
;
static
inline
VersionControlList
allVersionControls
()
{
return
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
IVersionControl
>
();
}
// ---- VCSManagerPrivate
struct
VCSManagerPrivate
{
QMap
<
QString
,
IVersionControl
*>
m_cachedMatches
;
};
...
...
@@ -61,31 +71,54 @@ VCSManager::~VCSManager()
delete
m_d
;
}
void
VCSManager
::
setVCSEnabled
(
const
QString
&
directory
)
{
if
(
debug
)
qDebug
()
<<
Q_FUNC_INFO
<<
directory
;
IVersionControl
*
managingVCS
=
findVersionControlForDirectory
(
directory
);
const
VersionControlList
versionControls
=
allVersionControls
();
foreach
(
IVersionControl
*
versionControl
,
versionControls
)
{
const
bool
newEnabled
=
versionControl
==
managingVCS
;
if
(
newEnabled
!=
versionControl
->
isEnabled
())
versionControl
->
setEnabled
(
newEnabled
);
}
}
void
VCSManager
::
setAllVCSEnabled
()
{
if
(
debug
)
qDebug
()
<<
Q_FUNC_INFO
;
const
VersionControlList
versionControls
=
allVersionControls
();
foreach
(
IVersionControl
*
versionControl
,
versionControls
)
if
(
!
versionControl
->
isEnabled
())
versionControl
->
setEnabled
(
true
);
}
IVersionControl
*
VCSManager
::
findVersionControlForDirectory
(
const
QString
&
directory
)
{
// first look into the cache
int
pos
=
0
;
{
// First try the whole name
QMap
<
QString
,
IVersionControl
*>::
const_iterator
it
=
m_d
->
m_cachedMatches
.
constFind
(
directory
);
if
(
it
!=
m_d
->
m_cachedMatches
.
constEnd
())
{
// first look into the cache
, check the whole name
{
const
QMap
<
QString
,
IVersionControl
*>::
const_iterator
it
=
m_d
->
m_cachedMatches
.
constFind
(
directory
);
if
(
it
!=
m_d
->
m_cachedMatches
.
constEnd
())
return
it
.
value
();
}
}
int
pos
=
0
;
const
QChar
slash
=
QLatin1Char
(
'/'
);
while
(
true
)
{
int
index
=
directory
.
indexOf
(
'/'
,
pos
);
int
index
=
directory
.
indexOf
(
slash
,
pos
);
if
(
index
==
-
1
)
break
;
QString
directoryPart
=
directory
.
left
(
index
);
const
QString
directoryPart
=
directory
.
left
(
index
);
QMap
<
QString
,
IVersionControl
*>::
const_iterator
it
=
m_d
->
m_cachedMatches
.
constFind
(
directoryPart
);
if
(
it
!=
m_d
->
m_cachedMatches
.
constEnd
())
{
if
(
it
!=
m_d
->
m_cachedMatches
.
constEnd
())
return
it
.
value
();
}
pos
=
index
+
1
;
}
// ah nothing so ask the IVersionControls directly
QList
<
I
VersionControl
*>
versionControls
=
ExtensionSystem
::
PluginManager
::
instance
()
->
getObjects
<
I
VersionControl
>
();
const
VersionControl
List
versionControls
=
all
VersionControl
s
();
foreach
(
IVersionControl
*
versionControl
,
versionControls
)
{
if
(
versionControl
->
managesDirectory
(
directory
))
{
m_d
->
m_cachedMatches
.
insert
(
versionControl
->
findTopLevelForDirectory
(
directory
),
versionControl
);
...
...
@@ -95,20 +128,20 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
return
0
;
}
void
VCSManager
::
showDeleteDialog
(
const
QString
&
fileName
)
bool
VCSManager
::
showDeleteDialog
(
const
QString
&
fileName
)
{
IVersionControl
*
vc
=
findVersionControlForDirectory
(
QFileInfo
(
fileName
).
absolutePath
());
if
(
!
vc
)
return
;
if
(
!
vc
||
!
vc
->
supportsOperation
(
IVersionControl
::
DeleteOperation
)
)
return
true
;
const
QString
title
=
QCoreApplication
::
translate
(
"VCSManager"
,
"Version Control"
);
const
QString
msg
=
QCoreApplication
::
translate
(
"VCSManager"
,
"Would you like to remove this file from the version control system?
\n
"
"Note: This might remove the local file."
);
"Would you like to remove this file from the version control system
(%1)
?
\n
"
"Note: This might remove the local file."
)
.
arg
(
vc
->
name
())
;
const
QMessageBox
::
StandardButton
button
=
QMessageBox
::
question
(
0
,
title
,
msg
,
QMessageBox
::
Yes
|
QMessageBox
::
No
,
QMessageBox
::
Yes
);
if
(
button
=
=
QMessageBox
::
Yes
)
{
vc
->
vcsDelete
(
fileName
)
;
}
if
(
button
!
=
QMessageBox
::
Yes
)
return
true
;
return
vc
->
vcsDelete
(
fileName
);
}
}
// namespace Core
src/plugins/coreplugin/vcsmanager.h
View file @
046e1882
...
...
@@ -45,12 +45,12 @@ class IVersionControl;
// The VCSManager has only one notable function:
// findVersionControlFor(), which returns the IVersionControl * for a given
// filename. Note that the VCSManager assumes that if a IVersionControl *
// filename. Note that the VCSManager assumes that if a IVersionControl *
// manages a directory, then it also manages all the files and all the
// subdirectories.
//
// It works by asking all IVersionControl * if they manage the file, and ask
// for the topmost directory it manages. This information is cached and
// for the topmost directory it manages. This information is cached and
// VCSManager thus knows pretty fast which IVersionControl * is responsible.
class
CORE_EXPORT
VCSManager
...
...
@@ -62,10 +62,16 @@ public:
IVersionControl
*
findVersionControlForDirectory
(
const
QString
&
directory
);
// Shows a confirmation dialog,
// wheter the file should also be deleted from revision control
// Calls sccDelete on the file
void
showDeleteDialog
(
const
QString
&
fileName
);
// Enable the VCS managing a certain directory only. This should
// be used by project manager classes.
void
setVCSEnabled
(
const
QString
&
directory
);
// Enable all VCS.
void
setAllVCSEnabled
();
// Shows a confirmation dialog, whether the file should also be deleted
// from revision control Calls sccDelete on the file. Returns false
// if a failure occurs
bool
showDeleteDialog
(
const
QString
&
fileName
);
private:
VCSManagerPrivate
*
m_d
;
...
...
src/plugins/git/git.pro
View file @
046e1882
...
...
@@ -17,7 +17,8 @@ HEADERS += gitplugin.h \
giteditor
.
h
\
annotationhighlighter
.
h
\
gitsubmiteditorwidget
.
h
\
gitsubmiteditor
.
h
gitsubmiteditor
.
h
\
gitversioncontrol
.
h
SOURCES
+=
gitplugin
.
cpp
\
gitoutputwindow
.
cpp
\
...
...
@@ -28,7 +29,8 @@ SOURCES += gitplugin.cpp \
giteditor
.
cpp
\
annotationhighlighter
.
cpp
\
gitsubmiteditorwidget
.
cpp
\
gitsubmiteditor
.
cpp
gitsubmiteditor
.
cpp
\
gitversioncontrol
.
cpp
FORMS
+=
changeselectiondialog
.
ui
\
settingspage
.
ui
\
...
...
src/plugins/git/gitclient.cpp
View file @
046e1882
...
...
@@ -87,11 +87,6 @@ GitClient::~GitClient()
{
}
bool
GitClient
::
vcsOpen
(
const
QString
&
fileName
)
{
return
m_plugin
->
vcsOpen
(
fileName
);
}
QString
GitClient
::
findRepositoryForFile
(
const
QString
&
fileName
)
{
const
QString
gitDirectory
=
QLatin1String
(
kGitDirectoryC
);
...
...
src/plugins/git/gitclient.h
View file @
046e1882
...
...
@@ -62,17 +62,14 @@ class GitCommand;
struct
CommitData
;
struct
GitSubmitEditorPanelData
;
class
GitClient
:
public
Core
::
IVersionControl
class
GitClient
:
public
QObject
{
Q_OBJECT
public:
GitClient
(
GitPlugin
*
plugin
,
Core
::
ICore
*
core
);
explicit
GitClient
(
GitPlugin
*
plugin
,
Core
::
ICore
*
core
);
~
GitClient
();
bool
vcsOpen
(
const
QString
&
fileName
);
bool
vcsAdd
(
const
QString
&
)
{
return
false
;
}
bool
vcsDelete
(
const
QString
&
)
{
return
false
;
}
bool
managesDirectory
(
const
QString
&
)
const
{
return
false
;
}
QString
findTopLevelForDirectory
(
const
QString
&
)
const
{
return
QString
();
}
...
...
src/plugins/git/gitplugin.cpp
View file @
046e1882
...
...
@@ -33,6 +33,7 @@
#include "gitplugin.h"
#include "gitclient.h"
#include "gitversioncontrol.h"
#include "giteditor.h"
#include "gitconstants.h"
#include "changeselectiondialog.h"
...
...
@@ -132,6 +133,7 @@ GitPlugin::GitPlugin() :
m_settingsPage
(
0
),
m_coreListener
(
0
),
m_submitEditorFactory
(
0
),
m_versionControl
(
0
),
m_changeTmpFile
(
0
)
{
Q_ASSERT
(
m_instance
==
0
);
...
...
@@ -170,6 +172,12 @@ GitPlugin::~GitPlugin()
m_submitEditorFactory
=
0
;
}
if
(
m_versionControl
)
{
removeObject
(
m_versionControl
);
delete
m_versionControl
;
m_versionControl
=
0
;
}
cleanChangeTmpFile
();
delete
m_gitClient
;
m_instance
=
0
;
...
...
@@ -235,6 +243,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message)
m_submitEditorFactory
=
new
GitSubmitEditorFactory
(
&
submitParameters
);
addObject
(
m_submitEditorFactory
);
m_versionControl
=
new
GitVersionControl
(
m_gitClient
);
addObject
(
m_versionControl
);
//register actions
Core
::
ActionManagerInterface
*
actionManager
=
m_core
->
actionManager
();
...
...
@@ -245,6 +256,10 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message)
actionManager
->
createMenu
(
QLatin1String
(
"Git"
));
gitContainer
->
menu
()
->
setTitle
(
tr
(
"&Git"
));
toolsContainer
->
addMenu
(
gitContainer
);
if
(
QAction
*
ma
=
gitContainer
->
menu
()
->
menuAction
())
{
ma
->
setEnabled
(
m_versionControl
->
isEnabled
());
connect
(
m_versionControl
,
SIGNAL
(
enabledChanged
(
bool
)),
ma
,
SLOT
(
setVisible
(
bool
)));
}
Core
::
ICommand
*
command
;
QAction
*
tmpaction
;
...
...
@@ -383,12 +398,6 @@ void GitPlugin::extensionsInitialized()
m_projectExplorer
=
ExtensionSystem
::
PluginManager
::
instance
()
->
getObject
<
ProjectExplorer
::
ProjectExplorerPlugin
>
();
}
bool
GitPlugin
::
vcsOpen
(
const
QString
&
fileName
)
{
Q_UNUSED
(
fileName
);
return
false
;
}
void
GitPlugin
::
submitEditorDiff
(
const
QStringList
&
files
)
{
if
(
files
.
empty
())
...
...
src/plugins/git/gitplugin.h
View file @
046e1882
...
...
@@ -55,6 +55,7 @@ QT_END_NAMESPACE
namespace
Core
{
class
IEditorFactory
;
class
ICore
;
class
IVersionControl
;
}
namespace
Git
{
...
...
@@ -87,8 +88,6 @@ public:
~
GitPlugin
();
static
GitPlugin
*
instance
();
bool
vcsOpen
(
const
QString
&
fileName
);
bool
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
);
void
extensionsInitialized
();
...
...
@@ -154,6 +153,7 @@ private:
QList
<
Core
::
IEditorFactory
*>
m_editorFactories
;
CoreListener
*
m_coreListener
;
Core
::
IEditorFactory
*
m_submitEditorFactory
;
Core
::
IVersionControl
*
m_versionControl
;
QString
m_submitRepository
;
QStringList
m_submitOrigCommitFiles
;
QTemporaryFile
*
m_changeTmpFile
;
...
...
src/plugins/perforce/perforceplugin.cpp
View file @
046e1882
...
...
@@ -235,6 +235,10 @@ bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *erro
am
->
createMenu
(
QLatin1String
(
PERFORCE_MENU
));
mperforce
->
menu
()
->
setTitle
(
tr
(
"&Perforce"
));
mtools
->
addMenu
(
mperforce
);
if
(
QAction
*
ma
=
mperforce
->
menu
()
->
menuAction
())
{
ma
->
setEnabled
(
m_versionControl
->
isEnabled
());
connect
(
m_versionControl
,
SIGNAL
(
enabledChanged
(
bool
)),
ma
,
SLOT
(
setVisible
(
bool
)));
}
QList
<
int
>
globalcontext
;
globalcontext
<<
Core
::
Constants
::
C_GLOBAL_ID
;
...
...
src/plugins/perforce/perforceversioncontrol.cpp
View file @
046e1882
...
...
@@ -38,10 +38,41 @@ namespace Perforce {
namespace
Internal
{
PerforceVersionControl
::
PerforceVersionControl
(
PerforcePlugin
*
plugin
)
:
m_enabled
(
true
),
m_plugin
(
plugin
)
{
}
QString
PerforceVersionControl
::
name
()
const
{
return
QLatin1String
(
"perforce"
);
}
bool
PerforceVersionControl
::
isEnabled
()
const
{
return
m_enabled
;
}
void
PerforceVersionControl
::
setEnabled
(
bool
enabled
)
{
if
(
m_enabled
!=
enabled
)
{
m_enabled
=
enabled
;
emit
enabledChanged
(
m_enabled
);
}
}
bool
PerforceVersionControl
::
supportsOperation
(
Operation
operation
)
const
{
bool
rc
=
true
;
switch
(
operation
)
{
case
AddOperation
:
case
DeleteOperation
:
case
OpenOperation
:
break
;
}
return
rc
;
}
bool
PerforceVersionControl
::
vcsOpen
(
const
QString
&
fileName
)
{
return
m_plugin
->
vcsOpen
(
fileName
);
...
...
src/plugins/perforce/perforceversioncontrol.h
View file @
046e1882
...
...
@@ -46,13 +46,25 @@ class PerforceVersionControl : public Core::IVersionControl
Q_OBJECT
public:
explicit
PerforceVersionControl
(
PerforcePlugin
*
plugin
);
virtual
QString
name
()
const
;
virtual
bool
isEnabled
()
const
;
virtual
void
setEnabled
(
bool
enabled
);
bool
managesDirectory
(
const
QString
&
directory
)
const
;
virtual
QString
findTopLevelForDirectory
(
const
QString
&
directory
)
const
;
virtual
bool
supportsOperation
(
Operation
operation
)
const
;
virtual
bool
vcsOpen
(
const
QString
&
fileName
);
virtual
bool
vcsAdd
(
const
QString
&
fileName
);
virtual
bool
vcsDelete
(
const
QString
&
filename
);
signals:
void
enabledChanged
(
bool
);
private:
bool
m_enabled
;
PerforcePlugin
*
m_plugin
;
};
...
...
src/plugins/projectexplorer/projectexplorer.cpp
View file @
046e1882
...
...
@@ -76,6 +76,7 @@
#include <coreplugin/welcomemode.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <utils/listutils.h>
#include <QtCore/qplugin.h>
...
...
@@ -1153,6 +1154,13 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
if
(
projectChanged
)
{
if
(
debug
)
qDebug
()
<<
"ProjectExplorer - currentProjectChanged("
<<
(
project
?
project
->
name
()
:
"0"
)
<<
")"
;
// Enable the right VCS
if
(
const
Core
::
IFile
*
projectFile
=
project
?
project
->
file
()
:
static_cast
<
const
Core
::
IFile
*>
(
0
))
{
m_core
->
vcsManager
()
->
setVCSEnabled
(
QFileInfo
(
projectFile
->
fileName
()).
absolutePath
());
}
else
{
m_core
->
vcsManager
()
->
setAllVCSEnabled
();
}
emit
currentProjectChanged
(
project
);
updateActions
();
}
...
...
@@ -1565,27 +1573,28 @@ void ProjectExplorerPlugin::addExistingFiles()
fileNames
.
removeOne
(
file
);
}
if
(
Core
::
IVersionControl
*
vcManager
=
m_core
->
vcsManager
()
->
findVersionControlForDirectory
(
dir
))
{
const
QString
files
=
fileNames
.
join
(
"
\n
"
);
QMessageBox
::
StandardButton
button
=
if
(
Core
::
IVersionControl
*
vcManager
=
m_core
->
vcsManager
()
->
findVersionControlForDirectory
(
dir
))
if
(
vcManager
->
supportsOperation
(
Core
::
IVersionControl
::
AddOperation
))
{
const
QString
files
=
fileNames
.
join
(
QString
(
QLatin1Char
(
'\n'
)));
QMessageBox
::
StandardButton
button
=
QMessageBox
::
question
(
m_core
->
mainWindow
(),
tr
(
"Add to Version Control"
),
tr
(
"Add files
\n
%1
\n
to version control?"
).
arg
(
files
),
tr
(
"Add files
\n
%1
\n
to version control
(%2)
?"
).
arg
(
files
,
vcManager
->
name
()
),
QMessageBox
::
Yes
|
QMessageBox
::
No
);
if
(
button
==
QMessageBox
::
Yes
)
{
QStringList
notAddedToVc
;
foreach
(
const
QString
file
,
fileNames
)
{
if
(
!
vcManager
->
vcsAdd
(
file
))
notAddedToVc
<<
file
;
}
if
(
button
==
QMessageBox
::
Yes
)
{
QStringList
notAddedToVc
;
foreach
(
const
QString
&
file
,
fileNames
)
{
if
(
!
vcManager
->
vcsAdd
(
file
))
notAddedToVc
<<
file
;
}
if
(
!
notAddedToVc
.
isEmpty
())
{
const
QString
message
=
tr
(
"Could not add following files to version control
\n
"
);
const
QString
filesNotAdded
=
notAddedToVc
.
join
(
"
\n
"
);
QMessageBox
::
warning
(
m_core
->
mainWindow
(),
tr
(
"Add files to version control failed"
),
message
+
filesNotAdded
);
if
(
!
notAddedToVc
.
isEmpty
())
{
const
QString
message
=
tr
(
"Could not add following files to version control (%1)
\n
"
).
arg
(
vcManager
->
name
());
const
QString
filesNotAdded
=
notAddedToVc
.
join
(
QString
(
QLatin1Char
(
'\n'
)));
QMessageBox
::
warning
(
m_core
->
mainWindow
(),
tr
(
"Add files to version control failed"
),
message
+
filesNotAdded
);
<