2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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>
|
|
|
|
|
|
|
|
|
|
#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-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
GenericProjectPlugin::GenericProjectPlugin()
|
2014-08-20 00:58:38 +02:00
|
|
|
: m_contextMenuProject(0)
|
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)
|
|
|
|
|
Utils::MimeDatabase::addMimeTypes(QLatin1String(":genericproject/GenericProjectManager.mimetypes.xml"));
|
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);
|
2009-03-12 17:53:25 +01:00
|
|
|
addAutoReleasedObject(new GenericProjectWizard);
|
2012-04-24 15:49:09 +02:00
|
|
|
addAutoReleasedObject(new GenericBuildConfigurationFactory);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
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
|
|
|
|
2015-01-13 15:50:37 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::aboutToShowContextMenu,
|
2014-08-20 00:58:38 +02:00
|
|
|
[this] (Project *project, Node *) { m_contextMenuProject = project; });
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
return true;
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericProjectPlugin::editFiles()
|
|
|
|
|
{
|
|
|
|
|
GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject);
|
2014-08-20 00:58:38 +02:00
|
|
|
SelectableFilesDialogEditFiles sfd(genericProject->projectFilePath().toFileInfo().path(), genericProject->files(),
|
|
|
|
|
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)
|
2011-06-20 11:57:20 +02:00
|
|
|
genericProject->setFiles(sfd.selectedFiles());
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|