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
a7bb5f25
Commit
a7bb5f25
authored
Aug 27, 2010
by
Jarek Kobus
Browse files
Add "Remove Project" action to the project explorer
Reviewed-by:
dt
<
qtc-committer@nokia.com
>
parent
dedba8c8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/projectexplorer.cpp
View file @
a7bb5f25
...
...
@@ -163,6 +163,7 @@ struct ProjectExplorerPluginPrivate {
QAction
*
m_addNewFileAction
;
QAction
*
m_addExistingFilesAction
;
QAction
*
m_removeFileAction
;
QAction
*
m_removeProjectAction
;
QAction
*
m_deleteFileAction
;
QAction
*
m_renameFileAction
;
QAction
*
m_openFileAction
;
...
...
@@ -725,6 +726,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
globalcontext
);
mfilec
->
addAction
(
cmd
,
Constants
::
G_FILE_OTHER
);
// remove project action
d
->
m_removeProjectAction
=
new
QAction
(
tr
(
"Remove Project"
),
this
);
cmd
=
am
->
registerAction
(
d
->
m_removeProjectAction
,
ProjectExplorer
::
Constants
::
REMOVEPROJECT
,
globalcontext
);
msubProject
->
addAction
(
cmd
,
Constants
::
G_PROJECT_FILES
);
// delete file action
d
->
m_deleteFileAction
=
new
QAction
(
tr
(
"Delete File..."
),
this
);
cmd
=
am
->
registerAction
(
d
->
m_deleteFileAction
,
ProjectExplorer
::
Constants
::
DELETEFILE
,
...
...
@@ -826,6 +833,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect
(
d
->
m_clearSession
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
clearSession
()));
connect
(
d
->
m_addNewFileAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addNewFile
()));
connect
(
d
->
m_addExistingFilesAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addExistingFiles
()));
connect
(
d
->
m_removeProjectAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
removeProject
()));
connect
(
d
->
m_openFileAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
openFile
()));
connect
(
d
->
m_showInGraphicalShell
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
showInGraphicalShell
()));
connect
(
d
->
m_openTerminalHere
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
openTerminalHere
()));
...
...
@@ -2088,6 +2096,19 @@ void ProjectExplorerPlugin::addExistingFiles()
}
}
void
ProjectExplorerPlugin
::
removeProject
()
{
ProjectNode
*
subProjectNode
=
qobject_cast
<
ProjectNode
*>
(
d
->
m_currentNode
->
projectNode
());
ProjectNode
*
projectNode
=
qobject_cast
<
ProjectNode
*>
(
subProjectNode
->
parentFolderNode
());
if
(
projectNode
)
{
Core
::
ICore
*
core
=
Core
::
ICore
::
instance
();
RemoveFileDialog
removeFileDialog
(
subProjectNode
->
path
(),
core
->
mainWindow
());
removeFileDialog
.
setDeleteFileVisible
(
false
);
if
(
removeFileDialog
.
exec
()
==
QDialog
::
Accepted
)
projectNode
->
removeSubProjects
(
QStringList
()
<<
subProjectNode
->
path
());
}
}
void
ProjectExplorerPlugin
::
openFile
()
{
QTC_ASSERT
(
d
->
m_currentNode
,
return
)
...
...
src/plugins/projectexplorer/projectexplorer.h
View file @
a7bb5f25
...
...
@@ -170,6 +170,7 @@ private slots:
void
addNewFile
();
void
addExistingFiles
();
void
removeProject
();
void
openFile
();
void
showInGraphicalShell
();
void
removeFile
();
...
...
src/plugins/projectexplorer/projectexplorerconstants.h
View file @
a7bb5f25
...
...
@@ -74,6 +74,7 @@ const char * const FINDINALLPROJECTS = "ProjectExplorer.FindInAllProjects";
const
char
*
const
SHOWPROPERTIES
=
"ProjectExplorer.ShowProperties"
;
const
char
*
const
ADDNEWFILE
=
"ProjectExplorer.AddNewFile"
;
const
char
*
const
ADDEXISTINGFILES
=
"ProjectExplorer.AddExistingFiles"
;
const
char
*
const
REMOVEPROJECT
=
"ProjectExplorer.RemoveProject"
;
const
char
*
const
OPENFILE
=
"ProjectExplorer.OpenFile"
;
const
char
*
const
SHOWINGRAPHICALSHELL
=
"ProjectExplorer.ShowInGraphicalShell"
;
const
char
*
const
OPENTERMIANLHERE
=
"ProjectExplorer.OpenTerminalHere"
;
...
...
src/plugins/projectexplorer/removefiledialog.cpp
View file @
a7bb5f25
...
...
@@ -50,6 +50,11 @@ RemoveFileDialog::~RemoveFileDialog()
delete
m_ui
;
}
void
RemoveFileDialog
::
setDeleteFileVisible
(
bool
visible
)
{
m_ui
->
deleteFileCheckBox
->
setVisible
(
visible
);
}
bool
RemoveFileDialog
::
isDeleteFileChecked
()
const
{
return
m_ui
->
deleteFileCheckBox
->
isChecked
();
...
...
src/plugins/projectexplorer/removefiledialog.h
View file @
a7bb5f25
...
...
@@ -47,6 +47,7 @@ public:
explicit
RemoveFileDialog
(
const
QString
&
filePath
,
QWidget
*
parent
=
0
);
virtual
~
RemoveFileDialog
();
void
setDeleteFileVisible
(
bool
visible
);
bool
isDeleteFileChecked
()
const
;
protected:
...
...
src/plugins/qt4projectmanager/qt4nodes.cpp
View file @
a7bb5f25
...
...
@@ -780,6 +780,18 @@ bool Qt4PriFileNode::canAddSubProject(const QString &proFilePath) const
return
false
;
}
static
QString
simplifyProFilePath
(
const
QString
&
proFilePath
)
{
// if proFilePath is like: _path_/projectName/projectName.pro
// we simplify it to: _path_/projectName
QFileInfo
fi
(
proFilePath
);
const
QString
parentPath
=
fi
.
absolutePath
();
QFileInfo
parentFi
(
parentPath
);
if
(
parentFi
.
fileName
()
==
fi
.
completeBaseName
())
return
parentPath
;
return
proFilePath
;
}
bool
Qt4PriFileNode
::
addSubProjects
(
const
QStringList
&
proFilePaths
)
{
ProjectExplorer
::
FindAllFilesVisitor
visitor
;
...
...
@@ -787,18 +799,9 @@ bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
const
QStringList
&
allFiles
=
visitor
.
filePaths
();
QStringList
uniqueProFilePaths
;
foreach
(
const
QString
&
proFile
,
proFilePaths
)
{
if
(
!
allFiles
.
contains
(
proFile
))
{
// if proFilePath is like: _path_/projectName/projectName.pro
// we simplify it to: _path_/projectName
QString
proFilePath
=
proFile
;
QFileInfo
fi
(
proFile
);
QFileInfo
parentFi
(
fi
.
absolutePath
());
if
(
parentFi
.
fileName
()
==
fi
.
baseName
())
proFilePath
=
parentFi
.
absoluteFilePath
();
uniqueProFilePaths
.
append
(
proFilePath
);
}
}
foreach
(
const
QString
&
proFile
,
proFilePaths
)
if
(
!
allFiles
.
contains
(
proFile
))
uniqueProFilePaths
.
append
(
simplifyProFilePath
(
proFile
));
QStringList
failedFiles
;
changeFiles
(
ProjectExplorer
::
ProjectFileType
,
uniqueProFilePaths
,
&
failedFiles
,
AddToProFile
);
...
...
@@ -808,8 +811,17 @@ bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
bool
Qt4PriFileNode
::
removeSubProjects
(
const
QStringList
&
proFilePaths
)
{
Q_UNUSED
(
proFilePaths
)
return
false
;
//changeIncludes(m_includeFile, proFilePaths, RemoveFromProFile);
QStringList
failedOriginalFiles
;
changeFiles
(
ProjectExplorer
::
ProjectFileType
,
proFilePaths
,
&
failedOriginalFiles
,
RemoveFromProFile
);
QStringList
simplifiedProFiles
;
foreach
(
const
QString
&
proFile
,
failedOriginalFiles
)
simplifiedProFiles
.
append
(
simplifyProFilePath
(
proFile
));
QStringList
failedSimplifiedFiles
;
changeFiles
(
ProjectExplorer
::
ProjectFileType
,
simplifiedProFiles
,
&
failedSimplifiedFiles
,
RemoveFromProFile
);
return
failedSimplifiedFiles
.
isEmpty
();
}
bool
Qt4PriFileNode
::
addFiles
(
const
FileType
fileType
,
const
QStringList
&
filePaths
,
...
...
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