forked from qt-creator/qt-creator
QtSupport: Additional parameter for QtVersion::restore().
This enables a QtVersionFactory to be able to create more than one QtVersion, which can make sense e.g. if there are several closely related ones. Change-Id: I597f524abfc27c483c71bb6567ce7b77bc3d3041 Reviewed-on: http://codereview.qt.nokia.com/835 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -58,8 +58,10 @@ bool DesktopQtVersionFactory::canRestore(const QString &type)
|
|||||||
return type == QLatin1String(QtSupport::Constants::DESKTOPQT);
|
return type == QLatin1String(QtSupport::Constants::DESKTOPQT);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *DesktopQtVersionFactory::restore(const QVariantMap &data)
|
QtSupport::BaseQtVersion *DesktopQtVersionFactory::restore(const QString &type, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
|
if (!canRestore(type))
|
||||||
|
return 0;
|
||||||
DesktopQtVersion *v = new DesktopQtVersion;
|
DesktopQtVersion *v = new DesktopQtVersion;
|
||||||
v->fromMap(data);
|
v->fromMap(data);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
~DesktopQtVersionFactory();
|
~DesktopQtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type);
|
virtual bool canRestore(const QString &type);
|
||||||
virtual QtSupport::BaseQtVersion *restore(const QVariantMap &data);
|
virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data);
|
||||||
|
|
||||||
virtual int priority() const;
|
virtual int priority() const;
|
||||||
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
||||||
|
|||||||
@@ -58,8 +58,10 @@ bool SimulatorQtVersionFactory::canRestore(const QString &type)
|
|||||||
return type == QLatin1String(QtSupport::Constants::SIMULATORQT);
|
return type == QLatin1String(QtSupport::Constants::SIMULATORQT);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *SimulatorQtVersionFactory::restore(const QVariantMap &data)
|
QtSupport::BaseQtVersion *SimulatorQtVersionFactory::restore(const QString &type, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
|
if (!canRestore(type))
|
||||||
|
return 0;
|
||||||
QtSupport::BaseQtVersion *v = new SimulatorQtVersion;
|
QtSupport::BaseQtVersion *v = new SimulatorQtVersion;
|
||||||
v->fromMap(data);
|
v->fromMap(data);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
~SimulatorQtVersionFactory();
|
~SimulatorQtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type);
|
virtual bool canRestore(const QString &type);
|
||||||
virtual QtSupport::BaseQtVersion *restore(const QVariantMap &data);
|
virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data);
|
||||||
|
|
||||||
virtual int priority() const;
|
virtual int priority() const;
|
||||||
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ bool SymbianQtVersionFactory::canRestore(const QString &type)
|
|||||||
return type == QLatin1String(QtSupport::Constants::SYMBIANQT);
|
return type == QLatin1String(QtSupport::Constants::SYMBIANQT);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *SymbianQtVersionFactory::restore(const QVariantMap &data)
|
QtSupport::BaseQtVersion *SymbianQtVersionFactory::restore(const QString &type, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
|
if (!canRestore(type))
|
||||||
|
return 0;
|
||||||
SymbianQtVersion *v = new SymbianQtVersion;
|
SymbianQtVersion *v = new SymbianQtVersion;
|
||||||
v->fromMap(data);
|
v->fromMap(data);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
~SymbianQtVersionFactory();
|
~SymbianQtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type);
|
virtual bool canRestore(const QString &type);
|
||||||
virtual QtSupport::BaseQtVersion *restore(const QVariantMap &data);
|
virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data);
|
||||||
|
|
||||||
virtual int priority() const;
|
virtual int priority() const;
|
||||||
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
||||||
|
|||||||
@@ -55,8 +55,10 @@ bool WinCeQtVersionFactory::canRestore(const QString &type)
|
|||||||
return type == QLatin1String(QtSupport::Constants::WINCEQT);
|
return type == QLatin1String(QtSupport::Constants::WINCEQT);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *WinCeQtVersionFactory::restore(const QVariantMap &data)
|
QtSupport::BaseQtVersion *WinCeQtVersionFactory::restore(const QString &type, const QVariantMap &data)
|
||||||
{
|
{
|
||||||
|
if (!canRestore(type))
|
||||||
|
return 0;
|
||||||
WinCeQtVersion *v = new WinCeQtVersion;
|
WinCeQtVersion *v = new WinCeQtVersion;
|
||||||
v->fromMap(data);
|
v->fromMap(data);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
~WinCeQtVersionFactory();
|
~WinCeQtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type);
|
virtual bool canRestore(const QString &type);
|
||||||
virtual QtSupport::BaseQtVersion *restore(const QVariantMap &data);
|
virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data);
|
||||||
|
|
||||||
virtual int priority() const;
|
virtual int priority() const;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
~QtVersionFactory();
|
~QtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type) = 0;
|
virtual bool canRestore(const QString &type) = 0;
|
||||||
virtual BaseQtVersion *restore(const QVariantMap &data) = 0;
|
virtual BaseQtVersion *restore(const QString &type, const QVariantMap &data) = 0;
|
||||||
|
|
||||||
/// factories with higher priority are asked first to identify
|
/// factories with higher priority are asked first to identify
|
||||||
/// a qtversion, the priority of the desktop factory is 0 and
|
/// a qtversion, the priority of the desktop factory is 0 and
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ bool QtVersionManager::restoreQtVersions()
|
|||||||
bool restored = false;
|
bool restored = false;
|
||||||
foreach (QtVersionFactory *f, factories) {
|
foreach (QtVersionFactory *f, factories) {
|
||||||
if (f->canRestore(type)) {
|
if (f->canRestore(type)) {
|
||||||
if (BaseQtVersion *qtv = f->restore(qtversionMap)) {
|
if (BaseQtVersion *qtv = f->restore(type, qtversionMap)) {
|
||||||
if (m_versions.contains(qtv->uniqueId())) {
|
if (m_versions.contains(qtv->uniqueId())) {
|
||||||
// This shouldn't happen, we are restoring the same id multiple times?
|
// This shouldn't happen, we are restoring the same id multiple times?
|
||||||
qWarning() << "A Qt version with id"<<qtv->uniqueId()<<"already exists";
|
qWarning() << "A Qt version with id"<<qtv->uniqueId()<<"already exists";
|
||||||
@@ -292,7 +292,7 @@ void QtVersionManager::updateFromInstaller()
|
|||||||
removeVersion(v);
|
removeVersion(v);
|
||||||
qtversionMap[QLatin1String("Id")] = id;
|
qtversionMap[QLatin1String("Id")] = id;
|
||||||
|
|
||||||
if (BaseQtVersion *qtv = factory->restore(qtversionMap)) {
|
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
||||||
Q_ASSERT(qtv->isAutodetected());
|
Q_ASSERT(qtv->isAutodetected());
|
||||||
addVersion(qtv);
|
addVersion(qtv);
|
||||||
restored = true;
|
restored = true;
|
||||||
@@ -303,7 +303,7 @@ void QtVersionManager::updateFromInstaller()
|
|||||||
if (!restored) { // didn't replace any existing versions
|
if (!restored) { // didn't replace any existing versions
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
qDebug() << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
||||||
if (BaseQtVersion *qtv = factory->restore(qtversionMap)) {
|
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
||||||
Q_ASSERT(qtv->isAutodetected());
|
Q_ASSERT(qtv->isAutodetected());
|
||||||
addVersion(qtv);
|
addVersion(qtv);
|
||||||
restored = true;
|
restored = true;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "maemoqtversion.h"
|
#include "maemoqtversion.h"
|
||||||
|
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
@@ -57,8 +58,10 @@ bool MaemoQtVersionFactory::canRestore(const QString &type)
|
|||||||
return type == QLatin1String(QtSupport::Constants::MAEMOQT);
|
return type == QLatin1String(QtSupport::Constants::MAEMOQT);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *MaemoQtVersionFactory::restore(const QVariantMap &data)
|
QtSupport::BaseQtVersion *MaemoQtVersionFactory::restore(const QString &type,
|
||||||
|
const QVariantMap &data)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(canRestore(type), return 0);
|
||||||
MaemoQtVersion *v = new MaemoQtVersion;
|
MaemoQtVersion *v = new MaemoQtVersion;
|
||||||
v->fromMap(data);
|
v->fromMap(data);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
~MaemoQtVersionFactory();
|
~MaemoQtVersionFactory();
|
||||||
|
|
||||||
virtual bool canRestore(const QString &type);
|
virtual bool canRestore(const QString &type);
|
||||||
virtual QtSupport::BaseQtVersion *restore(const QVariantMap &data);
|
virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data);
|
||||||
|
|
||||||
virtual int priority() const;
|
virtual int priority() const;
|
||||||
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
virtual QtSupport::BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString());
|
||||||
|
|||||||
Reference in New Issue
Block a user