2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-09-18 15:58:07 +02: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
|
2012-09-18 15:58:07 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-09-18 15:58:07 +02: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.
|
2012-09-18 15:58:07 +02: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
|
2012-09-18 15:58:07 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-09-18 15:58:07 +02:00
|
|
|
|
|
|
|
|
#include "addqtoperation.h"
|
|
|
|
|
|
|
|
|
|
#include "addkeysoperation.h"
|
|
|
|
|
#include "findkeyoperation.h"
|
|
|
|
|
#include "findvalueoperation.h"
|
|
|
|
|
#include "getoperation.h"
|
|
|
|
|
#include "rmkeysoperation.h"
|
|
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
2012-11-20 15:14:33 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
// Qt version file stuff:
|
|
|
|
|
static char PREFIX[] = "QtVersion.";
|
|
|
|
|
static char VERSION[] = "Version";
|
|
|
|
|
|
|
|
|
|
// BaseQtVersion:
|
|
|
|
|
static char ID[] = "Id";
|
|
|
|
|
static char DISPLAYNAME[] = "Name";
|
|
|
|
|
static char AUTODETECTED[] = "isAutodetected";
|
|
|
|
|
static char AUTODETECTION_SOURCE[] = "autodetectionSource";
|
|
|
|
|
static char QMAKE[] = "QMakePath";
|
|
|
|
|
static char TYPE[] = "QtVersion.Type";
|
|
|
|
|
|
|
|
|
|
QString AddQtOperation::name() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("addQt");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AddQtOperation::helpText() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("add a Qt version to Qt Creator");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AddQtOperation::argumentsHelpText() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(" --id <ID> id of the new Qt version. (required)\n"
|
|
|
|
|
" --name <NAME> display name of the new Qt version. (required)\n"
|
|
|
|
|
" --qmake <PATH> path to qmake. (required)\n"
|
|
|
|
|
" --type <TYPE> type of Qt version to add. (required)\n"
|
|
|
|
|
" <KEY> <TYPE:VALUE> extra key value pairs\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AddQtOperation::setArguments(const QStringList &args)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < args.count(); ++i) {
|
|
|
|
|
const QString current = args.at(i);
|
|
|
|
|
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--id")) {
|
2012-10-11 14:00:24 +02:00
|
|
|
if (next.isNull()) {
|
|
|
|
|
std::cerr << "Error parsing after --id." << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
++i; // skip next;
|
|
|
|
|
m_id = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--name")) {
|
2012-10-11 14:00:24 +02:00
|
|
|
if (next.isNull()) {
|
|
|
|
|
std::cerr << "Error parsing after --name." << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
++i; // skip next;
|
|
|
|
|
m_displayName = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--qmake")) {
|
2012-10-11 14:00:24 +02:00
|
|
|
if (next.isNull()) {
|
|
|
|
|
std::cerr << "Error parsing after --qmake." << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
++i; // skip next;
|
|
|
|
|
m_qmake = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--type")) {
|
2012-10-11 14:00:24 +02:00
|
|
|
if (next.isNull()) {
|
|
|
|
|
std::cerr << "Error parsing after --type." << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
++i; // skip next;
|
|
|
|
|
m_type = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 14:00:24 +02:00
|
|
|
if (next.isNull()) {
|
|
|
|
|
std::cerr << "Unknown parameter: " << qPrintable(current) << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
++i; // skip next;
|
|
|
|
|
KeyValuePair pair(current, next);
|
2012-10-11 14:00:24 +02:00
|
|
|
if (!pair.value.isValid()) {
|
|
|
|
|
std::cerr << "Error parsing: " << qPrintable(current) << " " << qPrintable(next) << std::endl << std::endl;
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
2012-10-11 14:00:24 +02:00
|
|
|
}
|
2012-09-18 15:58:07 +02:00
|
|
|
m_extra << pair;
|
|
|
|
|
}
|
|
|
|
|
|
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 (m_id.isEmpty())
|
2012-10-11 14:00:24 +02:00
|
|
|
std::cerr << "Error no id was passed." << std::endl << std::endl;
|
|
|
|
|
|
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 (m_displayName.isEmpty())
|
2012-10-11 14:00:24 +02:00
|
|
|
std::cerr << "Error no display name was passed." << std::endl << std::endl;
|
|
|
|
|
|
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 (m_qmake.isEmpty())
|
2012-10-11 14:00:24 +02:00
|
|
|
std::cerr << "Error no qmake was passed." << std::endl << std::endl;
|
|
|
|
|
|
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 (m_type.isEmpty())
|
2012-10-11 14:00:24 +02:00
|
|
|
std::cerr << "Error no type was passed." << std::endl << std::endl;
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_qmake.isEmpty() && !m_type.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AddQtOperation::execute() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = load(QLatin1String("qtversions"));
|
|
|
|
|
if (map.isEmpty())
|
|
|
|
|
map = initializeQtVersions();
|
|
|
|
|
|
2013-02-22 13:57:00 +01:00
|
|
|
QVariantMap result = addQt(map, m_id, m_displayName, m_type, m_qmake, m_extra);
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2013-05-16 15:47:47 +02:00
|
|
|
if (result.isEmpty() || result == map)
|
2012-09-18 15:58:07 +02:00
|
|
|
return -2;
|
|
|
|
|
|
2013-02-22 13:57:00 +01:00
|
|
|
return save(result, QLatin1String("qtversions")) ? 0 : -3;
|
2012-09-18 15:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
bool AddQtOperation::test() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = initializeQtVersions();
|
|
|
|
|
|
|
|
|
|
if (!map.count() == 1
|
|
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-11-20 15:14:33 +01:00
|
|
|
#if defined Q_OS_WIN
|
|
|
|
|
map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"),
|
|
|
|
|
QLatin1String("/tmp//../tmp/test\\qmake"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
#else
|
2012-09-18 15:58:07 +02:00
|
|
|
map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"),
|
2012-11-20 15:14:33 +01:00
|
|
|
QLatin1String("/tmp//../tmp/test/qmake"),
|
2012-09-18 15:58:07 +02:00
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))));
|
2012-11-20 15:14:33 +01:00
|
|
|
#endif
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2012-09-28 09:50:06 +02:00
|
|
|
if (map.count() != 2
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String("QtVersion.0")))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap version0 = map.value(QLatin1String("QtVersion.0")).toMap();
|
2012-10-09 16:01:56 +02:00
|
|
|
if (version0.count() != 7
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !version0.contains(QLatin1String(ID))
|
|
|
|
|
|| version0.value(QLatin1String(ID)).toInt() != -1
|
|
|
|
|
|| !version0.contains(QLatin1String(DISPLAYNAME))
|
|
|
|
|
|| version0.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version")
|
|
|
|
|
|| !version0.contains(QLatin1String(AUTODETECTED))
|
|
|
|
|
|| version0.value(QLatin1String(AUTODETECTED)).toBool() != true
|
|
|
|
|
|| !version0.contains(QLatin1String(AUTODETECTION_SOURCE))
|
2013-01-22 15:41:10 +01:00
|
|
|
|| version0.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.testId")
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !version0.contains(QLatin1String(TYPE))
|
|
|
|
|
|| version0.value(QLatin1String(TYPE)).toString() != QLatin1String("testType")
|
|
|
|
|
|| !version0.contains(QLatin1String(QMAKE))
|
|
|
|
|
|| version0.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake")
|
|
|
|
|
|| !version0.contains(QLatin1String("extraData"))
|
|
|
|
|
|| version0.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue"))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Ignore existing ids:
|
|
|
|
|
QVariantMap result = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version2"), QLatin1String("testType2"),
|
|
|
|
|
QLatin1String("/tmp/test/qmake2"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (!result.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Make sure name is unique:
|
|
|
|
|
map = addQt(map, QLatin1String("testId2"), QLatin1String("Test Qt Version"), QLatin1String("testType3"),
|
|
|
|
|
QLatin1String("/tmp/test/qmake2"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))));
|
2012-09-28 09:50:06 +02:00
|
|
|
if (map.count() != 3
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String("QtVersion.0"))
|
|
|
|
|
|| !map.contains(QLatin1String("QtVersion.1")))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (map.value(QLatin1String("QtVersion.0")) != version0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap version1 = map.value(QLatin1String("QtVersion.1")).toMap();
|
2012-10-09 16:01:56 +02:00
|
|
|
if (version1.count() != 7
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !version1.contains(QLatin1String(ID))
|
|
|
|
|
|| version1.value(QLatin1String(ID)).toInt() != -1
|
|
|
|
|
|| !version1.contains(QLatin1String(DISPLAYNAME))
|
|
|
|
|
|| version1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version2")
|
|
|
|
|
|| !version1.contains(QLatin1String(AUTODETECTED))
|
|
|
|
|
|| version1.value(QLatin1String(AUTODETECTED)).toBool() != true
|
|
|
|
|
|| !version1.contains(QLatin1String(AUTODETECTION_SOURCE))
|
2013-01-22 15:41:10 +01:00
|
|
|
|| version1.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.testId2")
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !version1.contains(QLatin1String(TYPE))
|
|
|
|
|
|| version1.value(QLatin1String(TYPE)).toString() != QLatin1String("testType3")
|
|
|
|
|
|| !version1.contains(QLatin1String(QMAKE))
|
|
|
|
|
|| version1.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake2")
|
|
|
|
|
|| !version1.contains(QLatin1String("extraData"))
|
|
|
|
|
|| version1.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue"))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
QVariantMap AddQtOperation::addQt(const QVariantMap &map,
|
|
|
|
|
const QString &id, const QString &displayName, const QString &type,
|
|
|
|
|
const QString &qmake, const KeyValuePairList &extra)
|
|
|
|
|
{
|
2012-11-20 16:28:53 +01:00
|
|
|
QString sdkId = id;
|
|
|
|
|
if (!id.startsWith(QLatin1String("SDK.")))
|
|
|
|
|
sdkId = QString::fromLatin1("SDK.") + id;
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
// Sanity check: Make sure autodetection source is not in use already:
|
2012-11-20 16:28:53 +01:00
|
|
|
QStringList valueKeys = FindValueOperation::findValues(map, sdkId);
|
2012-09-18 15:58:07 +02:00
|
|
|
bool hasId = false;
|
|
|
|
|
foreach (const QString &k, valueKeys) {
|
|
|
|
|
if (k.endsWith(QString(QLatin1Char('/')) + QLatin1String(AUTODETECTION_SOURCE))) {
|
|
|
|
|
hasId = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasId) {
|
|
|
|
|
std::cerr << "Error: Id " << qPrintable(id) << " already defined as Qt versions." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find position to insert:
|
|
|
|
|
int versionCount = 0;
|
|
|
|
|
for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
|
|
|
|
|
if (!i.key().startsWith(QLatin1String(PREFIX)))
|
|
|
|
|
continue;
|
|
|
|
|
QString number = i.key().mid(QString::fromLatin1(PREFIX).count());
|
|
|
|
|
bool ok;
|
|
|
|
|
int count = number.toInt(&ok);
|
|
|
|
|
if (ok && count >= versionCount)
|
|
|
|
|
versionCount = count + 1;
|
|
|
|
|
}
|
|
|
|
|
const QString qt = QString::fromLatin1(PREFIX) + QString::number(versionCount);
|
|
|
|
|
|
|
|
|
|
// Sanity check: Make sure displayName is unique.
|
|
|
|
|
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
|
|
|
|
|
QStringList nameList;
|
2013-03-11 17:23:55 +01:00
|
|
|
foreach (const QString &nameKey, nameKeys)
|
2012-09-18 15:58:07 +02:00
|
|
|
nameList << GetOperation::get(map, nameKey).toString();
|
|
|
|
|
const QString uniqueName = makeUnique(displayName, nameList);
|
|
|
|
|
|
2012-11-20 15:14:33 +01:00
|
|
|
// Sanitize qmake path:
|
|
|
|
|
QString saneQmake = QDir::cleanPath(QDir::fromNativeSeparators(qmake));
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
// insert data:
|
|
|
|
|
KeyValuePairList data;
|
|
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1));
|
|
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(uniqueName));
|
|
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true));
|
2012-11-20 16:28:53 +01:00
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(sdkId));
|
2012-11-20 15:14:33 +01:00
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), QVariant(saneQmake));
|
2012-09-18 15:58:07 +02:00
|
|
|
data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(type));
|
|
|
|
|
|
|
|
|
|
KeyValuePairList qtExtraList;
|
|
|
|
|
foreach (const KeyValuePair &pair, extra)
|
|
|
|
|
qtExtraList << KeyValuePair(QStringList() << qt << pair.key, pair.value);
|
|
|
|
|
data.append(qtExtraList);
|
|
|
|
|
|
|
|
|
|
return AddKeysOperation::addKeys(map, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AddQtOperation::initializeQtVersions()
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
map.insert(QLatin1String(VERSION), 1);
|
|
|
|
|
return map;
|
|
|
|
|
}
|