2010-01-19 16:59:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-19 16:59:18 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2010-01-19 16:59:18 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-01-19 16:59:18 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-01-19 16:59:18 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2011-09-16 12:57:37 +02:00
|
|
|
#include "settingsaccessor.h"
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
#include "buildconfiguration.h"
|
2012-06-26 15:35:11 +02:00
|
|
|
#include "devicesupport/devicemanager.h"
|
2010-01-19 16:59:18 +01:00
|
|
|
#include "project.h"
|
2010-07-08 13:40:19 +02:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "projectexplorersettings.h"
|
2010-09-09 11:48:01 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "profile.h"
|
|
|
|
|
#include "profilemanager.h"
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2010-05-19 15:17:12 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-01-19 16:59:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-10-19 17:51:52 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <utils/persistentsettings.h>
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
2012-04-17 08:01:25 +02:00
|
|
|
#include <QFile>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMessageBox>
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// UserFileVersionHandler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
class UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
UserFileVersionHandler();
|
|
|
|
|
virtual ~UserFileVersionHandler();
|
|
|
|
|
|
|
|
|
|
// The user file version this handler accepts for input.
|
|
|
|
|
virtual int userFileVersion() const = 0;
|
|
|
|
|
virtual QString displayUserFileVersion() const = 0;
|
|
|
|
|
// Update from userFileVersion() to userFileVersion() + 1
|
|
|
|
|
virtual QVariantMap update(Project *project, const QVariantMap &map) = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
typedef QPair<QLatin1String,QLatin1String> Change;
|
|
|
|
|
QVariantMap renameKeys(const QList<Change> &changes, QVariantMap map);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UserFileVersionHandler::UserFileVersionHandler()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserFileVersionHandler::~UserFileVersionHandler()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Performs a simple renaming of the listed keys in \a changes recursively on \a map.
|
|
|
|
|
*/
|
|
|
|
|
QVariantMap UserFileVersionHandler::renameKeys(const QList<Change> &changes, QVariantMap map)
|
|
|
|
|
{
|
|
|
|
|
foreach (const Change &change, changes) {
|
|
|
|
|
QVariantMap::iterator oldSetting = map.find(change.first);
|
|
|
|
|
if (oldSetting != map.end()) {
|
|
|
|
|
map.insert(change.second, oldSetting.value());
|
|
|
|
|
map.erase(oldSetting);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap::iterator i = map.begin();
|
|
|
|
|
while (i != map.end()) {
|
|
|
|
|
QVariant v = i.value();
|
|
|
|
|
if (v.type() == QVariant::Map)
|
|
|
|
|
i.value() = renameKeys(changes, v.toMap());
|
|
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // ProjectExplorer
|
|
|
|
|
|
|
|
|
|
|
2010-01-19 16:59:18 +01:00
|
|
|
using namespace ProjectExplorer;
|
2011-09-15 11:32:15 +02:00
|
|
|
using namespace Internal;
|
2011-08-16 10:45:23 +02:00
|
|
|
using Utils::PersistentSettingsReader;
|
|
|
|
|
using Utils::PersistentSettingsWriter;
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
namespace {
|
2010-11-19 21:26:36 +01:00
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
const char VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion";
|
|
|
|
|
const char ENVIRONMENT_ID_KEY[] = "ProjectExplorer.Project.Updater.EnvironmentId";
|
2011-10-04 14:54:24 +02:00
|
|
|
const char USER_STICKY_KEYS_KEY[] = "ProjectExplorer.Project.UserStickyKeys";
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
const char SHARED_SETTINGS[] = "SharedSettings";
|
2011-09-15 15:44:49 +02:00
|
|
|
|
2010-01-19 16:59:18 +01:00
|
|
|
// Version 0 is used in Qt Creator 1.3.x and
|
2010-03-11 17:47:09 +01:00
|
|
|
// (in a slighly different flavour) post 1.3 master.
|
2010-01-19 16:59:18 +01:00
|
|
|
class Version0Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("1.3");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QVariantMap convertBuildConfigurations(Project *project, const QVariantMap &map);
|
|
|
|
|
QVariantMap convertRunConfigurations(Project *project, const QVariantMap &map);
|
|
|
|
|
QVariantMap convertBuildSteps(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
// Version 1 is used in master post Qt Creator 1.3.x.
|
|
|
|
|
// It was never used in any official release but is required for the
|
|
|
|
|
// transition to later versions (which introduce support for targets).
|
|
|
|
|
class Version1Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("1.3+git");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct TargetDescription
|
|
|
|
|
{
|
|
|
|
|
TargetDescription(QString tid, QString dn) :
|
|
|
|
|
id(tid),
|
|
|
|
|
displayName(dn)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TargetDescription(const TargetDescription &td) :
|
|
|
|
|
id(td.id),
|
|
|
|
|
displayName(td.displayName)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString id;
|
|
|
|
|
QString displayName;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-11 17:47:09 +01:00
|
|
|
// Version 2 is used in master post Qt Creator 2.0 alpha.
|
|
|
|
|
class Version2Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("2.0-alpha+git");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-24 13:33:54 +01:00
|
|
|
// Version 3 reflect the move of symbian signing from run to build step.
|
|
|
|
|
class Version3Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("2.0-alpha2+git");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-06 17:56:01 +02:00
|
|
|
// Version 4 reflects the introduction of deploy steps
|
|
|
|
|
class Version4Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
2010-09-28 14:40:45 +02:00
|
|
|
return QLatin1String("2.1pre1");
|
2010-07-06 17:56:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-15 13:58:18 +02:00
|
|
|
// Version 5 reflects the introduction of new deploy steps for Symbian/Maemo
|
|
|
|
|
class Version5Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
2010-09-28 14:40:45 +02:00
|
|
|
return QLatin1String("2.1pre2");
|
2010-07-15 13:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-09-28 14:40:45 +02:00
|
|
|
// Version 6 reflects the introduction of new deploy steps for Symbian/Maemo
|
2010-07-16 14:00:41 +02:00
|
|
|
class Version6Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
2010-09-28 14:40:45 +02:00
|
|
|
return QLatin1String("2.1pre3");
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-09-28 14:40:45 +02:00
|
|
|
// Version 7 reflects the introduction of new deploy configuration for Symbian
|
2010-08-10 12:31:55 +02:00
|
|
|
class Version7Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
2010-09-28 14:40:45 +02:00
|
|
|
return QLatin1String("2.1pre4");
|
2010-08-10 12:31:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 17:51:52 +02:00
|
|
|
// Version 8 reflects the change of environment variable expansion rules,
|
|
|
|
|
// turning some env variables into expandos, the change of argument quoting rules,
|
|
|
|
|
// and the change of VariableManager's expansion syntax.
|
|
|
|
|
class Version8Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
// pre5 because we renamed 2.2 to 2.1 later, so people already have 2.2pre4 files
|
|
|
|
|
return QLatin1String("2.2pre5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
// Version 9 reflects the refactoring of the Maemo deploy step.
|
|
|
|
|
class Version9Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 9;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("2.3pre1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
|
|
|
|
|
2012-01-23 14:55:58 +01:00
|
|
|
// Version 10 introduces disabling buildsteps, and handles upgrading custom process steps
|
|
|
|
|
class Version10Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("2.5pre1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
};
|
2011-03-09 12:07:35 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// Version 10 introduces disabling buildsteps, and handles upgrading custom process steps
|
|
|
|
|
class Version11Handler : public UserFileVersionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Version11Handler();
|
|
|
|
|
~Version11Handler();
|
|
|
|
|
|
|
|
|
|
int userFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return 11;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayUserFileVersion() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("2.6pre1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap update(Project *project, const QVariantMap &map);
|
|
|
|
|
|
|
|
|
|
private:
|
2012-08-07 14:01:52 +02:00
|
|
|
Profile *uniqueProfile(Profile *p);
|
|
|
|
|
void addBuildConfiguration(Profile *p, const QVariantMap &bc, int bcPos, int bcCount);
|
|
|
|
|
void addDeployConfiguration(Profile *p, const QVariantMap &dc, int dcPos, int dcActive);
|
|
|
|
|
void addRunConfigurations(Profile *p,
|
2012-08-08 11:23:45 +03:00
|
|
|
const QMap<int, QVariantMap> &rcs, int activeRc, const QString &projectDir);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
void parseQtversionFile();
|
|
|
|
|
void parseToolChainFile();
|
|
|
|
|
|
|
|
|
|
class ToolChainExtraData {
|
|
|
|
|
public:
|
|
|
|
|
explicit ToolChainExtraData(const QString &mks = QString(), const QString &d = QString()) :
|
|
|
|
|
m_mkspec(mks), m_debugger(d)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QString m_mkspec;
|
|
|
|
|
QString m_debugger;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QHash<QString, ToolChainExtraData> m_toolChainExtras;
|
|
|
|
|
QHash<int, QString> m_qtVersionExtras;
|
|
|
|
|
|
|
|
|
|
QHash<Profile *, QVariantMap> m_targets;
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 17:51:52 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
//
|
|
|
|
|
// Helper functions:
|
|
|
|
|
//
|
|
|
|
|
|
2010-10-19 17:51:52 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
2011-08-03 12:32:24 +02:00
|
|
|
class HandlerNode
|
|
|
|
|
{
|
2010-10-19 17:51:52 +02:00
|
|
|
public:
|
|
|
|
|
QSet<QString> strings;
|
|
|
|
|
QHash<QString, HandlerNode> children;
|
|
|
|
|
};
|
2011-08-03 12:32:24 +02:00
|
|
|
|
2010-10-19 17:51:52 +02:00
|
|
|
Q_DECLARE_TYPEINFO(HandlerNode, Q_MOVABLE_TYPE);
|
|
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
static HandlerNode buildHandlerNodes(const char * const **keys)
|
|
|
|
|
{
|
|
|
|
|
HandlerNode ret;
|
|
|
|
|
while (const char *rname = *(*keys)++) {
|
|
|
|
|
QString name = QLatin1String(rname);
|
|
|
|
|
if (name.endsWith(QLatin1Char('.'))) {
|
|
|
|
|
HandlerNode sub = buildHandlerNodes(keys);
|
|
|
|
|
foreach (const QString &key, name.split(QLatin1Char('|')))
|
|
|
|
|
ret.children.insert(key, sub);
|
|
|
|
|
} else {
|
|
|
|
|
ret.strings.insert(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QVariantMap processHandlerNodes(const HandlerNode &node, const QVariantMap &map,
|
|
|
|
|
QVariant (*handler)(const QVariant &var))
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &key = it.key();
|
|
|
|
|
if (node.strings.contains(key)) {
|
|
|
|
|
result.insert(key, handler(it.value()));
|
|
|
|
|
goto handled;
|
|
|
|
|
}
|
|
|
|
|
if (it.value().type() == QVariant::Map)
|
|
|
|
|
for (QHash<QString, HandlerNode>::ConstIterator subit = node.children.constBegin();
|
|
|
|
|
subit != node.children.constEnd(); ++subit)
|
|
|
|
|
if (key.startsWith(subit.key())) {
|
|
|
|
|
result.insert(key, processHandlerNodes(subit.value(), it.value().toMap(), handler));
|
|
|
|
|
goto handled;
|
|
|
|
|
}
|
|
|
|
|
result.insert(key, it.value());
|
|
|
|
|
handled: ;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// UserFileAccessor
|
|
|
|
|
// -------------------------------------------------------------------------
|
2012-08-17 13:18:31 +02:00
|
|
|
SettingsAccessor::SettingsAccessor(Project *project) :
|
2010-01-19 16:59:18 +01:00
|
|
|
m_firstVersion(-1),
|
2011-09-15 11:32:15 +02:00
|
|
|
m_lastVersion(-1),
|
|
|
|
|
m_userFileAcessor(QByteArray("qtcUserFileName"),
|
|
|
|
|
QLatin1String(".user"),
|
|
|
|
|
QString::fromLocal8Bit(qgetenv("QTC_EXTENSION")),
|
2011-09-15 15:44:49 +02:00
|
|
|
true,
|
2012-08-17 13:18:31 +02:00
|
|
|
true,
|
|
|
|
|
this),
|
2011-09-15 15:44:49 +02:00
|
|
|
m_sharedFileAcessor(QByteArray("qtcSharedFileName"),
|
|
|
|
|
QLatin1String(".shared"),
|
|
|
|
|
QString::fromLocal8Bit(qgetenv("QTC_SHARED_EXTENSION")),
|
|
|
|
|
false,
|
2012-08-17 13:18:31 +02:00
|
|
|
false,
|
|
|
|
|
this),
|
|
|
|
|
m_project(project)
|
2010-01-19 16:59:18 +01:00
|
|
|
{
|
2012-08-17 13:18:31 +02:00
|
|
|
QTC_CHECK(m_project);
|
|
|
|
|
|
2010-01-19 16:59:18 +01:00
|
|
|
addVersionHandler(new Version0Handler);
|
2010-02-08 15:50:06 +01:00
|
|
|
addVersionHandler(new Version1Handler);
|
2010-03-11 17:47:09 +01:00
|
|
|
addVersionHandler(new Version2Handler);
|
2010-03-24 13:33:54 +01:00
|
|
|
addVersionHandler(new Version3Handler);
|
2010-07-06 17:56:01 +02:00
|
|
|
addVersionHandler(new Version4Handler);
|
2010-07-15 13:58:18 +02:00
|
|
|
addVersionHandler(new Version5Handler);
|
2010-07-16 14:00:41 +02:00
|
|
|
addVersionHandler(new Version6Handler);
|
2010-08-10 12:31:55 +02:00
|
|
|
addVersionHandler(new Version7Handler);
|
2010-10-19 17:51:52 +02:00
|
|
|
addVersionHandler(new Version8Handler);
|
2011-03-09 12:07:35 +01:00
|
|
|
addVersionHandler(new Version9Handler);
|
2012-01-23 14:55:58 +01:00
|
|
|
addVersionHandler(new Version10Handler);
|
2012-04-24 15:49:09 +02:00
|
|
|
addVersionHandler(new Version11Handler);
|
2010-01-19 16:59:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
SettingsAccessor::~SettingsAccessor()
|
2010-01-19 16:59:18 +01:00
|
|
|
{
|
|
|
|
|
qDeleteAll(m_handlers);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
Project *SettingsAccessor::project() const
|
|
|
|
|
{ return m_project; }
|
2011-09-15 11:32:15 +02:00
|
|
|
|
2011-09-15 15:44:49 +02:00
|
|
|
namespace {
|
|
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
// It's assumed that the shared map has the same structure as the user map.
|
|
|
|
|
template <class Operation_T>
|
|
|
|
|
void synchronizeSettings(QVariantMap *userMap,
|
|
|
|
|
const QVariantMap &sharedMap,
|
|
|
|
|
Operation_T *op)
|
2011-09-15 15:44:49 +02:00
|
|
|
{
|
|
|
|
|
QVariantMap::const_iterator it = sharedMap.begin();
|
|
|
|
|
QVariantMap::const_iterator eit = sharedMap.end();
|
|
|
|
|
for (; it != eit; ++it) {
|
|
|
|
|
const QString &key = it.key();
|
2011-10-04 14:54:24 +02:00
|
|
|
const QVariant &sharedValue = it.value();
|
|
|
|
|
const QVariant &userValue = userMap->value(key);
|
|
|
|
|
if (sharedValue.type() == QVariant::Map) {
|
|
|
|
|
if (userValue.type() != QVariant::Map) {
|
2011-09-15 15:44:49 +02:00
|
|
|
// This should happen only if the user manually changed the file in such a way.
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-10-04 14:54:24 +02:00
|
|
|
QVariantMap nestedUserMap = userValue.toMap();
|
|
|
|
|
synchronizeSettings(&nestedUserMap,
|
|
|
|
|
sharedValue.toMap(),
|
|
|
|
|
op);
|
|
|
|
|
userMap->insert(key, nestedUserMap);
|
|
|
|
|
} else if (userMap->contains(key) && userValue != sharedValue) {
|
|
|
|
|
op->apply(userMap, key, sharedValue);
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
|
|
|
|
|
struct MergeSharedSetting
|
2011-09-15 15:44:49 +02:00
|
|
|
{
|
2011-10-04 14:54:24 +02:00
|
|
|
MergeSharedSetting(const QSet<QString> &sticky) : m_userSticky(sticky) {}
|
|
|
|
|
|
|
|
|
|
void apply(QVariantMap *userMap, const QString &key, const QVariant &sharedValue)
|
|
|
|
|
{
|
|
|
|
|
if (!m_userSticky.contains(key))
|
|
|
|
|
userMap->insert(key, sharedValue);
|
|
|
|
|
}
|
|
|
|
|
QSet<QString> m_userSticky;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// When restoring settings...
|
|
|
|
|
// We check whether a .shared file exists. If so, we compare the settings in this file with
|
|
|
|
|
// corresponding ones in the .user file. Whenever we identify a corresponding setting which
|
|
|
|
|
// has a different value and which is not marked as sticky, we merge the .shared value into
|
|
|
|
|
// the .user value.
|
|
|
|
|
void mergeSharedSettings(QVariantMap *userMap, const QVariantMap &sharedMap)
|
|
|
|
|
{
|
|
|
|
|
if (sharedMap.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QSet<QString> stickyKeys;
|
2012-01-09 16:30:33 +01:00
|
|
|
const QVariant stickyList = userMap->take(QLatin1String(USER_STICKY_KEYS_KEY)).toList();
|
2011-10-04 14:54:24 +02:00
|
|
|
if (stickyList.isValid()) {
|
|
|
|
|
if (stickyList.type() != QVariant::List) {
|
|
|
|
|
// File is messed up... The user probably changed something.
|
|
|
|
|
return;
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
2011-10-04 14:54:24 +02:00
|
|
|
foreach (const QVariant &v, stickyList.toList())
|
|
|
|
|
stickyKeys.insert(v.toString());
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
2011-10-04 14:54:24 +02:00
|
|
|
|
|
|
|
|
MergeSharedSetting op(stickyKeys);
|
|
|
|
|
synchronizeSettings(userMap, sharedMap, &op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TrackUserStickySetting
|
|
|
|
|
{
|
|
|
|
|
void apply(QVariantMap *, const QString &key, const QVariant &)
|
|
|
|
|
{
|
|
|
|
|
m_userSticky.insert(key);
|
|
|
|
|
}
|
|
|
|
|
QSet<QString> m_userSticky;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// When saving settings...
|
|
|
|
|
// If a .shared file was considered in the previous restoring step, we check whether for
|
|
|
|
|
// any of the current .shared settings there's a .user one which is different. If so, this
|
|
|
|
|
// means the user explicitly changed it and we mark this setting as sticky.
|
|
|
|
|
// Note that settings are considered sticky only when they differ from the .shared ones.
|
|
|
|
|
// Although this approach is more flexible than permanent/forever sticky settings, it has
|
|
|
|
|
// the side-effect that if a particular value unintentionally becomes the same in both
|
|
|
|
|
// the .user and .shared files, this setting will "unstick".
|
|
|
|
|
void trackUserStickySettings(QVariantMap *userMap, const QVariantMap &sharedMap)
|
|
|
|
|
{
|
|
|
|
|
if (sharedMap.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TrackUserStickySetting op;
|
|
|
|
|
synchronizeSettings(userMap, sharedMap, &op);
|
|
|
|
|
|
2012-01-09 16:30:33 +01:00
|
|
|
userMap->insert(QLatin1String(USER_STICKY_KEYS_KEY), QVariant(op.m_userSticky.toList()));
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Anonymous
|
|
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
QVariantMap SettingsAccessor::restoreSettings() const
|
2010-01-19 16:59:18 +01:00
|
|
|
{
|
2012-08-17 13:18:31 +02:00
|
|
|
if (m_lastVersion < 0)
|
2010-01-19 16:59:18 +01:00
|
|
|
return QVariantMap();
|
|
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
SettingsData settings;
|
2012-08-17 13:18:31 +02:00
|
|
|
QString fn = project()->property(m_userFileAcessor.id()).toString();
|
|
|
|
|
if (fn.isEmpty())
|
|
|
|
|
fn = project()->document()->fileName() + m_userFileAcessor.suffix();
|
|
|
|
|
settings.m_fileName = Utils::FileName::fromString(fn);
|
|
|
|
|
if (!m_userFileAcessor.readFile(&settings))
|
2011-10-04 14:54:24 +02:00
|
|
|
settings.clear(); // No user settings, but there can still be shared ones.
|
|
|
|
|
|
|
|
|
|
if (settings.isValid()) {
|
2012-08-17 13:18:31 +02:00
|
|
|
if (settings.m_version > m_lastVersion + 1) {
|
2011-10-04 14:54:24 +02:00
|
|
|
QMessageBox::information(
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::mainWindow(),
|
2011-10-04 14:54:24 +02:00
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
|
|
|
|
"Using Old Project Settings File"),
|
|
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
2011-10-13 17:23:06 +02:00
|
|
|
"<html><head/><body><p>A versioned backup of the .user "
|
2011-10-04 14:54:24 +02:00
|
|
|
"settings file will be used, because the non-versioned "
|
|
|
|
|
"file was created by an incompatible newer version of "
|
|
|
|
|
"Qt Creator.</p><p>Project settings changes made since "
|
|
|
|
|
"the last time this version of Qt Creator was used "
|
|
|
|
|
"with this project are ignored, and changes made now "
|
|
|
|
|
"will <b>not</b> be propagated to the newer version."
|
|
|
|
|
"</p></body></html>"),
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify environment.
|
|
|
|
|
if (!verifyEnvironmentId(settings.m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toString())) {
|
|
|
|
|
// TODO tr, casing check
|
|
|
|
|
QMessageBox msgBox(
|
|
|
|
|
QMessageBox::Question,
|
|
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
|
|
|
|
"Project Settings File from a different Environment?"),
|
|
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
|
|
|
|
"Qt Creator has found a .user settings file which was "
|
|
|
|
|
"created for another development setup, maybe "
|
|
|
|
|
"originating from another machine.\n\n"
|
|
|
|
|
"The .user settings files contain environment specific "
|
|
|
|
|
"settings. They should not be copied to a different "
|
|
|
|
|
"environment. \n\n"
|
|
|
|
|
"Do you still want to load the settings file?"),
|
|
|
|
|
QMessageBox::Yes | QMessageBox::No,
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::mainWindow());
|
2011-10-04 14:54:24 +02:00
|
|
|
msgBox.setDefaultButton(QMessageBox::No);
|
|
|
|
|
msgBox.setEscapeButton(QMessageBox::No);
|
|
|
|
|
if (msgBox.exec() == QMessageBox::No)
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Do we need to generate a backup?
|
|
|
|
|
if (settings.m_version < m_lastVersion + 1 && !settings.m_usingBackup) {
|
2012-08-20 18:52:20 +02:00
|
|
|
const QString &backupFileName = settings.m_fileName.toString()
|
2012-01-09 16:30:33 +01:00
|
|
|
+ QLatin1Char('.')
|
2011-10-04 14:54:24 +02:00
|
|
|
+ m_handlers.value(settings.m_version)->displayUserFileVersion();
|
|
|
|
|
QFile::remove(backupFileName); // Remove because copy doesn't overwrite
|
2012-08-20 18:52:20 +02:00
|
|
|
QFile::copy(settings.m_fileName.toString(), backupFileName);
|
2011-10-04 14:54:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-18 18:35:40 +01:00
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
|
|
|
|
|
// Time to consider shared settings...
|
2011-09-15 15:44:49 +02:00
|
|
|
SettingsData sharedSettings;
|
2012-08-27 14:05:46 +02:00
|
|
|
if (!sharedSettings.m_fileName.isEmpty() && m_sharedFileAcessor.readFile(&sharedSettings)) {
|
2011-10-04 14:54:24 +02:00
|
|
|
bool useSharedSettings = true;
|
|
|
|
|
if (sharedSettings.m_version != settings.m_version) {
|
|
|
|
|
int baseFileVersion;
|
2011-09-15 15:44:49 +02:00
|
|
|
if (sharedSettings.m_version > m_lastVersion + 1) {
|
2011-10-04 14:54:24 +02:00
|
|
|
// The shared file version is newer than Creator... If we have valid user
|
|
|
|
|
// settings we prompt the user whether we could try an *unsupported* update.
|
|
|
|
|
// This makes sense since the merging operation will only replace shared settings
|
|
|
|
|
// that perfectly match corresponding user ones. If we don't have valid user
|
|
|
|
|
// settings to compare against, there's nothing we can do.
|
|
|
|
|
if (!settings.isValid())
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
|
2011-09-15 15:44:49 +02:00
|
|
|
QMessageBox msgBox(
|
|
|
|
|
QMessageBox::Question,
|
|
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
|
|
|
|
"Unsupported Shared Settings File"),
|
|
|
|
|
QApplication::translate("ProjectExplorer::SettingsAccessor",
|
|
|
|
|
"The version of your .shared file is not yet "
|
2011-10-04 14:54:24 +02:00
|
|
|
"supported by this Qt Creator version. "
|
|
|
|
|
"Only settings that are still compatible "
|
|
|
|
|
"will be taken into account.\n\n"
|
2011-09-15 15:44:49 +02:00
|
|
|
"Do you want to continue?\n\n"
|
|
|
|
|
"If you choose not to continue Qt Creator will "
|
2011-10-04 14:54:24 +02:00
|
|
|
"not try to load the .shared file."),
|
2011-09-15 15:44:49 +02:00
|
|
|
QMessageBox::Yes | QMessageBox::No,
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::mainWindow());
|
2011-09-15 15:44:49 +02:00
|
|
|
msgBox.setDefaultButton(QMessageBox::No);
|
|
|
|
|
msgBox.setEscapeButton(QMessageBox::No);
|
|
|
|
|
if (msgBox.exec() == QMessageBox::No)
|
|
|
|
|
useSharedSettings = false;
|
|
|
|
|
else
|
2011-10-04 14:54:24 +02:00
|
|
|
baseFileVersion = m_lastVersion + 1;
|
2011-09-15 15:44:49 +02:00
|
|
|
} else {
|
2011-10-04 14:54:24 +02:00
|
|
|
baseFileVersion = qMax(settings.m_version, sharedSettings.m_version);
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useSharedSettings) {
|
|
|
|
|
// We now update the user and shared settings so they are compatible.
|
2011-10-04 14:54:24 +02:00
|
|
|
for (int i = sharedSettings.m_version; i < baseFileVersion; ++i)
|
2012-08-17 13:18:31 +02:00
|
|
|
sharedSettings.m_map = m_handlers.value(i)->update(m_project, sharedSettings.m_map);
|
2011-10-04 14:54:24 +02:00
|
|
|
|
|
|
|
|
if (!settings.isValid()) {
|
2012-08-17 13:18:31 +02:00
|
|
|
m_project->setProperty(SHARED_SETTINGS, sharedSettings.m_map);
|
2011-10-04 14:54:24 +02:00
|
|
|
return sharedSettings.m_map;
|
|
|
|
|
}
|
|
|
|
|
for (int i = settings.m_version; i < baseFileVersion; ++i)
|
2012-08-17 13:18:31 +02:00
|
|
|
settings.m_map = m_handlers.value(i)->update(m_project, settings.m_map);
|
2011-10-04 14:54:24 +02:00
|
|
|
settings.m_version = baseFileVersion;
|
2011-09-15 15:44:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-04 14:54:24 +02:00
|
|
|
|
|
|
|
|
if (useSharedSettings) {
|
2012-08-17 13:18:31 +02:00
|
|
|
m_project->setProperty(SHARED_SETTINGS, sharedSettings.m_map);
|
2011-10-04 14:54:24 +02:00
|
|
|
if (!settings.isValid())
|
|
|
|
|
return sharedSettings.m_map;
|
|
|
|
|
|
|
|
|
|
mergeSharedSettings(&settings.m_map, sharedSettings.m_map);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
if (!settings.isValid())
|
|
|
|
|
return QVariantMap();
|
2010-01-19 16:59:18 +01:00
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
// Update from the base version to Creator's version.
|
|
|
|
|
for (int i = settings.m_version; i <= m_lastVersion; ++i)
|
2012-08-17 13:18:31 +02:00
|
|
|
settings.m_map = m_handlers.value(i)->update(m_project, settings.m_map);
|
2011-09-15 15:44:49 +02:00
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
return settings.m_map;
|
2010-01-19 16:59:18 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
bool SettingsAccessor::saveSettings(const QVariantMap &map) const
|
2010-01-19 16:59:18 +01:00
|
|
|
{
|
2012-08-17 13:18:31 +02:00
|
|
|
if (map.isEmpty())
|
2010-01-19 16:59:18 +01:00
|
|
|
return false;
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
SettingsData settings(map);
|
2012-08-17 13:18:31 +02:00
|
|
|
QString fn = project()->property(m_userFileAcessor.id()).toString();
|
|
|
|
|
if (fn.isEmpty())
|
|
|
|
|
fn = project()->document()->fileName() + m_userFileAcessor.suffix();
|
|
|
|
|
settings.m_fileName = Utils::FileName::fromString(fn);
|
|
|
|
|
const QVariant &shared = m_project->property(SHARED_SETTINGS);
|
2011-10-04 14:54:24 +02:00
|
|
|
if (shared.isValid())
|
|
|
|
|
trackUserStickySettings(&settings.m_map, shared.toMap());
|
2011-09-15 15:44:49 +02:00
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
return m_userFileAcessor.writeFile(&settings);
|
2010-01-19 16:59:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
void SettingsAccessor::addVersionHandler(UserFileVersionHandler *handler)
|
2010-01-19 16:59:18 +01:00
|
|
|
{
|
|
|
|
|
const int version(handler->userFileVersion());
|
|
|
|
|
QTC_ASSERT(handler, return);
|
|
|
|
|
QTC_ASSERT(version >= 0, return);
|
|
|
|
|
QTC_ASSERT(!m_handlers.contains(version), return);
|
|
|
|
|
QTC_ASSERT(m_handlers.isEmpty() ||
|
|
|
|
|
(version == m_lastVersion + 1 || version == m_firstVersion - 1), return);
|
|
|
|
|
|
|
|
|
|
if (m_handlers.isEmpty()) {
|
|
|
|
|
m_firstVersion = version;
|
|
|
|
|
m_lastVersion = version;
|
|
|
|
|
} else {
|
|
|
|
|
if (version < m_firstVersion)
|
|
|
|
|
m_firstVersion = version;
|
|
|
|
|
if (version > m_lastVersion)
|
|
|
|
|
m_lastVersion = version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_handlers.insert(version, handler);
|
|
|
|
|
|
|
|
|
|
// Postconditions:
|
|
|
|
|
Q_ASSERT(m_lastVersion >= 0);
|
|
|
|
|
Q_ASSERT(m_firstVersion >= 0);
|
|
|
|
|
Q_ASSERT(m_lastVersion >= m_firstVersion);
|
|
|
|
|
Q_ASSERT(m_handlers.count() == m_lastVersion - m_firstVersion + 1);
|
|
|
|
|
for (int i = m_firstVersion; i < m_lastVersion; ++i)
|
|
|
|
|
Q_ASSERT(m_handlers.contains(i));
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
bool SettingsAccessor::verifyEnvironmentId(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
QUuid fileEnvironmentId(id);
|
|
|
|
|
if (!fileEnvironmentId.isNull()
|
|
|
|
|
&& fileEnvironmentId
|
|
|
|
|
!= ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-04 14:54:24 +02:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// SettingsData
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
void SettingsAccessor::SettingsData::clear()
|
|
|
|
|
{
|
|
|
|
|
m_version = -1;
|
|
|
|
|
m_usingBackup = false;
|
|
|
|
|
m_map.clear();
|
|
|
|
|
m_fileName.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SettingsAccessor::SettingsData::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return m_version > -1 && !m_fileName.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// FileAcessor
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
SettingsAccessor::FileAccessor::FileAccessor(const QByteArray &id,
|
|
|
|
|
const QString &defaultSuffix,
|
|
|
|
|
const QString &environmentSuffix,
|
2011-09-15 15:44:49 +02:00
|
|
|
bool envSpecific,
|
2012-08-17 13:18:31 +02:00
|
|
|
bool versionStrict, SettingsAccessor *accessor)
|
2011-09-15 11:32:15 +02:00
|
|
|
: m_id(id)
|
|
|
|
|
, m_environmentSpecific(envSpecific)
|
2011-09-15 15:44:49 +02:00
|
|
|
, m_versionStrict(versionStrict)
|
2012-08-17 13:18:31 +02:00
|
|
|
, m_accessor(accessor)
|
|
|
|
|
, m_writer(0)
|
2011-09-15 11:32:15 +02:00
|
|
|
{
|
|
|
|
|
assignSuffix(defaultSuffix, environmentSuffix);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
SettingsAccessor::FileAccessor::~FileAccessor()
|
|
|
|
|
{
|
|
|
|
|
delete m_writer;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
void SettingsAccessor::FileAccessor::assignSuffix(const QString &defaultSuffix,
|
|
|
|
|
const QString &environmentSuffix)
|
|
|
|
|
{
|
|
|
|
|
if (!environmentSuffix.isEmpty()) {
|
|
|
|
|
m_suffix = environmentSuffix;
|
2012-01-09 16:30:33 +01:00
|
|
|
m_suffix.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_.-]")), QString(QLatin1Char('_'))); // replace fishy characters:
|
2011-09-15 11:32:15 +02:00
|
|
|
m_suffix.prepend(QLatin1Char('.'));
|
|
|
|
|
} else {
|
|
|
|
|
m_suffix = defaultSuffix;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SettingsAccessor::FileAccessor::findNewestCompatibleSetting(SettingsData *settings) const
|
|
|
|
|
{
|
2012-08-20 18:52:20 +02:00
|
|
|
const QString baseFileName = settings->m_fileName.toString();
|
2011-09-15 11:32:15 +02:00
|
|
|
const int baseVersion = settings->m_version;
|
|
|
|
|
settings->m_fileName.clear();
|
|
|
|
|
settings->m_version = -1;
|
|
|
|
|
|
|
|
|
|
PersistentSettingsReader reader;
|
|
|
|
|
|
|
|
|
|
QFileInfo fileInfo(baseFileName);
|
|
|
|
|
QStringList fileNameFilter(fileInfo.fileName() + QLatin1String(".*"));
|
|
|
|
|
const QStringList &entryList = fileInfo.absoluteDir().entryList(fileNameFilter);
|
|
|
|
|
QStringList candidates;
|
|
|
|
|
|
|
|
|
|
// First we try to identify the newest old version with a quick check.
|
|
|
|
|
foreach (const QString &file, entryList) {
|
|
|
|
|
const QString &suffix = file.mid(fileInfo.fileName().length() + 1);
|
|
|
|
|
const QString &candidateFileName = baseFileName + QLatin1String(".") + suffix;
|
|
|
|
|
candidates.append(candidateFileName);
|
2012-08-17 13:18:31 +02:00
|
|
|
for (int candidateVersion = m_accessor->m_lastVersion;
|
|
|
|
|
candidateVersion >= m_accessor->m_firstVersion;
|
2011-09-15 11:32:15 +02:00
|
|
|
--candidateVersion) {
|
2012-08-17 13:18:31 +02:00
|
|
|
if (suffix == m_accessor->m_handlers.value(candidateVersion)->displayUserFileVersion()) {
|
2011-09-15 11:32:15 +02:00
|
|
|
if (candidateVersion > settings->m_version) {
|
|
|
|
|
settings->m_version = candidateVersion;
|
2012-08-20 18:52:20 +02:00
|
|
|
settings->m_fileName = Utils::FileName::fromString(candidateFileName);
|
2011-09-15 11:32:15 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings->m_version != -1) {
|
|
|
|
|
if (reader.load(settings->m_fileName)) {
|
|
|
|
|
settings->m_map = reader.restoreValues();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-08-20 18:52:20 +02:00
|
|
|
qWarning() << "Unable to load file" << settings->m_fileName.toUserOutput();
|
2011-09-15 11:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we haven't identified a valid file or if it for any reason failed to load, we
|
|
|
|
|
// try a more expensive check (which is actually needed to identify our own and newer
|
|
|
|
|
// versions as we don't know what extensions will be assigned in the future).
|
|
|
|
|
foreach (const QString &candidateFileName, candidates) {
|
2012-08-20 18:52:20 +02:00
|
|
|
Utils::FileName fn = Utils::FileName::fromString(candidateFileName);
|
|
|
|
|
if (settings->m_fileName == fn)
|
2011-09-15 11:32:15 +02:00
|
|
|
continue; // This one has already failed to load.
|
2012-08-20 18:52:20 +02:00
|
|
|
if (reader.load(fn)) {
|
2011-09-15 11:32:15 +02:00
|
|
|
settings->m_map = reader.restoreValues();
|
|
|
|
|
int candidateVersion = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
|
2012-08-17 13:18:31 +02:00
|
|
|
if (candidateVersion == m_accessor->m_lastVersion + 1) {
|
2011-09-15 11:32:15 +02:00
|
|
|
settings->m_version = candidateVersion;
|
2012-08-20 18:52:20 +02:00
|
|
|
settings->m_fileName = fn;
|
2011-09-15 11:32:15 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Nothing really worked...
|
|
|
|
|
qWarning() << "File version" << baseVersion << "too new.";
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
bool SettingsAccessor::FileAccessor::readFile(SettingsData *settings) const
|
2011-09-15 11:32:15 +02:00
|
|
|
{
|
|
|
|
|
PersistentSettingsReader reader;
|
|
|
|
|
if (!reader.load(settings->m_fileName))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
settings->m_map = reader.restoreValues();
|
|
|
|
|
|
|
|
|
|
// Get and verify file version
|
|
|
|
|
settings->m_version = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
|
2011-09-15 15:44:49 +02:00
|
|
|
if (!m_versionStrict)
|
|
|
|
|
return true;
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
if (settings->m_version < m_accessor->m_firstVersion) {
|
2011-09-15 11:32:15 +02:00
|
|
|
qWarning() << "Version" << settings->m_version << "in" << m_suffix << "too old.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
if (settings->m_version > m_accessor->m_lastVersion + 1) {
|
2011-09-15 11:32:15 +02:00
|
|
|
if (!findNewestCompatibleSetting(settings))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
settings->m_usingBackup = true;
|
2012-08-17 13:18:31 +02:00
|
|
|
m_accessor->project()->setProperty(m_id.constData(), settings->m_fileName.toString());
|
2011-09-15 11:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
bool SettingsAccessor::FileAccessor::writeFile(const SettingsData *settings) const
|
2011-09-15 11:32:15 +02:00
|
|
|
{
|
2012-08-17 13:18:31 +02:00
|
|
|
if (!m_writer || m_writer->fileName() != settings->m_fileName) {
|
|
|
|
|
delete m_writer;
|
|
|
|
|
m_writer = new Utils::PersistentSettingsWriter(settings->m_fileName, QLatin1String("QtCreatorProject"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 17:01:15 +02:00
|
|
|
QVariantMap data;
|
|
|
|
|
|
2011-09-15 11:32:15 +02:00
|
|
|
for (QVariantMap::const_iterator i = settings->m_map.constBegin();
|
|
|
|
|
i != settings->m_map.constEnd();
|
|
|
|
|
++i) {
|
2012-08-31 17:01:15 +02:00
|
|
|
data.insert(i.key(), i.value());
|
2011-09-15 11:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-31 17:01:15 +02:00
|
|
|
data.insert(QLatin1String(VERSION_KEY), m_accessor->m_lastVersion + 1);
|
2011-09-15 11:32:15 +02:00
|
|
|
|
2012-08-17 13:18:31 +02:00
|
|
|
if (m_environmentSpecific)
|
2012-08-31 17:01:15 +02:00
|
|
|
data.insert(QLatin1String(ENVIRONMENT_ID_KEY),
|
|
|
|
|
ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId.toString());
|
|
|
|
|
return m_writer->save(data, Core::ICore::mainWindow());
|
2011-09-15 11:32:15 +02:00
|
|
|
}
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version0Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QVariantMap Version0Handler::convertBuildConfigurations(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(project);
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
|
|
|
|
|
// Find a valid Id to use:
|
|
|
|
|
QString id;
|
2012-08-03 15:24:33 +02:00
|
|
|
if (project->id() == "GenericProjectManager.GenericProject") {
|
2010-01-19 16:59:18 +01:00
|
|
|
id = QLatin1String("GenericProjectManager.GenericBuildConfiguration");
|
2012-08-03 15:24:33 +02:00
|
|
|
} else if (project->id() == "CMakeProjectManager.CMakeProject") {
|
2010-01-19 16:59:18 +01:00
|
|
|
id = QLatin1String("CMakeProjectManager.CMakeBuildConfiguration");
|
2012-08-03 15:24:33 +02:00
|
|
|
} else if (project->id() == "Qt4ProjectManager.Qt4Project") {
|
2010-11-19 16:33:12 +01:00
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.NeedsV0Update"), QVariant());
|
2010-01-19 16:59:18 +01:00
|
|
|
id = QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration");
|
2010-11-19 16:33:12 +01:00
|
|
|
} else {
|
2010-01-19 16:59:18 +01:00
|
|
|
return QVariantMap(); // QmlProjects do not(/no longer) have BuildConfigurations,
|
|
|
|
|
// or we do not know how to handle this.
|
2010-11-19 16:33:12 +01:00
|
|
|
}
|
2010-01-19 16:59:18 +01:00
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
|
|
|
|
|
|
|
|
|
|
for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName")) {
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"),
|
|
|
|
|
i.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id == QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration") ||
|
|
|
|
|
id.startsWith(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration."))) {
|
|
|
|
|
// Qt4BuildConfiguration:
|
|
|
|
|
if (i.key() == QLatin1String("QtVersionId")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId"),
|
|
|
|
|
i.value().toInt());
|
|
|
|
|
} else if (i.key() == QLatin1String("ToolChain")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ToolChain"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("buildConfiguration")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("userEnvironmentChanges")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("useShadowBuild")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("clearSystemEnvironment")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("buildDirectory")) {
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "Unknown Qt4BuildConfiguration Key found:" << i.key() << i.value();
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
} else if (id == QLatin1String("CMakeProjectManager.CMakeBuildConfiguration")) {
|
|
|
|
|
if (i.key() == QLatin1String("userEnvironmentChanges")) {
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("msvcVersion")) {
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.MsvcVersion"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (i.key() == QLatin1String("buildDirectory")) {
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "Unknown CMakeBuildConfiguration Key found:" << i.key() << i.value();
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
} else if (id == QLatin1String("GenericProjectManager.GenericBuildConfiguration")) {
|
|
|
|
|
if (i.key() == QLatin1String("buildDirectory")) {
|
|
|
|
|
result.insert(QLatin1String("GenericProjectManager.GenericBuildConfiguration.BuildDirectory"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "Unknown GenericBuildConfiguration Key found:" << i.key() << i.value();
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
qWarning() << "Unknown BuildConfiguration Key found:" << i.key() << i.value();
|
|
|
|
|
qWarning() << "BuildConfiguration Id is:" << id;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap Version0Handler::convertRunConfigurations(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(project);
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QString id;
|
|
|
|
|
|
|
|
|
|
// Convert Id:
|
|
|
|
|
id = map.value(QLatin1String("Id")).toString();
|
|
|
|
|
if (id.isEmpty())
|
|
|
|
|
id = map.value(QLatin1String("type")).toString();
|
|
|
|
|
if (id.isEmpty())
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
|
|
|
|
|
if (QLatin1String("Qt4ProjectManager.DeviceRunConfiguration") == id)
|
|
|
|
|
id = QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration");
|
|
|
|
|
if (QLatin1String("Qt4ProjectManager.EmulatorRunConfiguration") == id)
|
|
|
|
|
id = QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration");
|
|
|
|
|
// no need to change the CMakeRunConfiguration, CustomExecutableRunConfiguration,
|
|
|
|
|
// MaemoRunConfiguration or Qt4RunConfiguration
|
|
|
|
|
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
|
|
|
|
|
|
|
|
|
|
// Convert everything else:
|
|
|
|
|
for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
|
|
|
|
|
if (i.key() == QLatin1String("Id") || i.key() == QLatin1String("type"))
|
|
|
|
|
continue;
|
|
|
|
|
if (i.key() == QLatin1String("RunConfiguration.name")) {
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"),
|
|
|
|
|
i.value());
|
|
|
|
|
} else if (QLatin1String("CMakeProjectManager.CMakeRunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("CMakeRunConfiguration.Target"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.Target"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguration.WorkingDirectory"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.WorkingDirectory"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguration.UserWorkingDirectory"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguration.UseTerminal"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UseTerminal"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguation.Title"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguation.Title"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguration.Arguments"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.Arguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CMakeRunConfiguration.UserEnvironmentChanges"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("BaseEnvironmentBase"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.BaseEnvironmentBase"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown CMakeRunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("ProFile"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.ProFile"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("SigningMode"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.SigningMode"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CustomSignaturePath"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CustomSignaturePath"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CustomKeyPath"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CustomKeyPath"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("SerialPortName"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.SerialPortName"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CommunicationType"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CommunicationType"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CommandLineArguments"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown S60DeviceRunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("ProFile"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration.ProFile"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown S60EmulatorRunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("Qt4ProjectManager.Qt4RunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("ProFile"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.ProFile"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("CommandLineArguments"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserSetName"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserSetName"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UseTerminal"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UseDyldImageSuffix"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserEnvironmentChanges"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("BaseEnvironmentBase"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserSetWorkingDirectory"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserWorkingDirectory"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown Qt4RunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("Qt4ProjectManager.MaemoRunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("ProFile"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.ProFile"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("Arguments"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Arguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("Simulator"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Simulator"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("DeviceId"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("LastDeployed"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.LastDeployed"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("DebuggingHelpersLastDeployed"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DebuggingHelpersLastDeployed"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown MaemoRunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("Executable"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.Executable"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("Arguments"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.Arguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("WorkingDirectory"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UseTerminal"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserSetName"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserSetName"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserName"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserName"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("UserEnvironmentChanges"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("BaseEnvironmentBase"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown CustomExecutableRunConfiguration key found:" << i.key() << i.value();
|
|
|
|
|
} else {
|
|
|
|
|
result.insert(i.key(), i.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap Version0Handler::convertBuildSteps(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(project);
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
|
|
|
|
|
QString id(map.value(QLatin1String("Id")).toString());
|
|
|
|
|
if (QLatin1String("GenericProjectManager.MakeStep") == id)
|
|
|
|
|
id = QLatin1String("GenericProjectManager.GenericMakeStep");
|
|
|
|
|
if (QLatin1String("projectexplorer.processstep") == id)
|
|
|
|
|
id = QLatin1String("ProjectExplorer.ProcessStep");
|
|
|
|
|
if (QLatin1String("trolltech.qt4projectmanager.make") == id)
|
|
|
|
|
id = QLatin1String("Qt4ProjectManager.MakeStep");
|
|
|
|
|
if (QLatin1String("trolltech.qt4projectmanager.qmake") == id)
|
|
|
|
|
id = QLatin1String("QtProjectManager.QMakeBuildStep");
|
|
|
|
|
// No need to change the CMake MakeStep.
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
|
|
|
|
|
|
|
|
|
|
for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
|
|
|
|
|
if (i.key() == QLatin1String("Id"))
|
|
|
|
|
continue;
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName")) {
|
|
|
|
|
// skip this: Not needed.
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (QLatin1String("GenericProjectManager.GenericMakeStep") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("buildTargets"))
|
|
|
|
|
result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.BuildTargets"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("makeArguments"))
|
|
|
|
|
result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.MakeArguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("makeCommand"))
|
|
|
|
|
result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.MakeCommand"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown GenericMakeStep value found:" << i.key() << i.value();
|
|
|
|
|
continue;
|
|
|
|
|
} else if (QLatin1String("ProjectExplorer.ProcessStep") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.ProcessStep.DisplayName"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("abstractProcess.command"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProcessStep.Command"), i.value());
|
|
|
|
|
else if ((i.key() == QLatin1String("abstractProcess.workingDirectory") ||
|
|
|
|
|
i.key() == QLatin1String("workingDirectory")) &&
|
|
|
|
|
!i.value().toString().isEmpty())
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProcessStep.WorkingDirectory"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("abstractProcess.arguments"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProcessStep.Arguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("abstractProcess.enabled"))
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.ProcessStep.Enabled"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown ProcessStep value found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("Qt4ProjectManager.MakeStep") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("makeargs"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MakeStep.MakeArguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("makeCmd"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MakeStep.MakeCommand"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("clean"))
|
|
|
|
|
result.insert(QLatin1String("Qt4ProjectManager.MakeStep.Clean"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown Qt4MakeStep value found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("QtProjectManager.QMakeBuildStep") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("qmakeArgs"))
|
|
|
|
|
result.insert(QLatin1String("QtProjectManager.QMakeBuildStep.QMakeArguments"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown Qt4QMakeStep value found:" << i.key() << i.value();
|
|
|
|
|
} else if (QLatin1String("CMakeProjectManager.MakeStep") == id) {
|
|
|
|
|
if (i.key() == QLatin1String("buildTargets"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.MakeStep.BuildTargets"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("additionalArguments"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.MakeStep.AdditionalArguments"), i.value());
|
|
|
|
|
else if (i.key() == QLatin1String("clean"))
|
|
|
|
|
result.insert(QLatin1String("CMakeProjectManager.MakeStep.Clean"), i.value());
|
|
|
|
|
else
|
|
|
|
|
qWarning() << "Unknown CMakeMakeStep value found:" << i.key() << i.value();
|
|
|
|
|
} else {
|
|
|
|
|
result.insert(i.key(), i.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap Version0Handler::update(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
|
|
|
|
|
// "project": section is unused, just ignore it.
|
|
|
|
|
|
|
|
|
|
// "buildconfigurations" and "buildConfiguration-":
|
|
|
|
|
QStringList bcs(map.value(QLatin1String("buildconfigurations")).toStringList());
|
|
|
|
|
QString active(map.value(QLatin1String("activebuildconfiguration")).toString());
|
|
|
|
|
|
|
|
|
|
int count(0);
|
|
|
|
|
foreach (const QString &bc, bcs) {
|
|
|
|
|
// convert buildconfiguration:
|
|
|
|
|
QString oldBcKey(QString::fromLatin1("buildConfiguration-") + bc);
|
|
|
|
|
if (bc == active)
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.ActiveBuildConfiguration"), count);
|
|
|
|
|
|
|
|
|
|
QVariantMap tmp(map.value(oldBcKey).toMap());
|
|
|
|
|
QVariantMap bcMap(convertBuildConfigurations(project, tmp));
|
|
|
|
|
if (bcMap.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// buildsteps
|
|
|
|
|
QStringList buildSteps(map.value(oldBcKey + QLatin1String("-buildsteps")).toStringList());
|
2010-02-01 16:13:40 +01:00
|
|
|
|
|
|
|
|
if (buildSteps.isEmpty())
|
|
|
|
|
// try lowercase version, too:-(
|
|
|
|
|
buildSteps = map.value(QString::fromLatin1("buildconfiguration-") + bc + QLatin1String("-buildsteps")).toStringList();
|
2010-01-19 16:59:18 +01:00
|
|
|
if (buildSteps.isEmpty())
|
2010-02-01 16:13:40 +01:00
|
|
|
buildSteps = map.value(QLatin1String("buildsteps")).toStringList();
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
int pos(0);
|
|
|
|
|
foreach (const QString &bs, buildSteps) {
|
|
|
|
|
// Watch out: Capitalization differs from oldBcKey!
|
|
|
|
|
const QString localKey(QLatin1String("buildconfiguration-") + bc + QString::fromLatin1("-buildstep") + QString::number(pos));
|
|
|
|
|
const QString globalKey(QString::fromLatin1("buildstep") + QString::number(pos));
|
|
|
|
|
|
|
|
|
|
QVariantMap local(map.value(localKey).toMap());
|
|
|
|
|
QVariantMap global(map.value(globalKey).toMap());
|
|
|
|
|
|
|
|
|
|
for (QVariantMap::const_iterator i = global.constBegin(); i != global.constEnd(); ++i) {
|
|
|
|
|
if (!local.contains(i.key()))
|
|
|
|
|
local.insert(i.key(), i.value());
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName") &&
|
|
|
|
|
local.value(i.key()).toString().isEmpty())
|
|
|
|
|
local.insert(i.key(), i.value());
|
|
|
|
|
}
|
|
|
|
|
local.insert(QLatin1String("Id"), bs);
|
|
|
|
|
|
|
|
|
|
bcMap.insert(QString::fromLatin1("ProjectExplorer.BuildConfiguration.BuildStep.") + QString::number(pos),
|
|
|
|
|
convertBuildSteps(project, local));
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
bcMap.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepsCount"), pos);
|
|
|
|
|
|
|
|
|
|
// cleansteps
|
|
|
|
|
QStringList cleanSteps(map.value(oldBcKey + QLatin1String("-cleansteps")).toStringList());
|
|
|
|
|
if (cleanSteps.isEmpty())
|
2010-02-01 16:13:40 +01:00
|
|
|
// try lowercase version, too:-(
|
|
|
|
|
cleanSteps = map.value(QString::fromLatin1("buildconfiguration-") + bc + QLatin1String("-cleansteps")).toStringList();
|
|
|
|
|
if (cleanSteps.isEmpty())
|
|
|
|
|
cleanSteps = map.value(QLatin1String("cleansteps")).toStringList();
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
|
foreach (const QString &bs, cleanSteps) {
|
|
|
|
|
// Watch out: Capitalization differs from oldBcKey!
|
|
|
|
|
const QString localKey(QLatin1String("buildconfiguration-") + bc + QString::fromLatin1("-cleanstep") + QString::number(pos));
|
|
|
|
|
const QString globalKey(QString::fromLatin1("cleanstep") + QString::number(pos));
|
|
|
|
|
|
|
|
|
|
QVariantMap local(map.value(localKey).toMap());
|
|
|
|
|
QVariantMap global(map.value(globalKey).toMap());
|
|
|
|
|
|
|
|
|
|
for (QVariantMap::const_iterator i = global.constBegin(); i != global.constEnd(); ++i) {
|
|
|
|
|
if (!local.contains(i.key()))
|
|
|
|
|
local.insert(i.key(), i.value());
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName") &&
|
|
|
|
|
local.value(i.key()).toString().isEmpty())
|
|
|
|
|
local.insert(i.key(), i.value());
|
|
|
|
|
}
|
|
|
|
|
local.insert(QLatin1String("Id"), bs);
|
|
|
|
|
bcMap.insert(QString::fromLatin1("ProjectExplorer.BuildConfiguration.CleanStep.") + QString::number(pos),
|
|
|
|
|
convertBuildSteps(project, local));
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
bcMap.insert(QLatin1String("ProjectExplorer.BuildConfiguration.CleanStepsCount"), pos);
|
|
|
|
|
|
|
|
|
|
// Merge into result set:
|
|
|
|
|
result.insert(QString::fromLatin1("ProjectExplorer.Project.BuildConfiguration.") + QString::number(count), bcMap);
|
|
|
|
|
++count;
|
|
|
|
|
}
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.BuildConfigurationCount"), count);
|
|
|
|
|
|
|
|
|
|
// "RunConfiguration*":
|
|
|
|
|
active = map.value(QLatin1String("activeRunConfiguration")).toString();
|
|
|
|
|
count = 0;
|
|
|
|
|
forever {
|
2012-01-09 16:30:33 +01:00
|
|
|
QString prefix(QLatin1String("RunConfiguration") + QString::number(count) + QLatin1Char('-'));
|
2010-01-19 16:59:18 +01:00
|
|
|
QVariantMap rcMap;
|
|
|
|
|
for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
|
|
|
|
|
if (!i.key().startsWith(prefix))
|
|
|
|
|
continue;
|
|
|
|
|
QString newKey(i.key().mid(prefix.size()));
|
|
|
|
|
rcMap.insert(newKey, i.value());
|
|
|
|
|
}
|
|
|
|
|
if (rcMap.isEmpty()) {
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.RunConfigurationCount"), count);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.insert(QString::fromLatin1("ProjectExplorer.Project.RunConfiguration.") + QString::number(count),
|
|
|
|
|
convertRunConfigurations(project, rcMap));
|
|
|
|
|
++count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// "defaultFileEncoding" (EditorSettings):
|
|
|
|
|
QVariant codecVariant(map.value(QLatin1String("defaultFileEncoding")));
|
|
|
|
|
if (codecVariant.isValid()) {
|
|
|
|
|
QByteArray codec(codecVariant.toByteArray());
|
|
|
|
|
QVariantMap editorSettingsMap;
|
|
|
|
|
editorSettingsMap.insert(QLatin1String("EditorConfiguration.Codec"), codec);
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.EditorSettings"),
|
|
|
|
|
editorSettingsMap);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-09 16:30:33 +01:00
|
|
|
QVariant toolchain(map.value(QLatin1String("toolChain")));
|
2010-01-19 16:59:18 +01:00
|
|
|
if (toolchain.isValid()) {
|
|
|
|
|
bool ok;
|
|
|
|
|
int type(toolchain.toInt(&ok));
|
|
|
|
|
if (!ok) {
|
|
|
|
|
QString toolChainName(toolchain.toString());
|
|
|
|
|
if (toolChainName == QLatin1String("gcc"))
|
2011-02-01 18:36:00 +01:00
|
|
|
type = 0;
|
2010-01-19 16:59:18 +01:00
|
|
|
else if (toolChainName == QLatin1String("mingw"))
|
2011-02-01 18:36:00 +01:00
|
|
|
type = 2;
|
2010-01-19 16:59:18 +01:00
|
|
|
else if (toolChainName == QLatin1String("msvc"))
|
2011-02-01 18:36:00 +01:00
|
|
|
type = 3;
|
2010-01-19 16:59:18 +01:00
|
|
|
else if (toolChainName == QLatin1String("wince"))
|
2011-02-01 18:36:00 +01:00
|
|
|
type = 4;
|
2010-01-19 16:59:18 +01:00
|
|
|
}
|
|
|
|
|
result.insert(QLatin1String("GenericProjectManager.GenericProject.Toolchain"), type);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version1Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QVariantMap Version1Handler::update(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
|
|
|
|
|
// The only difference between version 1 and 2 of the user file is that
|
|
|
|
|
// we need to add targets.
|
|
|
|
|
|
|
|
|
|
// Generate a list of all possible targets for the project:
|
|
|
|
|
QList<TargetDescription> targets;
|
2012-08-03 15:24:33 +02:00
|
|
|
if (project->id() == "GenericProjectManager.GenericProject")
|
2010-02-08 15:50:06 +01:00
|
|
|
targets << TargetDescription(QString::fromLatin1("GenericProjectManager.GenericTarget"),
|
|
|
|
|
QCoreApplication::translate("GenericProjectManager::GenericTarget",
|
|
|
|
|
"Desktop",
|
|
|
|
|
"Generic desktop target display name"));
|
2012-08-03 15:24:33 +02:00
|
|
|
else if (project->id() == "CMakeProjectManager.CMakeProject")
|
2010-02-08 15:50:06 +01:00
|
|
|
targets << TargetDescription(QString::fromLatin1("CMakeProjectManager.DefaultCMakeTarget"),
|
|
|
|
|
QCoreApplication::translate("CMakeProjectManager::Internal::CMakeTarget",
|
|
|
|
|
"Desktop",
|
|
|
|
|
"CMake Default target display name"));
|
2012-08-03 15:24:33 +02:00
|
|
|
else if (project->id() == "Qt4ProjectManager.Qt4Project")
|
2010-02-08 15:50:06 +01:00
|
|
|
targets << TargetDescription(QString::fromLatin1("Qt4ProjectManager.Target.DesktopTarget"),
|
|
|
|
|
QCoreApplication::translate("Qt4ProjectManager::Internal::Qt4Target",
|
|
|
|
|
"Desktop",
|
|
|
|
|
"Qt4 Desktop target display name"))
|
|
|
|
|
<< TargetDescription(QString::fromLatin1("Qt4ProjectManager.Target.MaemoEmulatorTarget"),
|
|
|
|
|
QCoreApplication::translate("Qt4ProjectManager::Internal::Qt4Target",
|
|
|
|
|
"Maemo Emulator",
|
|
|
|
|
"Qt4 Maemo Emulator target display name"))
|
|
|
|
|
<< TargetDescription(QString::fromLatin1("Qt4ProjectManager.Target.MaemoDeviceTarget"),
|
|
|
|
|
QCoreApplication::translate("Qt4ProjectManager::Internal::Qt4Target",
|
|
|
|
|
"Maemo Device",
|
|
|
|
|
"Qt4 Maemo Device target display name"));
|
2012-08-03 15:24:33 +02:00
|
|
|
else if (project->id() == "QmlProjectManager.QmlProject")
|
2010-02-08 15:50:06 +01:00
|
|
|
targets << TargetDescription(QString::fromLatin1("QmlProjectManager.QmlTarget"),
|
|
|
|
|
QCoreApplication::translate("QmlProjectManager::QmlTarget",
|
2010-05-20 11:59:42 +02:00
|
|
|
"QML Viewer",
|
|
|
|
|
"QML Viewer target display name"));
|
2010-02-08 15:50:06 +01:00
|
|
|
else
|
|
|
|
|
return QVariantMap(); // We do not know how to handle this.
|
|
|
|
|
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.ActiveTarget"), 0);
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.TargetCount"), targets.count());
|
|
|
|
|
int pos(0);
|
|
|
|
|
foreach (const TargetDescription &td, targets) {
|
|
|
|
|
QVariantMap targetMap;
|
|
|
|
|
// Do not set displayName or icon!
|
|
|
|
|
targetMap.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), td.id);
|
|
|
|
|
|
|
|
|
|
int count = map.value(QLatin1String("ProjectExplorer.Project.BuildConfigurationCount")).toInt();
|
|
|
|
|
targetMap.insert(QLatin1String("ProjectExplorer.Target.BuildConfigurationCount"), count);
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
QString key(QString::fromLatin1("ProjectExplorer.Project.BuildConfiguration.") + QString::number(i));
|
2010-09-02 10:01:32 +02:00
|
|
|
if (map.contains(key)) {
|
|
|
|
|
QVariantMap bcMap = map.value(key).toMap();
|
|
|
|
|
if (!bcMap.contains(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild")))
|
|
|
|
|
bcMap.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"), false);
|
2010-02-08 15:50:06 +01:00
|
|
|
targetMap.insert(QString::fromLatin1("ProjectExplorer.Target.BuildConfiguration.") + QString::number(i),
|
2010-09-02 10:01:32 +02:00
|
|
|
bcMap);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
count = map.value(QLatin1String("ProjectExplorer.Project.RunConfigurationCount")).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
QString key(QString::fromLatin1("ProjectExplorer.Project.RunConfiguration.") + QString::number(i));
|
|
|
|
|
if (map.contains(key))
|
|
|
|
|
targetMap.insert(QString::fromLatin1("ProjectExplorer.Target.RunConfiguration.") + QString::number(i),
|
|
|
|
|
map.value(key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (map.contains(QLatin1String("ProjectExplorer.Project.ActiveBuildConfiguration")))
|
|
|
|
|
targetMap.insert(QLatin1String("ProjectExplorer.Target.ActiveBuildConfiguration"),
|
|
|
|
|
map.value(QLatin1String("ProjectExplorer.Project.ActiveBuildConfiguration")));
|
|
|
|
|
if (map.contains(QLatin1String("ProjectExplorer.Project.ActiveRunConfiguration")))
|
|
|
|
|
targetMap.insert(QLatin1String("ProjectExplorer.Target.ActiveRunConfiguration"),
|
|
|
|
|
map.value(QLatin1String("ProjectExplorer.Project.ActiveRunConfiguration")));
|
|
|
|
|
if (map.contains(QLatin1String("ProjectExplorer.Project.RunConfigurationCount")))
|
|
|
|
|
targetMap.insert(QLatin1String("ProjectExplorer.Target.RunConfigurationCount"),
|
|
|
|
|
map.value(QLatin1String("ProjectExplorer.Project.RunConfigurationCount")));
|
|
|
|
|
|
|
|
|
|
result.insert(QString::fromLatin1("ProjectExplorer.Project.Target.") + QString::number(pos), targetMap);
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// copy everything else:
|
|
|
|
|
for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
|
|
|
|
|
if (i.key() == QLatin1String("ProjectExplorer.Project.ActiveBuildConfiguration") ||
|
|
|
|
|
i.key() == QLatin1String("ProjectExplorer.Project.BuildConfigurationCount") ||
|
|
|
|
|
i.key() == QLatin1String("ProjectExplorer.Project.ActiveRunConfiguration") ||
|
|
|
|
|
i.key() == QLatin1String("ProjectExplorer.Project.RunConfigurationCount") ||
|
|
|
|
|
i.key().startsWith(QLatin1String("ProjectExplorer.Project.BuildConfiguration.")) ||
|
|
|
|
|
i.key().startsWith(QLatin1String("ProjectExplorer.Project.RunConfiguration.")))
|
|
|
|
|
continue;
|
|
|
|
|
result.insert(i.key(), i.value());
|
|
|
|
|
}
|
2010-01-19 16:59:18 +01:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-03-11 17:47:09 +01:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version2Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QVariantMap Version2Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QList<Change> changes;
|
|
|
|
|
changes.append(qMakePair(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges"),
|
|
|
|
|
QLatin1String("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges")));
|
|
|
|
|
changes.append(qMakePair(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.ClearSystemEnvironment"),
|
|
|
|
|
QLatin1String("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment")));
|
|
|
|
|
changes.append(qMakePair(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges"),
|
|
|
|
|
QLatin1String("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges")));
|
|
|
|
|
changes.append(qMakePair(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment"),
|
|
|
|
|
QLatin1String("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment")));
|
|
|
|
|
|
|
|
|
|
return renameKeys(changes, QVariantMap(map));
|
|
|
|
|
}
|
2010-03-24 13:33:54 +01:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version3Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// insert the additional build step:
|
|
|
|
|
//<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.2" type="QVariantMap">
|
|
|
|
|
// <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Create sis Package</value>
|
|
|
|
|
// <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.S60SignBuildStep</value>
|
|
|
|
|
// <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
|
|
|
|
// <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
|
|
|
|
|
// <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60CreatePackageStep.Certificate" type="QString"></value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60CreatePackageStep.Keyfile" type="QString"></value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60CreatePackageStep.SignMode" type="int">0</value>
|
|
|
|
|
//</valuemap>
|
|
|
|
|
|
|
|
|
|
// remove the deprecated sign run settings from
|
|
|
|
|
//<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
|
|
|
|
|
// <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">untitled1 on Symbian Device</value>
|
|
|
|
|
// <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.S60DeviceRunConfiguration</value>
|
|
|
|
|
// <valuelist key="Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments" type="QVariantList"/>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60DeviceRunConfiguration.CustomKeyPath" type="QString"></value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60DeviceRunConfiguration.CustomSignaturePath" type="QString"></value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60DeviceRunConfiguration.ProFile" type="QString">untitled1.pro</value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60DeviceRunConfiguration.SerialPortName" type="QString">COM3</value>
|
|
|
|
|
// <value key="Qt4ProjectManager.S60DeviceRunConfiguration.SigningMode" type="int">0</value>
|
|
|
|
|
//</valuemap>
|
|
|
|
|
|
|
|
|
|
QVariantMap Version3Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &targetKey = it.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(targetKey, it.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const QVariantMap &originalTarget = it.value().toMap();
|
2012-08-22 13:27:25 +02:00
|
|
|
result.insert(targetKey, originalTarget);
|
2010-03-24 13:33:54 +01:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-07-06 17:56:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version4Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Move packaging steps from build steps into deploy steps
|
|
|
|
|
QVariantMap Version4Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &globalKey = it.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, it.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const QVariantMap &originalTarget = it.value().toMap();
|
2012-08-22 13:27:25 +02:00
|
|
|
// check for maemo device target
|
2010-07-06 17:56:01 +02:00
|
|
|
if (originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
|
|
|
|
|
!= QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget"))
|
|
|
|
|
{
|
|
|
|
|
result.insert(globalKey, originalTarget);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap newTarget;
|
|
|
|
|
QMapIterator<QString, QVariant> targetIt(originalTarget);
|
|
|
|
|
while (targetIt.hasNext()) {
|
|
|
|
|
targetIt.next();
|
|
|
|
|
const QString &targetKey = targetIt.key();
|
2010-09-29 10:10:25 +02:00
|
|
|
|
|
|
|
|
if (targetKey.startsWith(QLatin1String("ProjectExplorer.Target.RunConfiguration."))) {
|
|
|
|
|
const QVariantMap &runConfigMap = targetIt.value().toMap();
|
|
|
|
|
const QLatin1String maemoRcId("Qt4ProjectManager.MaemoRunConfiguration");
|
|
|
|
|
if (runConfigMap.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString()
|
|
|
|
|
== maemoRcId) {
|
|
|
|
|
QVariantMap newRunConfigMap;
|
|
|
|
|
for (QVariantMap::ConstIterator rcMapIt = runConfigMap.constBegin();
|
|
|
|
|
rcMapIt != runConfigMap.constEnd(); ++rcMapIt) {
|
|
|
|
|
const QLatin1String oldProFileKey(".ProFile");
|
|
|
|
|
if (rcMapIt.key() == oldProFileKey) {
|
|
|
|
|
newRunConfigMap.insert(maemoRcId + oldProFileKey,
|
|
|
|
|
rcMapIt.value());
|
|
|
|
|
} else {
|
|
|
|
|
newRunConfigMap.insert(rcMapIt.key(),
|
|
|
|
|
rcMapIt.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newTarget.insert(targetKey, newRunConfigMap);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-06 17:56:01 +02:00
|
|
|
if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration."))) {
|
|
|
|
|
newTarget.insert(targetKey, targetIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool movedBs = false;
|
|
|
|
|
const QVariantMap &originalBc = targetIt.value().toMap();
|
|
|
|
|
QVariantMap newBc;
|
|
|
|
|
QMapIterator<QString, QVariant> bcIt(originalBc);
|
|
|
|
|
while(bcIt.hasNext()) {
|
|
|
|
|
bcIt.next();
|
|
|
|
|
const QString &bcKey = bcIt.key();
|
|
|
|
|
if (!bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStep."))) {
|
|
|
|
|
newBc.insert(bcKey, bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVariantMap &buildStep = bcIt.value().toMap();
|
|
|
|
|
if ((buildStep.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString() ==
|
|
|
|
|
QLatin1String("Qt4ProjectManager.S60SignBuildStep"))
|
|
|
|
|
|| (buildStep.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString() ==
|
|
|
|
|
QLatin1String("Qt4ProjectManager.MaemoPackageCreationStep"))) {
|
|
|
|
|
movedBs = true;
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStep.0"), buildStep);
|
|
|
|
|
} else {
|
|
|
|
|
newBc.insert(bcKey, buildStep);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (movedBs) {
|
|
|
|
|
// adjust counts:
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"), 1);
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepsCount"),
|
|
|
|
|
newBc.value(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepsCount")).toInt() - 1);
|
|
|
|
|
}
|
|
|
|
|
newTarget.insert(targetKey, newBc);
|
|
|
|
|
}
|
|
|
|
|
result.insert(globalKey, newTarget);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-07-15 13:58:18 +02:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version5Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Move packaging steps from build steps into deploy steps
|
|
|
|
|
QVariantMap Version5Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &globalKey = it.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, it.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const QVariantMap &originalTarget = it.value().toMap();
|
2012-08-22 13:27:25 +02:00
|
|
|
// check for maemo device target
|
2010-07-15 13:58:18 +02:00
|
|
|
if (originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
|
|
|
|
|
!= QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) {
|
|
|
|
|
result.insert(globalKey, originalTarget);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap newTarget;
|
|
|
|
|
QMapIterator<QString, QVariant> targetIt(originalTarget);
|
|
|
|
|
while (targetIt.hasNext()) {
|
|
|
|
|
targetIt.next();
|
|
|
|
|
const QString &targetKey = targetIt.key();
|
|
|
|
|
if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration."))) {
|
|
|
|
|
newTarget.insert(targetKey, targetIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVariantMap &originalBc = targetIt.value().toMap();
|
|
|
|
|
QVariantMap newBc = originalBc;
|
|
|
|
|
QVariantMap newDeployStep;
|
|
|
|
|
|
|
|
|
|
if (originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
|
|
|
|
|
== QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")) {
|
|
|
|
|
newDeployStep.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"),
|
|
|
|
|
QLatin1String("Qt4ProjectManager.S60DeployStep"));
|
|
|
|
|
} else {
|
|
|
|
|
newDeployStep.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"),
|
|
|
|
|
QLatin1String("Qt4ProjectManager.MaemoDeployStep"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int deployCount = newBc.value(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"), 0).toInt();
|
|
|
|
|
newBc.insert(QString::fromLatin1("ProjectExplorer.BuildConfiguration.DeployStep.") + QString::number(deployCount),
|
|
|
|
|
newDeployStep);
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"), deployCount + 1);
|
|
|
|
|
|
|
|
|
|
newTarget.insert(targetKey, newBc);
|
|
|
|
|
}
|
|
|
|
|
result.insert(globalKey, newTarget);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version6Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Introduce DeployConfiguration and BuildStepLists
|
|
|
|
|
QVariantMap Version6Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &globalKey = it.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, it.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap newDc;
|
|
|
|
|
const QVariantMap &originalTarget = it.value().toMap();
|
|
|
|
|
QVariantMap newTarget;
|
|
|
|
|
QVariantMap deploySteps;
|
|
|
|
|
QString deploymentName = QCoreApplication::translate("ProjectExplorer::UserFileHandler", "No deployment");
|
|
|
|
|
|
|
|
|
|
QMapIterator<QString, QVariant> targetIt(originalTarget);
|
|
|
|
|
while (targetIt.hasNext()) {
|
|
|
|
|
targetIt.next();
|
|
|
|
|
const QString &targetKey = targetIt.key();
|
|
|
|
|
|
|
|
|
|
if (targetKey == QLatin1String("ProjectExplorer.ProjectConfiguration.Id")) {
|
|
|
|
|
if (targetIt.value().toString() == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget"))
|
|
|
|
|
deploymentName = QCoreApplication::translate("ProjectExplorer::UserFileHandler", "Deploy to Maemo device");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration."))) {
|
|
|
|
|
newTarget.insert(targetKey, targetIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap buildSteps;
|
|
|
|
|
QVariantMap cleanSteps;
|
2010-08-02 14:30:17 +02:00
|
|
|
const QVariantMap &originalBc = targetIt.value().toMap();
|
2010-07-16 14:00:41 +02:00
|
|
|
QVariantMap newBc;
|
|
|
|
|
|
|
|
|
|
QMapIterator<QString, QVariant> bcIt(originalBc);
|
|
|
|
|
while (bcIt.hasNext())
|
|
|
|
|
{
|
|
|
|
|
bcIt.next();
|
|
|
|
|
const QString &bcKey = bcIt.key();
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStep."))) {
|
|
|
|
|
QString position = bcKey.mid(45);
|
|
|
|
|
buildSteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepsCount"))) {
|
|
|
|
|
buildSteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.CleanStep."))) {
|
|
|
|
|
QString position = bcKey.mid(45);
|
|
|
|
|
cleanSteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.CleanStepsCount"))) {
|
|
|
|
|
cleanSteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStep."))) {
|
|
|
|
|
QString position = bcKey.mid(46);
|
|
|
|
|
deploySteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"))) {
|
|
|
|
|
deploySteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
newBc.insert(bcKey, bcIt.value());
|
|
|
|
|
}
|
|
|
|
|
buildSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Build"));
|
|
|
|
|
buildSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Build"));
|
|
|
|
|
cleanSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Clean"));
|
|
|
|
|
cleanSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Clean"));
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.0"), buildSteps);
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.1"), cleanSteps);
|
|
|
|
|
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepListCount"), 2);
|
|
|
|
|
newTarget.insert(targetKey, newBc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only insert one deploy configuration:
|
|
|
|
|
deploySteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Deploy"));
|
|
|
|
|
deploySteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Deploy"));
|
|
|
|
|
newDc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.0"), deploySteps);
|
|
|
|
|
newDc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepListCount"), 1);
|
|
|
|
|
newDc.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), deploymentName);
|
|
|
|
|
newDc.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.DefaultDeployConfiguration"));
|
|
|
|
|
|
|
|
|
|
newTarget.insert(QLatin1String("ProjectExplorer.Target.DeployConfigurationCount"), 1);
|
|
|
|
|
newTarget.insert(QLatin1String("ProjectExplorer.Target.ActiveDeployConfiguration"), 0);
|
|
|
|
|
newTarget.insert(QLatin1String("ProjectExplorer.Target.DeployConfiguration.0"), newDc);
|
|
|
|
|
result.insert(globalKey, newTarget);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-08-10 12:31:55 +02:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version7Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// new implementation of DeployConfiguration
|
|
|
|
|
QVariantMap Version7Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> it(map);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
const QString &globalKey = it.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, it.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const QVariantMap &originalTarget = it.value().toMap();
|
2012-08-22 13:27:25 +02:00
|
|
|
result.insert(globalKey, originalTarget);
|
2010-08-10 12:31:55 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-10-19 17:51:52 +02:00
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Version8Handler
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Argument list reinterpretation
|
|
|
|
|
|
|
|
|
|
static const char * const argListKeys[] = {
|
|
|
|
|
"ProjectExplorer.Project.Target.",
|
|
|
|
|
"ProjectExplorer.Target.BuildConfiguration."
|
|
|
|
|
"|ProjectExplorer.Target.DeployConfiguration.",
|
|
|
|
|
"ProjectExplorer.BuildConfiguration.BuildStepList.",
|
|
|
|
|
"ProjectExplorer.BuildStepList.Step.",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.MakeArguments",
|
|
|
|
|
"QtProjectManager.QMakeBuildStep.QMakeArguments",
|
|
|
|
|
"Qt4ProjectManager.MakeStep.MakeArguments",
|
|
|
|
|
"CMakeProjectManager.MakeStep.AdditionalArguments",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"ProjectExplorer.Target.RunConfiguration.",
|
|
|
|
|
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments",
|
|
|
|
|
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments",
|
|
|
|
|
"CMakeProjectManager.CMakeRunConfiguration.Arguments",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char * const lameArgListKeys[] = {
|
|
|
|
|
"ProjectExplorer.Project.Target.",
|
|
|
|
|
"ProjectExplorer.Target.BuildConfiguration."
|
|
|
|
|
"|ProjectExplorer.Target.DeployConfiguration.",
|
|
|
|
|
"ProjectExplorer.BuildConfiguration.BuildStepList.",
|
|
|
|
|
"ProjectExplorer.BuildStepList.Step.",
|
|
|
|
|
"ProjectExplorer.ProcessStep.Arguments",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"ProjectExplorer.Target.RunConfiguration.",
|
|
|
|
|
"Qt4ProjectManager.MaemoRunConfiguration.Arguments",
|
|
|
|
|
"Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments",
|
|
|
|
|
"QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
|
inline static bool isSpecialChar(ushort c)
|
|
|
|
|
{
|
|
|
|
|
// Chars that should be quoted (TM). This includes:
|
|
|
|
|
static const uchar iqm[] = {
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
|
|
|
|
|
0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
|
|
|
|
|
}; // 0-32 \'"$`<>|;&(){}*?#!~[]
|
|
|
|
|
|
|
|
|
|
return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static bool hasSpecialChars(const QString &arg)
|
|
|
|
|
{
|
|
|
|
|
for (int x = arg.length() - 1; x >= 0; --x)
|
|
|
|
|
if (isSpecialChar(arg.unicode()[x].unicode()))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// These were split according to sane (even if a bit arcane) rules
|
|
|
|
|
static QVariant version8ArgNodeHandler(const QVariant &var)
|
|
|
|
|
{
|
|
|
|
|
QString ret;
|
|
|
|
|
foreach (const QVariant &svar, var.toList()) {
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
|
// We don't just addArg, so we don't disarm existing env expansions.
|
|
|
|
|
// This is a bit fuzzy logic ...
|
|
|
|
|
QString s = svar.toString();
|
|
|
|
|
s.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
|
|
|
|
|
s.replace(QLatin1Char('"'), QLatin1String("\\\""));
|
|
|
|
|
s.replace(QLatin1Char('`'), QLatin1String("\\`"));
|
|
|
|
|
if (s != svar.toString() || hasSpecialChars(s))
|
|
|
|
|
s.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
|
|
|
|
|
Utils::QtcProcess::addArgs(&ret, s);
|
|
|
|
|
#else
|
|
|
|
|
// Under windows, env expansions cannot be quoted anyway.
|
|
|
|
|
Utils::QtcProcess::addArg(&ret, svar.toString());
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return QVariant(ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// These were just split on whitespace
|
|
|
|
|
static QVariant version8LameArgNodeHandler(const QVariant &var)
|
|
|
|
|
{
|
|
|
|
|
QString ret;
|
|
|
|
|
foreach (const QVariant &svar, var.toList())
|
|
|
|
|
Utils::QtcProcess::addArgs(&ret, svar.toString());
|
|
|
|
|
return QVariant(ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Environment variable reinterpretation
|
|
|
|
|
|
|
|
|
|
static const char * const envExpandedKeys[] = {
|
|
|
|
|
"ProjectExplorer.Project.Target.",
|
|
|
|
|
"ProjectExplorer.Target.BuildConfiguration."
|
|
|
|
|
"|ProjectExplorer.Target.DeployConfiguration.",
|
|
|
|
|
"ProjectExplorer.BuildConfiguration.BuildStepList.",
|
|
|
|
|
"ProjectExplorer.BuildStepList.Step.",
|
|
|
|
|
"ProjectExplorer.ProcessStep.WorkingDirectory",
|
|
|
|
|
"ProjectExplorer.ProcessStep.Command",
|
|
|
|
|
"ProjectExplorer.ProcessStep.Arguments",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.MakeCommand",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.MakeArguments",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.BuildTargets",
|
|
|
|
|
"QtProjectManager.QMakeBuildStep.QMakeArguments",
|
|
|
|
|
"Qt4ProjectManager.MakeStep.MakeCommand",
|
|
|
|
|
"Qt4ProjectManager.MakeStep.MakeArguments",
|
|
|
|
|
"CMakeProjectManager.MakeStep.AdditionalArguments",
|
|
|
|
|
"CMakeProjectManager.MakeStep.BuildTargets",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory",
|
|
|
|
|
0,
|
|
|
|
|
"ProjectExplorer.Target.RunConfiguration.",
|
|
|
|
|
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory",
|
|
|
|
|
"ProjectExplorer.CustomExecutableRunConfiguration.Executable",
|
|
|
|
|
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments",
|
|
|
|
|
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory",
|
|
|
|
|
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments",
|
|
|
|
|
"Qt4ProjectManager.MaemoRunConfiguration.Arguments",
|
|
|
|
|
"Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments",
|
|
|
|
|
"CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory",
|
|
|
|
|
"CMakeProjectManager.CMakeRunConfiguration.Arguments",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static QString version8NewVar(const QString &old)
|
|
|
|
|
{
|
|
|
|
|
QString ret = old;
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
|
ret.prepend(QLatin1String("${"));
|
|
|
|
|
ret.append(QLatin1Char('}'));
|
|
|
|
|
#else
|
|
|
|
|
ret.prepend(QLatin1Char('%'));
|
|
|
|
|
ret.append(QLatin1Char('%'));
|
|
|
|
|
#endif
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Translate DOS-like env var expansions into Unix-like ones and vice versa.
|
|
|
|
|
// On the way, change {SOURCE,BUILD}DIR env expansions to %{}-expandos
|
|
|
|
|
static QVariant version8EnvNodeTransform(const QVariant &var)
|
|
|
|
|
{
|
|
|
|
|
QString result = var.toString();
|
|
|
|
|
|
2010-12-06 13:49:41 +01:00
|
|
|
result.replace(QRegExp(QLatin1String("%SOURCEDIR%|\\$(SOURCEDIR\\b|\\{SOURCEDIR\\})")),
|
2010-10-19 17:51:52 +02:00
|
|
|
QLatin1String("%{sourceDir}"));
|
2010-12-06 13:49:41 +01:00
|
|
|
result.replace(QRegExp(QLatin1String("%BUILDDIR%|\\$(BUILDDIR\\b|\\{BUILDDIR\\})")),
|
2010-10-19 17:51:52 +02:00
|
|
|
QLatin1String("%{buildDir}"));
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
|
for (int vStart = -1, i = 0; i < result.length(); ) {
|
|
|
|
|
QChar c = result.at(i++);
|
|
|
|
|
if (c == QLatin1Char('%')) {
|
|
|
|
|
if (vStart > 0 && vStart < i - 1) {
|
|
|
|
|
QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
|
|
|
|
|
result.replace(vStart - 1, i - vStart + 1, nv);
|
|
|
|
|
i = vStart - 1 + nv.length();
|
|
|
|
|
vStart = -1;
|
|
|
|
|
} else {
|
|
|
|
|
vStart = i;
|
|
|
|
|
}
|
|
|
|
|
} else if (vStart > 0) {
|
|
|
|
|
// Sanity check so we don't catch too much garbage
|
|
|
|
|
if (!c.isLetterOrNumber() && c != QLatin1Char('_'))
|
|
|
|
|
vStart = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
enum { BASE, OPTIONALVARIABLEBRACE, VARIABLE, BRACEDVARIABLE } state = BASE;
|
|
|
|
|
int vStart = -1;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < result.length();) {
|
|
|
|
|
QChar c = result.at(i++);
|
|
|
|
|
if (state == BASE) {
|
|
|
|
|
if (c == QLatin1Char('$'))
|
|
|
|
|
state = OPTIONALVARIABLEBRACE;
|
|
|
|
|
} else if (state == OPTIONALVARIABLEBRACE) {
|
|
|
|
|
if (c == QLatin1Char('{')) {
|
|
|
|
|
state = BRACEDVARIABLE;
|
|
|
|
|
vStart = i;
|
|
|
|
|
} else if (c.isLetterOrNumber() || c == QLatin1Char('_')) {
|
|
|
|
|
state = VARIABLE;
|
|
|
|
|
vStart = i - 1;
|
|
|
|
|
} else {
|
|
|
|
|
state = BASE;
|
|
|
|
|
}
|
|
|
|
|
} else if (state == BRACEDVARIABLE) {
|
|
|
|
|
if (c == QLatin1Char('}')) {
|
|
|
|
|
QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
|
|
|
|
|
result.replace(vStart - 2, i - vStart + 2, nv);
|
|
|
|
|
i = vStart + nv.length();
|
|
|
|
|
state = BASE;
|
|
|
|
|
}
|
|
|
|
|
} else if (state == VARIABLE) {
|
|
|
|
|
if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
|
|
|
|
|
QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
|
|
|
|
|
result.replace(vStart - 1, i - vStart, nv);
|
|
|
|
|
i = vStart - 1 + nv.length(); // On the same char - could be next expansion.
|
|
|
|
|
state = BASE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (state == VARIABLE) {
|
|
|
|
|
QString nv = version8NewVar(result.mid(vStart));
|
|
|
|
|
result.truncate(vStart - 1);
|
|
|
|
|
result += nv;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return QVariant(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QVariant version8EnvNodeHandler(const QVariant &var)
|
|
|
|
|
{
|
|
|
|
|
if (var.type() != QVariant::List)
|
|
|
|
|
return version8EnvNodeTransform(var);
|
|
|
|
|
|
|
|
|
|
QVariantList vl;
|
|
|
|
|
foreach (const QVariant &svar, var.toList())
|
|
|
|
|
vl << version8EnvNodeTransform(svar);
|
|
|
|
|
return vl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VariableManager expando reinterpretation
|
|
|
|
|
|
|
|
|
|
static const char * const varExpandedKeys[] = {
|
|
|
|
|
"ProjectExplorer.Project.Target.",
|
|
|
|
|
"ProjectExplorer.Target.BuildConfiguration."
|
|
|
|
|
"|ProjectExplorer.Target.DeployConfiguration.",
|
|
|
|
|
"ProjectExplorer.BuildConfiguration.BuildStepList.",
|
|
|
|
|
"ProjectExplorer.BuildStepList.Step.",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.MakeCommand",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.MakeArguments",
|
|
|
|
|
"GenericProjectManager.GenericMakeStep.BuildTargets",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Translate old-style ${} var expansions into new-style %{} ones
|
2011-01-11 19:30:53 +01:00
|
|
|
static QVariant version8VarNodeTransform(const QVariant &var)
|
2010-10-19 17:51:52 +02:00
|
|
|
{
|
|
|
|
|
static const char * const vars[] = {
|
|
|
|
|
"absoluteFilePath",
|
|
|
|
|
"absolutePath",
|
|
|
|
|
"baseName",
|
|
|
|
|
"canonicalPath",
|
|
|
|
|
"canonicalFilePath",
|
|
|
|
|
"completeBaseName",
|
|
|
|
|
"completeSuffix",
|
|
|
|
|
"fileName",
|
|
|
|
|
"filePath",
|
|
|
|
|
"path",
|
|
|
|
|
"suffix"
|
|
|
|
|
};
|
|
|
|
|
static QSet<QString> map;
|
|
|
|
|
if (map.isEmpty())
|
2011-05-10 15:19:38 +02:00
|
|
|
for (unsigned i = 0; i < sizeof(vars)/sizeof(vars[0]); ++i)
|
2010-10-19 17:51:52 +02:00
|
|
|
map.insert(QLatin1String("CURRENT_DOCUMENT:") + QLatin1String(vars[i]));
|
|
|
|
|
|
|
|
|
|
QString str = var.toString();
|
|
|
|
|
int pos = 0;
|
|
|
|
|
forever {
|
|
|
|
|
int openPos = str.indexOf(QLatin1String("${"), pos);
|
|
|
|
|
if (openPos < 0)
|
|
|
|
|
break;
|
|
|
|
|
int varPos = openPos + 2;
|
|
|
|
|
int closePos = str.indexOf(QLatin1Char('}'), varPos);
|
|
|
|
|
if (closePos < 0)
|
|
|
|
|
break;
|
|
|
|
|
if (map.contains(str.mid(varPos, closePos - varPos)))
|
|
|
|
|
str[openPos] = QLatin1Char('%');
|
|
|
|
|
pos = closePos + 1;
|
|
|
|
|
}
|
|
|
|
|
return QVariant(str);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-11 19:30:53 +01:00
|
|
|
static QVariant version8VarNodeHandler(const QVariant &var)
|
|
|
|
|
{
|
|
|
|
|
if (var.type() != QVariant::List)
|
|
|
|
|
return version8VarNodeTransform(var);
|
|
|
|
|
|
|
|
|
|
QVariantList vl;
|
|
|
|
|
foreach (const QVariant &svar, var.toList())
|
|
|
|
|
vl << version8VarNodeTransform(svar);
|
|
|
|
|
return vl;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 17:51:52 +02:00
|
|
|
QVariantMap Version8Handler::update(Project *, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
const char * const *p1 = argListKeys;
|
|
|
|
|
QVariantMap rmap1 = processHandlerNodes(buildHandlerNodes(&p1), map, version8ArgNodeHandler);
|
|
|
|
|
const char * const *p2 = lameArgListKeys;
|
|
|
|
|
QVariantMap rmap2 = processHandlerNodes(buildHandlerNodes(&p2), rmap1, version8LameArgNodeHandler);
|
|
|
|
|
const char * const *p3 = envExpandedKeys;
|
|
|
|
|
QVariantMap rmap3 = processHandlerNodes(buildHandlerNodes(&p3), rmap2, version8EnvNodeHandler);
|
|
|
|
|
const char * const *p4 = varExpandedKeys;
|
|
|
|
|
return processHandlerNodes(buildHandlerNodes(&p4), rmap3, version8VarNodeHandler);
|
|
|
|
|
}
|
2011-03-09 12:07:35 +01:00
|
|
|
|
|
|
|
|
QVariantMap Version9Handler::update(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(project);
|
|
|
|
|
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
QMapIterator<QString, QVariant> globalIt(map);
|
|
|
|
|
while (globalIt.hasNext()) {
|
|
|
|
|
globalIt.next();
|
|
|
|
|
const QString &globalKey = globalIt.key();
|
|
|
|
|
// check for target info
|
|
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, globalIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVariantMap &origTargetMap = globalIt.value().toMap();
|
|
|
|
|
const QString targetIdKey
|
|
|
|
|
= QLatin1String("ProjectExplorer.ProjectConfiguration.Id");
|
|
|
|
|
// check for maemo device target
|
|
|
|
|
if (origTargetMap.value(targetIdKey)
|
|
|
|
|
!= QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")
|
|
|
|
|
&& origTargetMap.value(targetIdKey)
|
|
|
|
|
!= QLatin1String("Qt4ProjectManager.Target.HarmattanDeviceTarget")
|
|
|
|
|
&& origTargetMap.value(targetIdKey)
|
|
|
|
|
!= QLatin1String("Qt4ProjectManager.Target.MeegoDeviceTarget"))
|
|
|
|
|
{
|
|
|
|
|
result.insert(globalKey, origTargetMap);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap newTargetMap;
|
|
|
|
|
QMapIterator<QString, QVariant> targetIt(origTargetMap);
|
|
|
|
|
while (targetIt.hasNext()) {
|
|
|
|
|
targetIt.next();
|
|
|
|
|
if (!targetIt.key().startsWith(QLatin1String("ProjectExplorer.Target.DeployConfiguration."))) {
|
|
|
|
|
newTargetMap.insert(targetIt.key(), targetIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap deployConfMap = targetIt.value().toMap();
|
|
|
|
|
deployConfMap.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"),
|
|
|
|
|
QLatin1String("2.2MaemoDeployConfig"));
|
|
|
|
|
newTargetMap.insert(targetIt.key(), deployConfMap);
|
|
|
|
|
}
|
|
|
|
|
result.insert(globalKey, newTargetMap);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2012-01-23 14:55:58 +01:00
|
|
|
|
|
|
|
|
QVariantMap Version10Handler::update(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(project);
|
|
|
|
|
QList<Change> changes;
|
|
|
|
|
changes.append(qMakePair(QLatin1String("ProjectExplorer.ProcessStep.Enabled"),
|
|
|
|
|
QLatin1String("ProjectExplorer.BuildStep.Enabled")));
|
|
|
|
|
return renameKeys(changes, QVariantMap(map));
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
Version11Handler::Version11Handler()
|
2012-06-20 15:51:28 +02:00
|
|
|
{ }
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
Version11Handler::~Version11Handler()
|
|
|
|
|
{
|
|
|
|
|
ProfileManager *pm = ProfileManager::instance();
|
|
|
|
|
if (!pm) // Can happen during teardown!
|
|
|
|
|
return;
|
|
|
|
|
QList<Profile *> knownProfiles = pm->profiles();
|
|
|
|
|
foreach (Profile *p, m_targets.keys()) {
|
|
|
|
|
if (!knownProfiles.contains(p))
|
|
|
|
|
delete p;
|
|
|
|
|
}
|
|
|
|
|
m_targets.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-08 11:23:45 +03:00
|
|
|
static inline int targetId(const QString &targetKey)
|
|
|
|
|
{
|
|
|
|
|
return targetKey.mid(targetKey.lastIndexOf(QLatin1Char('.')) + 1).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
|
|
|
|
|
{
|
2012-06-20 15:51:28 +02:00
|
|
|
// Read in old data to help with the transition:
|
|
|
|
|
parseQtversionFile();
|
|
|
|
|
parseToolChainFile();
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap result;
|
|
|
|
|
ProfileManager *pm = ProfileManager::instance();
|
|
|
|
|
foreach (Profile *p, pm->profiles())
|
|
|
|
|
m_targets.insert(p, QVariantMap());
|
|
|
|
|
|
|
|
|
|
QMapIterator<QString, QVariant> globalIt(map);
|
|
|
|
|
int activeTarget = map.value(QLatin1String("ProjectExplorer.Project.ActiveTarget"), 0).toInt();
|
|
|
|
|
|
|
|
|
|
while (globalIt.hasNext()) {
|
|
|
|
|
globalIt.next();
|
|
|
|
|
const QString &globalKey = globalIt.key();
|
|
|
|
|
// Keep everything but targets:
|
2012-08-07 14:01:52 +02:00
|
|
|
if (globalKey == QLatin1String("ProjectExplorer.Project.ActiveTarget"))
|
|
|
|
|
continue;
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
|
|
|
|
|
result.insert(globalKey, globalIt.value());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update Targets:
|
|
|
|
|
const QVariantMap &target = globalIt.value().toMap();
|
2012-08-08 11:23:45 +03:00
|
|
|
int targetPos = targetId(globalKey);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
QVariantMap extraTargetData;
|
2012-08-08 11:23:45 +03:00
|
|
|
QMap<int, QVariantMap> bcs;
|
2012-04-24 15:49:09 +02:00
|
|
|
int activeBc = -1;
|
2012-08-08 11:23:45 +03:00
|
|
|
QMap<int, QVariantMap> dcs;
|
2012-04-24 15:49:09 +02:00
|
|
|
int activeDc = -1;
|
2012-08-08 11:23:45 +03:00
|
|
|
QMap<int, QVariantMap> rcs;
|
2012-04-24 15:49:09 +02:00
|
|
|
int activeRc = -1;
|
|
|
|
|
|
|
|
|
|
// Read old target:
|
|
|
|
|
QMapIterator<QString, QVariant> targetIt(target);
|
|
|
|
|
while (targetIt.hasNext()) {
|
|
|
|
|
targetIt.next();
|
|
|
|
|
const QString &targetKey = targetIt.key();
|
2012-06-20 15:51:28 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// BuildConfigurations:
|
|
|
|
|
if (targetKey == QLatin1String("ProjectExplorer.Target.ActiveBuildConfiguration"))
|
|
|
|
|
activeBc = targetIt.value().toInt();
|
|
|
|
|
else if (targetKey == QLatin1String("ProjectExplorer.Target.BuildConfigurationCount"))
|
|
|
|
|
continue;
|
|
|
|
|
else if (targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration.")))
|
2012-08-08 11:23:45 +03:00
|
|
|
bcs.insert(targetId(targetKey), targetIt.value().toMap());
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
|
|
|
|
|
|
|
|
|
// DeployConfigurations:
|
|
|
|
|
if (targetKey == QLatin1String("ProjectExplorer.Target.ActiveDeployConfiguration"))
|
|
|
|
|
activeDc = targetIt.value().toInt();
|
|
|
|
|
else if (targetKey == QLatin1String("ProjectExplorer.Target.DeployConfigurationCount"))
|
|
|
|
|
continue;
|
|
|
|
|
else if (targetKey.startsWith(QLatin1String("ProjectExplorer.Target.DeployConfiguration.")))
|
2012-08-08 11:23:45 +03:00
|
|
|
dcs.insert(targetId(targetKey), targetIt.value().toMap());
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
|
|
|
|
|
|
|
|
|
// RunConfigurations:
|
|
|
|
|
if (targetKey == QLatin1String("ProjectExplorer.Target.ActiveRunConfiguration"))
|
|
|
|
|
activeRc = targetIt.value().toInt();
|
|
|
|
|
else if (targetKey == QLatin1String("ProjectExplorer.Target.RunConfigurationCount"))
|
|
|
|
|
continue;
|
|
|
|
|
else if (targetKey.startsWith(QLatin1String("ProjectExplorer.Target.RunConfiguration.")))
|
2012-08-08 11:23:45 +03:00
|
|
|
rcs.insert(targetId(targetKey), targetIt.value().toMap());
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-06-20 15:51:28 +02:00
|
|
|
// Rest (the target's ProjectConfiguration settings only as there is nothing else):
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
|
|
|
|
extraTargetData.insert(targetKey, targetIt.value());
|
|
|
|
|
}
|
2012-08-07 14:01:52 +02:00
|
|
|
const QString oldTargetId = extraTargetData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// Check each BCs/DCs and create profiles as needed
|
2012-08-07 14:01:52 +02:00
|
|
|
static Profile rawProfile; // Do not needlessly use Core::Ids
|
2012-08-08 11:23:45 +03:00
|
|
|
QMapIterator<int, QVariantMap> buildIt(bcs);
|
|
|
|
|
while (buildIt.hasNext()) {
|
|
|
|
|
buildIt.next();
|
|
|
|
|
int bcPos = buildIt.key();
|
|
|
|
|
const QVariantMap &bc = buildIt.value();
|
2012-08-07 14:01:52 +02:00
|
|
|
Profile *tmpProfile = &rawProfile;
|
|
|
|
|
|
|
|
|
|
if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.AndroidDeviceTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":/android/images/QtAndroid.png"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
|
2012-08-07 14:01:52 +02:00
|
|
|
} else if (oldTargetId == QLatin1String("RemoteLinux.EmbeddedLinuxTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":///DESKTOP///"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("GenericLinuxOsType"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
|
2012-08-07 14:01:52 +02:00
|
|
|
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.HarmattanDeviceTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("HarmattanOsType"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
|
2012-08-07 14:01:52 +02:00
|
|
|
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Maemo5OsType"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
|
2012-08-07 14:01:52 +02:00
|
|
|
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MeegoDeviceTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("MeegoOsType"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
|
|
|
|
|
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")) {
|
|
|
|
|
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/SymbianDevice.png"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Qt4ProjectManager.SymbianDevice"));
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Symbian Device"));
|
2012-08-07 14:01:52 +02:00
|
|
|
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.QtSimulatorTarget")) {
|
2012-08-22 13:27:25 +02:00
|
|
|
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/Simulator.png"));
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Desktop Device"));
|
2012-06-20 15:51:28 +02:00
|
|
|
} else {
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setIconPath(QLatin1String(":///DESKTOP///"));
|
2012-08-22 16:12:57 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Desktop Device"));
|
2012-06-20 15:51:28 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// Tool chain
|
|
|
|
|
QString tcId = bc.value(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.ToolChain")).toString();
|
|
|
|
|
if (tcId.isEmpty())
|
|
|
|
|
tcId = bc.value(QLatin1String("ProjectExplorer.BuildCOnfiguration.ToolChain")).toString();
|
2012-06-20 15:51:28 +02:00
|
|
|
const QString origTcId = tcId;
|
|
|
|
|
tcId.replace(QLatin1String("Qt4ProjectManager.ToolChain.Maemo:"),
|
|
|
|
|
QLatin1String("ProjectExplorer.ToolChain.Gcc:")); // convert Maemo to GCC
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.ToolChain"), tcId);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// QtVersion
|
|
|
|
|
int qtVersionId = bc.value(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId"), -1).toInt();
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("QtSupport.QtInformation"), qtVersionId);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// Debugger + mkspec
|
2012-08-07 14:01:52 +02:00
|
|
|
QString debugger;
|
|
|
|
|
QString mkspec;
|
2012-06-20 15:51:28 +02:00
|
|
|
if (m_toolChainExtras.contains(origTcId)) {
|
2012-06-26 14:53:30 +02:00
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
2012-08-07 14:01:52 +02:00
|
|
|
debugger = m_toolChainExtras.value(origTcId).m_debugger;
|
2012-06-26 14:53:30 +02:00
|
|
|
if (!debugger.isEmpty() && !QFileInfo(debugger).isAbsolute())
|
|
|
|
|
debugger = env.searchInPath(debugger);
|
2012-08-07 14:01:52 +02:00
|
|
|
mkspec = m_toolChainExtras.value(origTcId).m_mkspec;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("Debugger.Information"), debugger);
|
|
|
|
|
tmpProfile->setValue(Core::Id("QtPM4.mkSpecInformation"), mkspec);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// SysRoot
|
2012-08-07 14:01:52 +02:00
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.SysRoot"), m_qtVersionExtras.value(qtVersionId));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-08-08 11:23:45 +03:00
|
|
|
QMapIterator<int, QVariantMap> deployIt(dcs);
|
|
|
|
|
while (deployIt.hasNext()) {
|
|
|
|
|
deployIt.next();
|
|
|
|
|
int dcPos = deployIt.key();
|
|
|
|
|
const QVariantMap &dc = deployIt.value();
|
2012-08-07 14:01:52 +02:00
|
|
|
// Device
|
|
|
|
|
QString devId = dc.value(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId")).toString();
|
2012-08-22 13:27:25 +02:00
|
|
|
if (devId.isEmpty())
|
|
|
|
|
devId = QByteArray("Desktop Device");
|
2012-08-07 14:01:52 +02:00
|
|
|
if (!devId.isEmpty() && !DeviceManager::instance()->find(Core::Id(devId))) // We do not know that device
|
|
|
|
|
devId.clear();
|
|
|
|
|
tmpProfile->setValue(Core::Id("PE.Profile.Device"), devId);
|
|
|
|
|
|
|
|
|
|
// Set display name last:
|
|
|
|
|
tmpProfile->setDisplayName(extraTargetData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName")).toString());
|
|
|
|
|
|
|
|
|
|
Profile *p = uniqueProfile(tmpProfile);
|
|
|
|
|
|
|
|
|
|
addBuildConfiguration(p, bc, bcPos, activeBc);
|
|
|
|
|
addDeployConfiguration(p, dc, dcPos, activeDc);
|
|
|
|
|
addRunConfigurations(p, rcs, activeRc, project->projectDirectory());
|
|
|
|
|
if (targetPos == activeTarget && bcPos == activeBc && dcPos == activeDc)
|
|
|
|
|
m_targets[p].insert(QLatin1String("Update.IsActive"), true);
|
|
|
|
|
} // dcs
|
2012-04-24 15:49:09 +02:00
|
|
|
} // bcs
|
2012-08-07 14:01:52 +02:00
|
|
|
} // read in map data
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
int newPos = 0;
|
|
|
|
|
// Generate new target data:
|
|
|
|
|
foreach (Profile *p, m_targets.keys()) {
|
|
|
|
|
QVariantMap data = m_targets.value(p);
|
|
|
|
|
if (data.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
|
2012-08-07 14:01:52 +02:00
|
|
|
pm->registerProfile(p);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
data.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), p->id().name());
|
|
|
|
|
data.insert(QLatin1String("ProjectExplorer.Target.Profile"), p->id().name());
|
|
|
|
|
data.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), p->displayName());
|
|
|
|
|
data.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DefaultDisplayName"), p->displayName());
|
|
|
|
|
|
|
|
|
|
result.insert(QString::fromLatin1("ProjectExplorer.Project.Target.") + QString::number(newPos), data);
|
2012-08-07 14:01:52 +02:00
|
|
|
if (data.value(QLatin1String("Update.IsActive"), false).toBool())
|
2012-04-24 15:49:09 +02:00
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.ActiveTarget"), newPos);
|
|
|
|
|
++newPos;
|
|
|
|
|
}
|
|
|
|
|
result.insert(QLatin1String("ProjectExplorer.Project.TargetCount"), newPos);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-07 14:01:52 +02:00
|
|
|
Profile *Version11Handler::uniqueProfile(Profile *p)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-08-22 16:12:57 +02:00
|
|
|
const QString tc = p->value(Core::Id("PE.Profile.ToolChain")).toString();
|
|
|
|
|
const int qt = p->value(Core::Id("QtSupport.QtInformation")).toInt();
|
|
|
|
|
const QString debugger = p->value(Core::Id("Debugger.Information")).toString();
|
|
|
|
|
const QString mkspec = p->value(Core::Id("QtPM4.mkSpecInformation")).toString();
|
|
|
|
|
const QString deviceType = p->value(Core::Id("PE.Profile.DeviceType")).toString();
|
|
|
|
|
const QString device = p->value(Core::Id("PE.Profile.Device")).toString();
|
|
|
|
|
const QString sysroot = p->value(Core::Id("PE.Profile.SysRoot")).toString();
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
foreach (Profile *i, m_targets.keys()) {
|
2012-08-22 16:12:57 +02:00
|
|
|
const QString currentTc = i->value(Core::Id("PE.Profile.ToolChain")).toString();
|
|
|
|
|
const int currentQt = i->value(Core::Id("QtSupport.QtInformation")).toInt();
|
|
|
|
|
const QString currentDebugger = i->value(Core::Id("Debugger.Information")).toString();
|
|
|
|
|
const QString currentMkspec = i->value(Core::Id("QtPM4.mkSpecInformation")).toString();
|
|
|
|
|
const QString currentDeviceType = i->value(Core::Id("PE.Profile.DeviceType")).toString();
|
|
|
|
|
const QString currentDevice = i->value(Core::Id("PE.Profile.Device")).toString();
|
|
|
|
|
const QString currentSysroot = i->value(Core::Id("PE.Profile.SysRoot")).toString();
|
|
|
|
|
|
|
|
|
|
bool deviceTypeOk = deviceType == currentDeviceType;
|
|
|
|
|
bool deviceOk = device.isEmpty() || currentDevice == device;
|
|
|
|
|
bool tcOk = tc.isEmpty() || currentTc.isEmpty() || currentTc == tc;
|
|
|
|
|
bool qtOk = qt == -1 || currentQt == qt;
|
|
|
|
|
bool debuggerOk = debugger.isEmpty() || currentDebugger.isEmpty() || currentDebugger == debugger;
|
|
|
|
|
bool mkspecOk = mkspec.isEmpty() || currentMkspec.isEmpty() || currentMkspec == mkspec;
|
|
|
|
|
bool sysrootOk = sysroot.isEmpty() || currentSysroot == sysroot;
|
|
|
|
|
|
|
|
|
|
if (deviceTypeOk && deviceOk && tcOk && qtOk && debuggerOk && mkspecOk && sysrootOk)
|
2012-08-07 14:01:52 +02:00
|
|
|
return i;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2012-08-07 14:01:52 +02:00
|
|
|
return p->clone(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Version11Handler::addBuildConfiguration(Profile *p, const QVariantMap &bc, int bcPos, int bcActive)
|
|
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap merged = m_targets.value(p);
|
2012-08-07 14:01:52 +02:00
|
|
|
int internalCount = merged.value(QLatin1String("ProjectExplorer.Target.BuildConfigurationCount"), 0).toInt();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-08-07 14:01:52 +02:00
|
|
|
for (int i = 0; i < internalCount; ++i) {
|
|
|
|
|
QVariantMap bcData = merged.value(QString::fromLatin1("ProjectExplorer.Target.BuildConfiguration.") + QString::number(i)).toMap();
|
|
|
|
|
if (bcData.value(QLatin1String("Update.BCPos"), -1).toInt() == bcPos)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QVariantMap data = bc;
|
|
|
|
|
data.insert(QLatin1String("Update.BCPos"), bcPos);
|
|
|
|
|
|
|
|
|
|
merged.insert(QString::fromLatin1("ProjectExplorer.Target.BuildConfiguration.") + QString::number(internalCount), data);
|
|
|
|
|
if (bcPos == bcActive)
|
|
|
|
|
merged.insert(QLatin1String("ProjectExplorer.Target.ActiveBuildConfiguration"), internalCount);
|
|
|
|
|
merged.insert(QLatin1String("ProjectExplorer.Target.BuildConfigurationCount"), internalCount + 1);
|
|
|
|
|
|
|
|
|
|
m_targets.insert(p, merged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Version11Handler::addDeployConfiguration(Profile *p, const QVariantMap &dc, int dcPos, int dcActive)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap merged = m_targets.value(p);
|
|
|
|
|
int internalCount = merged.value(QLatin1String("ProjectExplorer.Target.DeployConfigurationCount"), 0).toInt();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < internalCount; ++i) {
|
|
|
|
|
QVariantMap dcData = merged.value(QString::fromLatin1("ProjectExplorer.Target.DeployConfiguration.") + QString::number(i)).toMap();
|
|
|
|
|
if (dcData.value(QLatin1String("Update.DCPos"), -1).toInt() == dcPos)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QVariantMap data = dc;
|
|
|
|
|
data.insert(QLatin1String("Update.DCPos"), dcPos);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-08-07 14:01:52 +02:00
|
|
|
merged.insert(QString::fromLatin1("ProjectExplorer.Target.DeployConfiguration.") + QString::number(internalCount), data);
|
|
|
|
|
if (dcPos == dcActive)
|
|
|
|
|
merged.insert(QLatin1String("ProjectExplorer.Target.ActiveDeployConfiguration"), internalCount);
|
|
|
|
|
merged.insert(QLatin1String("ProjectExplorer.Target.DeployConfigurationCount"), internalCount + 1);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
m_targets.insert(p, merged);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-07 14:01:52 +02:00
|
|
|
void Version11Handler::addRunConfigurations(Profile *p,
|
2012-08-08 11:23:45 +03:00
|
|
|
const QMap<int, QVariantMap> &rcs, int activeRc,
|
2012-06-20 15:51:28 +02:00
|
|
|
const QString &projectDir)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-08-07 14:01:52 +02:00
|
|
|
QVariantMap data = m_targets.value(p);
|
2012-08-08 11:23:45 +03:00
|
|
|
data.insert(QLatin1String("ProjectExplorer.Target.RunConfigurationCount"), rcs.count());
|
|
|
|
|
QMapIterator<int, QVariantMap> runIt(rcs);
|
|
|
|
|
while (runIt.hasNext()) {
|
|
|
|
|
runIt.next();
|
|
|
|
|
QVariantMap rcData = runIt.value();
|
2012-08-07 14:01:52 +02:00
|
|
|
QString proFile = rcData.value(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.ProFile")).toString();
|
|
|
|
|
if (proFile.isEmpty())
|
|
|
|
|
proFile = rcData.value(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.ProFile")).toString();
|
|
|
|
|
if (!proFile.isEmpty()) {
|
|
|
|
|
QString newId = rcData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString();
|
|
|
|
|
newId.append(QLatin1Char(':'));
|
|
|
|
|
Utils::FileName fn = Utils::FileName::fromString(projectDir);
|
|
|
|
|
fn.appendPath(proFile);
|
|
|
|
|
newId.append(fn.toString());
|
|
|
|
|
rcData.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), newId);
|
2012-06-20 15:51:28 +02:00
|
|
|
}
|
2012-08-08 11:23:45 +03:00
|
|
|
data.insert(QString::fromLatin1("ProjectExplorer.Target.RunConfiguration.") + QString::number(runIt.key()), rcData);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2012-08-07 14:01:52 +02:00
|
|
|
data.insert(QLatin1String("ProjectExplorer.Target.ActiveRunConfiguration"), activeRc);
|
|
|
|
|
|
|
|
|
|
m_targets.insert(p, data);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-20 15:51:28 +02:00
|
|
|
static QString targetRoot(const QString &qmakePath)
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
Qt::CaseSensitivity cs = Qt::CaseInsensitive;
|
|
|
|
|
const QString binQmake = "/bin/qmake.exe";
|
|
|
|
|
#else
|
|
|
|
|
Qt::CaseSensitivity cs = Qt::CaseSensitive;
|
|
|
|
|
const QString binQmake = "/bin/qmake";
|
|
|
|
|
#endif
|
|
|
|
|
return QDir::cleanPath(qmakePath).remove(binQmake, cs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString maddeRoot(const QString &qmakePath)
|
|
|
|
|
{
|
|
|
|
|
QDir dir(targetRoot(qmakePath));
|
|
|
|
|
dir.cdUp(); dir.cdUp();
|
|
|
|
|
return dir.absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void Version11Handler::parseQtversionFile()
|
|
|
|
|
{
|
2012-08-07 17:43:06 +03:00
|
|
|
QFileInfo settingsLocation(ExtensionSystem::PluginManager::settings()->fileName());
|
2012-08-20 18:52:20 +02:00
|
|
|
Utils::FileName fileName = Utils::FileName::fromString(settingsLocation.absolutePath() + QLatin1String("/qtversion.xml"));
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::PersistentSettingsReader reader;
|
2012-06-20 15:51:28 +02:00
|
|
|
if (!reader.load(fileName)) {
|
|
|
|
|
qWarning("Failed to open legacy qtversions.xml file.");
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
2012-06-20 15:51:28 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap data = reader.restoreValues();
|
|
|
|
|
|
|
|
|
|
int count = data.value(QLatin1String("QtVersion.Count"), 0).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1("QtVersion.") + QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
continue;
|
|
|
|
|
const QVariantMap qtversionMap = data.value(key).toMap();
|
2012-06-20 15:51:28 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QString sysRoot = qtversionMap.value(QLatin1String("SystemRoot")).toString();
|
2012-06-20 15:51:28 +02:00
|
|
|
const QString type = qtversionMap.value(QLatin1String("QtVersion.Type")).toString();
|
|
|
|
|
const QString qmake = qtversionMap.value(QLatin1String("QMakePath")).toString();
|
|
|
|
|
|
|
|
|
|
if (type == QLatin1String("Qt4ProjectManager.QtVersion.Maemo")) {
|
|
|
|
|
QFile file(QDir::cleanPath(targetRoot(qmake)) + QLatin1String("/information"));
|
|
|
|
|
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
|
QTextStream stream(&file);
|
|
|
|
|
while (!stream.atEnd()) {
|
|
|
|
|
const QString &line = stream.readLine().trimmed();
|
|
|
|
|
const QStringList &list = line.split(QLatin1Char(' '));
|
|
|
|
|
if (list.count() <= 1)
|
|
|
|
|
continue;
|
|
|
|
|
if (list.at(0) == QLatin1String("sysroot")) {
|
|
|
|
|
sysRoot = maddeRoot(qmake) + QLatin1String("/sysroots/") + list.at(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
int id = qtversionMap.value(QLatin1String("Id")).toInt();
|
|
|
|
|
if (id > -1 && !sysRoot.isEmpty())
|
|
|
|
|
m_qtVersionExtras.insert(id, sysRoot);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Version11Handler::parseToolChainFile()
|
|
|
|
|
{
|
2012-08-07 17:43:06 +03:00
|
|
|
QFileInfo settingsLocation(ExtensionSystem::PluginManager::settings()->fileName());
|
2012-08-20 18:52:20 +02:00
|
|
|
Utils::FileName fileName = Utils::FileName::fromString(settingsLocation.absolutePath() + QLatin1String("/toolChains.xml"));
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::PersistentSettingsReader reader;
|
2012-06-20 15:51:28 +02:00
|
|
|
if (!reader.load(fileName)) {
|
|
|
|
|
qWarning("Failed to open legacy toolChains.xml file.");
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
2012-06-20 15:51:28 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap data = reader.restoreValues();
|
|
|
|
|
int count = data.value(QLatin1String("ToolChain.Count"), 0).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1("ToolChain.") + QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const QVariantMap tcMap = data.value(key).toMap();
|
|
|
|
|
QString id = tcMap.value(QLatin1String("ProjectExplorer.ToolChain.Id")).toString();
|
|
|
|
|
if (id.isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
QString mkspec = tcMap.value(QLatin1String("ProjectExplorer.ToolChain.MkSpecOverride")).toString();
|
|
|
|
|
QString debugger = tcMap.value(QLatin1String("ProjectExplorer.GccToolChain.Debugger")).toString();
|
|
|
|
|
|
|
|
|
|
m_toolChainExtras.insert(id, ToolChainExtraData(mkspec, debugger));
|
|
|
|
|
}
|
|
|
|
|
}
|