2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include "genericprojectplugin.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "genericbuildconfiguration.h"
|
2009-03-10 14:20:07 +01:00
|
|
|
#include "genericprojectmanager.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>
|
2015-01-13 15:50:37 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2013-08-24 23:10:17 +02:00
|
|
|
#include <projectexplorer/selectablefilesmodel.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>
|
2015-02-04 09:32:46 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QDebug>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
namespace GenericProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
|
|
|
|
{
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
addAutoReleasedObject(new Manager);
|
|
|
|
|
addAutoReleasedObject(new ProjectFilesFactory);
|
2009-03-18 13:33:00 +01:00
|
|
|
addAutoReleasedObject(new GenericMakeStepFactory);
|
2012-04-24 15:49:09 +02:00
|
|
|
addAutoReleasedObject(new GenericBuildConfigurationFactory);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2015-05-22 17:16:36 +02:00
|
|
|
IWizardFactory::registerFactoryCreator([]() { return QList<IWizardFactory *>() << new GenericProjectWizard; });
|
|
|
|
|
|
2013-08-30 16:38:57 +02:00
|
|
|
ActionContainer *mproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
2012-08-14 15:37:38 +02:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
auto editFilesAction = new QAction(tr("Edit Files..."), this);
|
|
|
|
|
Command *command = ActionManager::registerAction(editFilesAction,
|
|
|
|
|
"GenericProjectManager.EditFiles", Context(Constants::PROJECTCONTEXT));
|
2013-08-30 16:38:57 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2011-06-20 11:57:20 +02:00
|
|
|
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
|
|
|
|
|
|
2015-01-30 10:19:13 +01:00
|
|
|
connect(editFilesAction, &QAction::triggered, this, &GenericProjectPlugin::editFiles);
|
2011-06-20 11:57:20 +02:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
return true;
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericProjectPlugin::editFiles()
|
|
|
|
|
{
|
2015-07-14 13:10:18 +02:00
|
|
|
auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject());
|
|
|
|
|
if (!genericProject)
|
|
|
|
|
return;
|
2016-04-06 17:38:39 +02:00
|
|
|
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
2015-11-03 13:03:39 +01:00
|
|
|
Utils::transform(genericProject->files(), [](const QString &f) { return Utils::FileName::fromString(f); }),
|
|
|
|
|
ICore::mainWindow());
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (sfd.exec() == QDialog::Accepted)
|
2015-11-03 13:03:39 +01:00
|
|
|
genericProject->setFiles(Utils::transform(sfd.selectedFiles(), &Utils::FileName::toString));
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|