2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-14 14:48:06 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-01-14 14:48:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-14 14:48:06 +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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-01-14 14:48:06 +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
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt 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
|
|
|
****************************************************************************/
|
2010-01-14 14:48:06 +01:00
|
|
|
|
|
|
|
|
#include "projectconfiguration.h"
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2012-01-24 16:27:05 +01:00
|
|
|
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
|
|
|
|
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
|
|
|
|
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
2010-01-14 14:48:06 +01:00
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
ProjectConfiguration::ProjectConfiguration(QObject *parent, const Core::Id &id) :
|
2010-07-16 14:00:41 +02:00
|
|
|
QObject(parent),
|
2010-01-14 14:48:06 +01:00
|
|
|
m_id(id)
|
2012-04-24 15:49:09 +02:00
|
|
|
{ setObjectName(id.toString()); }
|
2010-01-14 14:48:06 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
ProjectConfiguration::ProjectConfiguration(QObject *parent, const ProjectConfiguration *source) :
|
2010-08-19 12:26:21 +02:00
|
|
|
QObject(parent),
|
|
|
|
|
m_id(source->m_id),
|
|
|
|
|
m_defaultDisplayName(source->m_defaultDisplayName)
|
2010-01-14 14:48:06 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(source);
|
|
|
|
|
m_displayName = tr("Clone of %1").arg(source->displayName());
|
2010-01-14 14:48:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectConfiguration::~ProjectConfiguration()
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|
2010-01-14 14:48:06 +01:00
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
Core::Id ProjectConfiguration::id() const
|
2010-01-14 14:48:06 +01:00
|
|
|
{
|
|
|
|
|
return m_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProjectConfiguration::displayName() const
|
|
|
|
|
{
|
2010-08-19 12:26:21 +02:00
|
|
|
if (!m_displayName.isEmpty())
|
|
|
|
|
return m_displayName;
|
|
|
|
|
return m_defaultDisplayName;
|
2010-01-14 14:48:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectConfiguration::setDisplayName(const QString &name)
|
|
|
|
|
{
|
2010-08-19 12:26:21 +02:00
|
|
|
if (displayName() == name)
|
2010-01-14 14:48:06 +01:00
|
|
|
return;
|
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 (name == m_defaultDisplayName)
|
2011-05-20 12:52:59 +02:00
|
|
|
m_displayName.clear();
|
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
|
|
|
else
|
2011-05-20 12:52:59 +02:00
|
|
|
m_displayName = name;
|
2010-01-14 14:48:06 +01:00
|
|
|
emit displayNameChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-19 12:26:21 +02:00
|
|
|
void ProjectConfiguration::setDefaultDisplayName(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
if (m_defaultDisplayName == name)
|
|
|
|
|
return;
|
|
|
|
|
const QString originalName = displayName();
|
|
|
|
|
m_defaultDisplayName = name;
|
|
|
|
|
if (originalName != displayName())
|
|
|
|
|
emit displayNameChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 12:52:59 +02:00
|
|
|
bool ProjectConfiguration::usesDefaultDisplayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_displayName.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 14:48:06 +01:00
|
|
|
QVariantMap ProjectConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
2012-03-15 17:17:40 +01:00
|
|
|
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.name());
|
2010-01-14 14:48:06 +01:00
|
|
|
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
|
2010-08-19 12:26:21 +02:00
|
|
|
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
|
2010-01-14 14:48:06 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProjectConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2012-11-20 07:18:01 +02:00
|
|
|
m_id = Core::Id(map.value(QLatin1String(CONFIGURATION_ID_KEY), QByteArray()).toByteArray());
|
2010-01-14 14:48:06 +01:00
|
|
|
m_displayName = map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
|
2010-11-23 12:17:54 +01:00
|
|
|
m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY),
|
|
|
|
|
m_defaultDisplayName.isEmpty() ?
|
|
|
|
|
m_displayName : m_defaultDisplayName).toString();
|
2012-03-15 17:17:40 +01:00
|
|
|
return m_id.isValid();
|
2010-01-14 14:48:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
Core::Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
2010-01-14 14:48:06 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return Core::Id(map.value(QLatin1String(CONFIGURATION_ID_KEY), QString()).toString());
|
2010-01-14 14:48:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProjectExplorer::displayNameFromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
return map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
|
|
|
|
|
}
|