#include "projectexplorersettings.h"
#include "target.h"
#include "targetsettingspanel.h"
+#include "copytaskhandler.h"
+#include "showineditortaskhandler.h"
+#include "vcsannotatetaskhandler.h"
#include "applicationrunconfiguration.h"
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
#include <coreplugin/mainwindow.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
-#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
d->m_proWindow = new ProjectWindow;
- QList<int> globalcontext;
- globalcontext.append(Core::Constants::C_GLOBAL_ID);
-
- QList<int> pecontext;
- pecontext << core->uniqueIDManager()->uniqueIdentifier(Constants::C_PROJECTEXPLORER);
+ Core::Context globalcontext(Core::Constants::C_GLOBAL);
+ Core::Context pecontext(Constants::C_PROJECTEXPLORER);
d->m_projectsMode = new Core::BaseMode;
d->m_projectsMode->setDisplayName(tr("Projects"));
d->m_projectsMode->setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")));
d->m_projectsMode->setPriority(Constants::P_MODE_SESSION);
d->m_projectsMode->setWidget(d->m_proWindow);
- d->m_projectsMode->setContext(QList<int>() << pecontext);
+ d->m_projectsMode->setContext(pecontext);
d->m_projectsMode->setEnabled(session()->startupProject());
d->m_projectsMode->setContextHelpId(QLatin1String("Managing Projects"));
addAutoReleasedObject(d->m_projectsMode);
d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
+ addAutoReleasedObject(new CopyTaskHandler);
+ addAutoReleasedObject(new ShowInEditorTaskHandler);
+ addAutoReleasedObject(new VcsAnnotateTaskHandler);
+
d->m_buildManager = new BuildManager(this);
connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
globalcontext);
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
- // renamefile action (TODO: Not supported yet)
+ // renamefile action
d->m_renameFileAction = new QAction(tr("Rename"), this);
cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
globalcontext);
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
- d->m_renameFileAction->setEnabled(false);
- d->m_renameFileAction->setVisible(false);
+ // Not yet used by anyone, so hide for now
+// mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
+// msubProject->addAction(cmd, Constants::G_FOLDER_FILES);
+// mproject->addAction(cmd, Constants::G_FOLDER_FILES);
// target selector
d->m_projectSelectorAction = new QAction(this);
QSettings *s = Core::ICore::instance()->settings();
if (s) {
- s->setValue("ProjectExplorer/StartupSession", d->m_session->file()->fileName());
+ s->setValue("ProjectExplorer/StartupSession", d->m_session->currentSession());
s->remove("ProjectExplorer/RecentProjects/Files");
QStringList fileNames;
contextMenu = d->m_sessionContextMenu;
}
- updateContextMenuActions(node);
+ updateContextMenuActions(d->m_currentNode);
if (contextMenu && contextMenu->actions().count() > 0) {
contextMenu->popup(globalPos);
}
bool projectChanged = false;
if (d->m_currentProject != project) {
- QList<int> oldContext;
- QList<int> newContext;
+ Core::Context oldContext;
+ Core::Context newContext;
if (d->m_currentProject) {
- oldContext.append(d->m_currentProject->projectManager()->projectContext());
- oldContext.append(d->m_currentProject->projectManager()->projectLanguage());
+ oldContext.add(d->m_currentProject->projectManager()->projectContext());
+ oldContext.add(d->m_currentProject->projectManager()->projectLanguage());
}
if (project) {
- newContext.append(project->projectManager()->projectContext());
- newContext.append(project->projectManager()->projectLanguage());
+ newContext.add(project->projectManager()->projectContext());
+ newContext.add(project->projectManager()->projectLanguage());
}
core->updateAdditionalContexts(oldContext, newContext);
bool ProjectExplorerPlugin::hasBuildSettings(Project *pro)
{
const QList<Project *> & projects = d->m_session->projectOrder(pro);
- foreach(Project *pro, projects)
- if (pro->activeTarget()->activeBuildConfiguration())
+ foreach(Project *project, projects)
+ if (project->activeTarget()->activeBuildConfiguration())
return true;
return false;
}
const QList<Project *> & projects = d->m_session->projectOrder(pro);
QList<BuildConfiguration *> configurations;
- foreach(Project *pro, projects)
- if (pro->activeTarget()->activeBuildConfiguration())
- configurations << pro->activeTarget()->activeBuildConfiguration();
+ foreach(Project *project, projects)
+ if (project->activeTarget()->activeBuildConfiguration())
+ configurations << project->activeTarget()->activeBuildConfiguration();
d->m_buildManager->buildProjects(configurations);
updateRunActions();
d->m_removeFileAction->setEnabled(false);
if (node->projectNode()) {
- QList<ProjectNode::ProjectAction> supportedActions = node->projectNode()->supportedActions();
- if (qobject_cast<FolderNode*>(node)) {
- const bool addFilesEnabled = supportedActions.contains(ProjectNode::AddFile);
+ QList<ProjectNode::ProjectAction> actions =
+ d->m_currentNode->projectNode()->supportedActions(node);
+
+ if (qobject_cast<FolderNode*>(d->m_currentNode)) {
+ bool addFilesEnabled = actions.contains(ProjectNode::AddFile);
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
d->m_addNewFileAction->setEnabled(addFilesEnabled);
- } else if (qobject_cast<FileNode*>(node)) {
- const bool removeFileEnabled = supportedActions.contains(ProjectNode::RemoveFile);
+ d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
+ } else if (qobject_cast<FileNode*>(d->m_currentNode)) {
+ bool removeFileEnabled = actions.contains(ProjectNode::RemoveFile);
d->m_removeFileAction->setEnabled(removeFileEnabled);
+ d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
}
}
}
FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode);
Core::ICore *core = Core::ICore::instance();
- const QString filePath = d->m_currentNode->path();
- const QString fileDir = QFileInfo(filePath).dir().absolutePath();
+ QString filePath = d->m_currentNode->path();
RemoveFileDialog removeFileDialog(filePath, core->mainWindow());
if (removeFileDialog.exec() == QDialog::Accepted) {
}
}
+void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
+{
+ FileNode *fileNode = qobject_cast<FileNode *>(node);
+ if (!fileNode)
+ return;
+ QString orgFilePath = node->path();
+ QString dir = QFileInfo(orgFilePath).absolutePath();
+ QString newFilePath = dir + "/" + to;
+ Core::ICore *core = Core::ICore::instance();
+ Core::IVersionControl *vc = core->vcsManager()->findVersionControlForDirectory(dir);
+ bool result = false;
+ if (vc && vc->supportsOperation(Core::IVersionControl::MoveOperation))
+ result = vc->vcsMove(orgFilePath, newFilePath);
+ if (!result) // The moving via vcs failed or the vcs does not support moving, fall back
+ result = QFile::rename(orgFilePath, newFilePath);
+ if (result) {
+ // yeah we moved, tell the filemanager about it
+ Core::ICore::instance()->fileManager()->renamedFile(orgFilePath, newFilePath);
+ // Tell the project plugin about it
+ ProjectNode *projectNode = fileNode->projectNode();
+ projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath);
+ // TODO emit a signal?
+ }
+}
+
void ProjectExplorerPlugin::populateOpenWithMenu(QMenu *menu, const QString &fileName)
{
typedef QList<Core::IEditorFactory*> EditorFactoryList;