Pick better targets when importing projects

Task-number: QTCREATORBUG-7721

Change-Id: Ib444d233d99a5121129671debab18557135559f4
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Tobias Hunger
2012-08-22 16:12:57 +02:00
parent d80b608d52
commit 790cc8947c

View File

@@ -48,7 +48,6 @@
#include <utils/persistentsettings.h> #include <utils/persistentsettings.h>
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
@@ -2327,23 +2326,34 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.AndroidDeviceTarget")) { if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.AndroidDeviceTarget")) {
tmpProfile->setIconPath(QLatin1String(":/android/images/QtAndroid.png")); tmpProfile->setIconPath(QLatin1String(":/android/images/QtAndroid.png"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
} else if (oldTargetId == QLatin1String("RemoteLinux.EmbeddedLinuxTarget")) { } else if (oldTargetId == QLatin1String("RemoteLinux.EmbeddedLinuxTarget")) {
tmpProfile->setIconPath(QLatin1String(":///DESKTOP///")); tmpProfile->setIconPath(QLatin1String(":///DESKTOP///"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("GenericLinuxOsType")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("GenericLinuxOsType"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.HarmattanDeviceTarget")) { } else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.HarmattanDeviceTarget")) {
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png")); tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("HarmattanOsType")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("HarmattanOsType"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) { } else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) {
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png")); tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Maemo5OsType")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Maemo5OsType"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MeegoDeviceTarget")) { } else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MeegoDeviceTarget")) {
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png")); tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("MeegoOsType")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("MeegoOsType"));
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"));
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.QtSimulatorTarget")) { } else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.QtSimulatorTarget")) {
tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/Simulator.png")); tmpProfile->setIconPath(QLatin1String(":/projectexplorer/images/Simulator.png"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop")); tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Desktop Device"));
} else { } else {
tmpProfile->setIconPath(QLatin1String(":///DESKTOP///")); tmpProfile->setIconPath(QLatin1String(":///DESKTOP///"));
tmpProfile->setValue(Core::Id("PE.Profile.DeviceType"), QString::fromLatin1("Desktop"));
tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Desktop Device")); tmpProfile->setValue(Core::Id("PE.Profile.Device"), QString::fromLatin1("Desktop Device"));
} }
@@ -2429,24 +2439,34 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
Profile *Version11Handler::uniqueProfile(Profile *p) Profile *Version11Handler::uniqueProfile(Profile *p)
{ {
foreach (Profile *i, m_targets.keys()) { const QString tc = p->value(Core::Id("PE.Profile.ToolChain")).toString();
const QString tc = i->value(Core::Id("PE.Profile.ToolChain")).toString(); const int qt = p->value(Core::Id("QtSupport.QtInformation")).toInt();
const int qt = i->value(Core::Id("QtSupport.QtInformation")).toInt(); const QString debugger = p->value(Core::Id("Debugger.Information")).toString();
const QString debugger = i->value(Core::Id("Debugger.Information")).toString(); const QString mkspec = p->value(Core::Id("QtPM4.mkSpecInformation")).toString();
const QString mkspec = i->value(Core::Id("QtPM4.mkSpecInformation")).toString(); const QString deviceType = p->value(Core::Id("PE.Profile.DeviceType")).toString();
const QString device = i->value(Core::Id("PE.Profile.Device")).toString(); const QString device = p->value(Core::Id("PE.Profile.Device")).toString();
const QString sysroot = p->value(Core::Id("PE.Profile.SysRoot")).toString();
if ((i->value(Core::Id("PE.Profile.DeviceType")).toString() == p->value(Core::Id("PE.Profile.DeviceType")).toString()) foreach (Profile *i, m_targets.keys()) {
&& (tc.isEmpty() || (tc == p->value(Core::Id("PE.Profile.ToolChain")).toString())) const QString currentTc = i->value(Core::Id("PE.Profile.ToolChain")).toString();
&& (qt == p->value(Core::Id("QtSupport.QtInformation")).toInt()) const int currentQt = i->value(Core::Id("QtSupport.QtInformation")).toInt();
&& (debugger.isEmpty() || (debugger == p->value(Core::Id("Debugger.Information")).toString())) const QString currentDebugger = i->value(Core::Id("Debugger.Information")).toString();
&& (mkspec.isEmpty() || (mkspec == p->value(Core::Id("QtPM4.mkSpecInformation")).toString())) const QString currentMkspec = i->value(Core::Id("QtPM4.mkSpecInformation")).toString();
&& (i->value(Core::Id("PE.Profile.SysRoot")).toString() == p->value(Core::Id("PE.Profile.SysRoot")).toString()) const QString currentDeviceType = i->value(Core::Id("PE.Profile.DeviceType")).toString();
&& (device == p->value(Core::Id("PE.Profile.Device")))) { 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)
return i; return i;
} }
}
return p->clone(true); return p->clone(true);
} }