2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-26 18:03:16 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2009-11-26 18:03:16 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-11-26 18:03:16 +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-11-26 18:03:16 +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-11-26 18:03:16 +01:00
|
|
|
|
|
|
|
|
#include "baseprojectwizarddialog.h"
|
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2009-11-26 18:03:16 +01:00
|
|
|
#include <utils/projectintropage.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
2009-11-26 18:03:16 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::BaseProjectWizardDialog
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The BaseProjectWizardDialog class is the base class for project
|
|
|
|
|
wizards.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
Presents the introductory page and takes care of setting the folder chosen
|
2011-04-14 12:58:14 +02:00
|
|
|
as default projects' folder should the user wish to do that.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2010-01-29 22:49:55 +01:00
|
|
|
struct BaseProjectWizardDialogPrivate {
|
2009-11-26 18:03:16 +01:00
|
|
|
explicit BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id = -1);
|
|
|
|
|
|
2010-03-22 15:33:33 +01:00
|
|
|
const int desiredIntroPageId;
|
2010-01-07 18:17:24 +01:00
|
|
|
Utils::ProjectIntroPage *introPage;
|
2010-03-22 15:33:33 +01:00
|
|
|
int introPageId;
|
2012-02-08 17:25:35 +01:00
|
|
|
QString selectedPlatform;
|
|
|
|
|
Core::FeatureSet requiredFeatureSet;
|
2009-11-26 18:03:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id) :
|
2010-03-22 15:33:33 +01:00
|
|
|
desiredIntroPageId(id),
|
|
|
|
|
introPage(page),
|
2010-10-27 12:51:33 +02:00
|
|
|
introPageId(-1)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
|
|
|
|
|
QWidget *parent,
|
2012-02-08 17:25:35 +01:00
|
|
|
const Core::WizardDialogParameters ¶meters) :
|
2015-05-29 17:25:40 +02:00
|
|
|
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
|
2009-11-26 18:03:16 +01:00
|
|
|
d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage))
|
|
|
|
|
{
|
2012-02-14 15:21:21 +01:00
|
|
|
setPath(parameters.defaultPath());
|
2012-02-08 17:25:35 +01:00
|
|
|
setSelectedPlatform(parameters.selectedPlatform());
|
|
|
|
|
setRequiredFeatures(parameters.requiredFeatures());
|
2009-11-26 18:03:16 +01:00
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFactory *factory,
|
|
|
|
|
Utils::ProjectIntroPage *introPage, int introId,
|
2012-02-03 18:00:08 +01:00
|
|
|
QWidget *parent,
|
2012-02-08 17:25:35 +01:00
|
|
|
const Core::WizardDialogParameters ¶meters) :
|
2015-05-29 17:25:40 +02:00
|
|
|
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
|
2009-11-26 18:03:16 +01:00
|
|
|
d(new BaseProjectWizardDialogPrivate(introPage, introId))
|
|
|
|
|
{
|
2012-02-14 15:21:21 +01:00
|
|
|
setPath(parameters.defaultPath());
|
2012-02-08 17:25:35 +01:00
|
|
|
setSelectedPlatform(parameters.selectedPlatform());
|
|
|
|
|
setRequiredFeatures(parameters.requiredFeatures());
|
2009-11-26 18:03:16 +01:00
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::init()
|
|
|
|
|
{
|
2010-03-22 15:33:33 +01:00
|
|
|
if (d->introPageId == -1) {
|
|
|
|
|
d->introPageId = addPage(d->introPage);
|
|
|
|
|
} else {
|
|
|
|
|
d->introPageId = d->desiredIntroPageId;
|
|
|
|
|
setPage(d->desiredIntroPageId, d->introPage);
|
|
|
|
|
}
|
2009-11-26 18:03:16 +01:00
|
|
|
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
|
2010-10-27 12:51:33 +02:00
|
|
|
connect(this, SIGNAL(nextClicked()), this, SLOT(nextClicked()));
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialog::~BaseProjectWizardDialog()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString BaseProjectWizardDialog::projectName() const
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
return d->introPage->projectName();
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BaseProjectWizardDialog::path() const
|
|
|
|
|
{
|
|
|
|
|
return d->introPage->path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setIntroDescription(const QString &des)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setDescription(des);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setPath(path);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
void BaseProjectWizardDialog::setProjectName(const QString &name)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
d->introPage->setProjectName(name);
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-13 16:37:48 +02:00
|
|
|
void BaseProjectWizardDialog::setProjectList(const QStringList &projectList)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setProjectList(projectList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setProjectDirectories(const QStringList &directories)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setProjectDirectories(directories);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setForceSubProject(bool force)
|
|
|
|
|
{
|
|
|
|
|
introPage()->setForceSubProject(force);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
void BaseProjectWizardDialog::slotAccepted()
|
|
|
|
|
{
|
|
|
|
|
if (d->introPage->useAsDefaultPath()) {
|
2010-03-22 15:33:33 +01:00
|
|
|
// Store the path as default path for new projects if desired.
|
2012-02-14 16:43:51 +01:00
|
|
|
Core::DocumentManager::setProjectsDirectory(path());
|
|
|
|
|
Core::DocumentManager::setUseProjectsDirectory(true);
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-27 12:51:33 +02:00
|
|
|
void BaseProjectWizardDialog::nextClicked()
|
2010-03-22 15:33:33 +01:00
|
|
|
{
|
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 (currentId() == d->introPageId)
|
2010-10-27 12:51:33 +02:00
|
|
|
emit projectParametersChanged(d->introPage->projectName(), d->introPage->path());
|
2010-03-22 15:33:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
Utils::ProjectIntroPage *BaseProjectWizardDialog::introPage() const
|
|
|
|
|
{
|
|
|
|
|
return d->introPage;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
|
|
|
|
const QDir pathDir(path);
|
2010-02-15 11:08:23 +01:00
|
|
|
//: File path suggestion for a new project. If you choose
|
2012-01-16 13:50:48 +01:00
|
|
|
//: to translate it, make sure it is a valid path name without blanks
|
|
|
|
|
//: and using only ascii chars.
|
2009-11-26 18:03:16 +01:00
|
|
|
const QString prefix = tr("untitled");
|
2011-04-19 15:42:14 +02:00
|
|
|
for (unsigned i = 0; ; ++i) {
|
2009-11-26 18:03:16 +01:00
|
|
|
QString name = prefix;
|
|
|
|
|
if (i)
|
|
|
|
|
name += QString::number(i);
|
|
|
|
|
if (!pathDir.exists(name))
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
return prefix;
|
|
|
|
|
}
|
2012-02-08 17:25:35 +01:00
|
|
|
|
2012-02-14 15:21:21 +01:00
|
|
|
void BaseProjectWizardDialog::addExtensionPages(const QList<QWizardPage *> &wizardPageList)
|
|
|
|
|
{
|
|
|
|
|
foreach (QWizardPage *p,wizardPageList)
|
2014-05-30 11:38:08 +02:00
|
|
|
addPage(p);
|
2012-02-14 15:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-08 17:25:35 +01:00
|
|
|
QString BaseProjectWizardDialog::selectedPlatform() const
|
|
|
|
|
{
|
|
|
|
|
return d->selectedPlatform;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setSelectedPlatform(const QString &platform)
|
|
|
|
|
{
|
|
|
|
|
d->selectedPlatform = platform;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::FeatureSet BaseProjectWizardDialog::requiredFeatures() const
|
|
|
|
|
{
|
|
|
|
|
return d->requiredFeatureSet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setRequiredFeatures(const Core::FeatureSet &featureSet)
|
|
|
|
|
{
|
|
|
|
|
d->requiredFeatureSet = featureSet;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
} // namespace ProjectExplorer
|