2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include "genericprojectplugin.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "genericbuildconfiguration.h"
|
2009-03-12 17:53:25 +01:00
|
|
|
#include "genericprojectwizard.h"
|
2009-03-16 11:08:07 +01:00
|
|
|
#include "genericprojectconstants.h"
|
|
|
|
|
#include "genericprojectfileseditor.h"
|
2009-03-18 13:33:00 +01:00
|
|
|
#include "genericmakestep.h"
|
2011-06-20 11:57:20 +02:00
|
|
|
#include "genericproject.h"
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-06-20 11:57:20 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2011-06-20 11:57:20 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2019-07-16 15:55:03 +02:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
2015-01-13 15:50:37 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2013-08-24 23:10:17 +02:00
|
|
|
#include <projectexplorer/selectablefilesmodel.h>
|
2019-07-16 15:55:03 +02:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2015-11-03 13:03:39 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/fileutils.h>
|
2019-07-16 15:55:03 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
|
2017-02-28 16:31:07 +01:00
|
|
|
#include <QAction>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
2019-07-16 15:55:03 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
namespace PEC = ProjectExplorer::Constants;
|
2014-08-20 00:58:38 +02:00
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
namespace GenericProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2018-02-02 14:17:52 +01:00
|
|
|
class GenericProjectPluginPrivate : public QObject
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2018-02-02 14:17:52 +01:00
|
|
|
public:
|
|
|
|
|
GenericProjectPluginPrivate();
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2018-02-02 14:17:52 +01:00
|
|
|
ProjectFilesFactory projectFilesFactory;
|
2019-07-30 13:45:05 +02:00
|
|
|
GenericMakeStepFactory makeStepFactory;
|
2018-02-02 14:17:52 +01:00
|
|
|
GenericBuildConfigurationFactory buildConfigFactory;
|
2017-03-03 18:16:34 +01:00
|
|
|
|
2018-10-25 12:12:07 +02:00
|
|
|
QAction editFilesAction{GenericProjectPlugin::tr("Edit Files..."), nullptr};
|
2018-02-02 14:17:52 +01:00
|
|
|
};
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2018-02-02 14:17:52 +01:00
|
|
|
GenericProjectPlugin::~GenericProjectPlugin()
|
|
|
|
|
{
|
2019-10-23 09:52:46 +02:00
|
|
|
delete d;
|
2018-02-02 14:17:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GenericProjectPlugin::initialize(const QStringList &, QString *)
|
|
|
|
|
{
|
2019-10-23 09:52:46 +02:00
|
|
|
d = new GenericProjectPluginPrivate;
|
2018-02-02 14:17:52 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenericProjectPluginPrivate::GenericProjectPluginPrivate()
|
|
|
|
|
{
|
|
|
|
|
ProjectManager::registerProjectType<GenericProject>(Constants::GENERICMIMETYPE);
|
|
|
|
|
|
2022-09-27 16:54:47 +02:00
|
|
|
IWizardFactory::registerFactoryCreator([] { return new GenericProjectWizard; });
|
2015-05-22 17:16:36 +02:00
|
|
|
|
2019-07-16 15:55:03 +02:00
|
|
|
ActionContainer *mproject = ActionManager::actionContainer(PEC::M_PROJECTCONTEXT);
|
2012-08-14 15:37:38 +02:00
|
|
|
|
2018-02-02 14:17:52 +01:00
|
|
|
Command *command = ActionManager::registerAction(&editFilesAction,
|
2017-12-20 11:13:26 +01:00
|
|
|
"GenericProjectManager.EditFiles", Context(Constants::GENERICPROJECT_ID));
|
2013-08-30 16:38:57 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2019-07-16 15:55:03 +02:00
|
|
|
mproject->addAction(command, PEC::G_PROJECT_FILES);
|
2011-06-20 11:57:20 +02:00
|
|
|
|
2018-02-21 10:32:48 +01:00
|
|
|
connect(&editFilesAction, &QAction::triggered, this, [] {
|
2019-10-23 09:49:27 +02:00
|
|
|
if (auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject()))
|
|
|
|
|
genericProject->editFilesTriggered();
|
2019-07-16 15:55:03 +02:00
|
|
|
});
|
|
|
|
|
|
2019-11-01 12:21:53 +01:00
|
|
|
const auto removeDirAction = new QAction(GenericProjectPlugin::tr("Remove Directory"), this);
|
2019-07-16 15:55:03 +02:00
|
|
|
Command * const cmd = ActionManager::registerAction(removeDirAction, "GenericProject.RemoveDir",
|
|
|
|
|
Context(PEC::C_PROJECT_TREE));
|
|
|
|
|
ActionManager::actionContainer(PEC::M_FOLDERCONTEXT)->addAction(cmd, PEC::G_FOLDER_OTHER);
|
|
|
|
|
connect(removeDirAction, &QAction::triggered, this, [] {
|
|
|
|
|
const auto folderNode = ProjectTree::currentNode()->asFolderNode();
|
|
|
|
|
QTC_ASSERT(folderNode, return);
|
|
|
|
|
const auto project = qobject_cast<GenericProject *>(folderNode->getProject());
|
|
|
|
|
QTC_ASSERT(project, return);
|
2021-07-14 16:49:42 +02:00
|
|
|
const FilePaths filesToRemove = transform(
|
2019-07-16 15:55:03 +02:00
|
|
|
folderNode->findNodes([](const Node *node) { return node->asFileNode(); }),
|
2021-07-14 16:49:42 +02:00
|
|
|
[](const Node *node) { return node->filePath();});
|
2019-10-23 09:49:27 +02:00
|
|
|
project->removeFilesTriggered(filesToRemove);
|
2018-02-02 14:17:52 +01:00
|
|
|
});
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|