diff --git a/qtcreator.pri b/qtcreator.pri index ce9e3f91ceb5163b16962c34725b54d6d3e0eba5..2890da370aba0b0db3a1951461e016545d9765d9 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -159,7 +159,3 @@ win32-msvc* { #Don't warn about sprintf, fopen etc being 'unsafe' DEFINES += _CRT_SECURE_NO_WARNINGS } - -# Handle S60 support: default on Windows, conditionally built on other platforms. -macx:SUPPORT_QT_S60 = $$(QTCREATOR_WITH_S60) -else:SUPPORT_QT_S60=1 diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri index f6347e41fb99cf9cc80f0abb9315081da1a8c2ac..a85714fe69ac9b58331bdebfcac3937e41981658 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri +++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri @@ -1,9 +1,4 @@ -!isEmpty(SUPPORT_QT_S60) { - DEFINES += QTCREATOR_WITH_S60 -} -SOURCES += $$PWD/s60devices.cpp \ - $$PWD/s60devicespreferencepane.cpp \ - $$PWD/s60manager.cpp \ +SOURCES += $$PWD/s60manager.cpp \ $$PWD/sbsv2parser.cpp \ $$PWD/winscwtoolchain.cpp \ $$PWD/gccetoolchain.cpp \ @@ -39,9 +34,7 @@ SOURCES += $$PWD/s60devices.cpp \ $$PWD/s60publishingbuildsettingspageovi.cpp \ $$PWD/s60publishingresultspageovi.cpp -HEADERS += $$PWD/s60devices.h \ - $$PWD/s60devicespreferencepane.h \ - $$PWD/s60manager.h \ +HEADERS += $$PWD/s60manager.h \ $$PWD/sbsv2parser.h \ $$PWD/winscwtoolchain.h \ $$PWD/gccetoolchain.h \ @@ -77,8 +70,7 @@ HEADERS += $$PWD/s60devices.h \ $$PWD/s60publishingbuildsettingspageovi.h \ $$PWD/s60publishingresultspageovi.h -FORMS += $$PWD/s60devicespreferencepane.ui \ - $$PWD/s60createpackagestep.ui \ +FORMS += $$PWD/s60createpackagestep.ui \ $$PWD/s60certificatedetailsdialog.ui \ $$PWD/rvcttoolchainconfigwidget.ui \ $$PWD/winscwtoolchainconfigwidget.ui \ diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 8b5331564914538b05a73f06441788ccf98d84ef..636f071376f565e797a27efb73fd455f51540eca 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -272,7 +272,7 @@ static inline QString executableFromPackageUnix(const QString &packageFileName) } // ABLD/Raptor: Return executable from device/EPOC -static inline QString localExecutableFromDevice(const QtVersion *qtv, +static inline QString localExecutableFromVersion(const QtVersion *qtv, const QString &symbianTarget, /* udeb/urel */ const QString &targetName, const ProjectExplorer::ToolChain *tc) @@ -281,12 +281,11 @@ static inline QString localExecutableFromDevice(const QtVersion *qtv, if (!tc) return QString(); - const S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(qtv); QString localExecutable; QString platform = S60Manager::platform(tc); if (qtv->isBuildWithSymbianSbsV2() && platform == QLatin1String("gcce")) platform = "armv5"; - QTextStream(&localExecutable) << device.epocRoot << "/epoc32/release/" + QTextStream(&localExecutable) << qtv->systemRoot() << "/epoc32/release/" << platform << '/' << symbianTarget << '/' << targetName << ".exe"; return localExecutable; } @@ -303,7 +302,7 @@ QString S60DeviceRunConfiguration::localExecutableFileName() const } ProjectExplorer::ToolChain *tc = qt4Target()->activeBuildConfiguration()->toolChain(); - return localExecutableFromDevice(qtVersion(), symbianTarget(), targetName(), tc); + return localExecutableFromVersion(qtVersion(), symbianTarget(), targetName(), tc); } quint32 S60DeviceRunConfiguration::executableUid() const diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp deleted file mode 100644 index e0c65a805112970a296b4998606189d8b1dad3b6..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/qt-s60/s60devices.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** No Commercial Usage -** -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "s60devices.h" - -#include <utils/environment.h> - -#include <coreplugin/icore.h> - -#include <QtCore/QSettings> -#include <QtCore/QXmlStreamReader> -#include <QtCore/QTextStream> -#include <QtCore/QFile> -#include <QtCore/QDir> -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> - -namespace { - const char * const SYMBIAN_SDKS_KEY = "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs"; - const char * const SYMBIAN_PATH_KEY = "CommonPath"; - const char * const SYMBIAN_DEVICES_FILE = "devices.xml"; - const char * const DEVICES_LIST = "devices"; - const char * const DEVICE = "device"; - const char * const DEVICE_ID = "id"; - const char * const DEVICE_NAME = "name"; - const char * const DEVICE_DEFAULT = "default"; - const char * const DEVICE_EPOCROOT = "epocroot"; - const char * const DEVICE_TOOLSROOT = "toolsroot"; - const char * const GNUPOC_SETTINGS_GROUP = "GnuPocSDKs"; - const char * const AUTODETECT_SETTINGS_GROUP = "SymbianSDKs"; - const char * const SDK_QT_ASSOC_SETTINGS_KEY_ROOT = "SymbianSDK"; - const char * const SETTINGS_DEFAULT_SDK_POSTFIX = ",default"; -} - -namespace Qt4ProjectManager { -namespace Internal { - -static int findDefaultDevice(const QList<S60Devices::Device> &d) -{ - const int count = d.size(); - for (int i = 0; i < count; i++) - if (d.at(i).isDefault) - return i; - return -1; -} - -S60Devices::Device::Device() : - isDefault(false) -{ -} - -bool S60Devices::Device::equals(const Device &rhs) const -{ - return id == rhs.id && name == rhs.name && isDefault == rhs.isDefault - && epocRoot == rhs.epocRoot && toolsRoot == rhs.toolsRoot - && qt == rhs.qt; -} - -QString S60Devices::Device::toHtml() const -{ - QString rc; - QTextStream str(&rc); - str << "<html><body><table>" - << "<tr><td><b>" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Id:") - << "</b></td><td>" << id << "</td></tr>" - << "<tr><td><b>" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Name:") - << "</b></td><td>" << name << "</td></tr>" - << "<tr><td><b>" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "EPOC:") - << "</b></td><td>" << epocRoot << "</td></tr>" - << "<tr><td><b>" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Tools:") - << "</b></td><td>" << toolsRoot << "</td></tr>" - << "<tr><td><b>" << QCoreApplication::translate("Qt4ProjectManager::Internal::S60Devices::Device", "Qt:") - << "</b></td><td>" << qt << "</td></tr>"; - return rc; -} - -// ------------ S60Devices -S60Devices::S60Devices(QObject *parent) : QObject(parent) -{ -} - -QList<S60Devices::Device> S60Devices::devices() const -{ - return m_devices; -} - -void S60Devices::setDevices(const QList<Device> &devices) -{ - if (m_devices != devices) { - m_devices = devices; - // Ensure a default device - if (!m_devices.isEmpty() && findDefaultDevice(m_devices) == -1) - m_devices.front().isDefault = true; - writeSettings(); - emit qtVersionsChanged(); - } -} - -const QList<S60Devices::Device> &S60Devices::devicesList() const -{ - return m_devices; -} - -QList<S60Devices::Device> &S60Devices::devicesList() -{ - return m_devices; -} - -S60Devices *S60Devices::createS60Devices(QObject *parent) -{ - S60Devices *rc = 0; -#ifdef Q_OS_WIN - AutoDetectS60QtDevices *ad = new AutoDetectS60QtDevices(parent); - ad->detectDevices(); - rc = ad; -#else - rc = new GnuPocS60Devices(parent); -#endif - rc->readSettings(); - return rc; -} - -int S60Devices::findById(const QString &id) const -{ - const int count = m_devices.size(); - for (int i = 0; i < count; i++) - if (m_devices.at(i).id == id) - return i; - return -1; -} - -int S60Devices::findByEpocRoot(const QString &er) const -{ - const int count = m_devices.size(); - for (int i = 0; i < count; i++) - if (m_devices.at(i).epocRoot == er) - return i; - return -1; -} - -S60Devices::Device S60Devices::deviceForId(const QString &id) const -{ - const int index = findById(id); - return index == -1 ? Device() : m_devices.at(index); -} - -S60Devices::Device S60Devices::deviceForEpocRoot(const QString &root) const -{ - const int index = findByEpocRoot(root); - return index == -1 ? Device() : m_devices.at(index); -} - -S60Devices::Device S60Devices::defaultDevice() const -{ - const int index = findDefaultDevice(m_devices); - return index == -1 ? Device() : m_devices.at(index); -} - -S60Devices::StringStringPairList S60Devices::readSdkQtAssociationSettings(const QSettings *settings, - const QString &group, - int *defaultIndexPtr) -{ - StringStringPairList rc; - // Read out numbered pairs of EpocRoot/QtDir as many as exist - // "SymbianSDK1=/epoc,/qt[,default]". - const QChar separator = QLatin1Char(','); - const QString keyRoot = group + QLatin1Char('/') + QLatin1String(SDK_QT_ASSOC_SETTINGS_KEY_ROOT); - int defaultIndex = -1; - for (int i = 1; ; i++) { - // Split pairs of epocroot/qtdir. - const QVariant valueV = settings->value(keyRoot + QString::number(i)); - if (!valueV.isValid()) - break; - // Check for default postfix - QString value = valueV.toString(); - if (value.endsWith(QLatin1String(SETTINGS_DEFAULT_SDK_POSTFIX))) { - value.truncate(value.size() - qstrlen(SETTINGS_DEFAULT_SDK_POSTFIX)); - defaultIndex = rc.size(); - } - // Split into SDK and Qt - const int separatorPos = value.indexOf(separator); - if (separatorPos == -1) - break; - const QString epocRoot = value.left(separatorPos); - const QString qtDir = value.mid(separatorPos + 1); - rc.push_back(StringStringPair(epocRoot, qtDir)); - } - if (defaultIndexPtr) - *defaultIndexPtr = defaultIndex; - return rc; -} - -void S60Devices::writeSdkQtAssociationSettings(QSettings *settings, const QString &group) const -{ - // Write out as numbered pairs of EpocRoot/QtDir and indicate default - // "SymbianSDK1=/epoc,/qt[,default]". - settings->beginGroup(group); - settings->remove(QString()); // remove all keys - if (const int count = devicesList().size()) { - const QString keyRoot = QLatin1String(SDK_QT_ASSOC_SETTINGS_KEY_ROOT); - const QChar separator = QLatin1Char(','); - for (int i = 0; i < count; i++) { - const QString key = keyRoot + QString::number(i + 1); - QString value = devicesList().at(i).epocRoot; - value += separator; - value += devicesList().at(i).qt; - // Indicate default by postfix ",default" - if (devicesList().at(i).isDefault) - value += QLatin1String(SETTINGS_DEFAULT_SDK_POSTFIX); - settings->setValue(key, value); - } - } - settings->endGroup(); -} - -void S60Devices::readSettings() -{ -} - -void S60Devices::writeSettings() -{ -} - -// ------------------ S60Devices - -AutoDetectS60Devices::AutoDetectS60Devices(QObject *parent) : - S60Devices(parent) -{ -} - -QString AutoDetectS60Devices::errorString() const -{ - return m_errorString; -} - -// as pointed to by environment. -static QStringList commonProgramFilesPaths() -{ - const QChar pathSep = QLatin1Char(';'); - QStringList rc; - const QByteArray commonX86 = qgetenv("CommonProgramFiles(x86)"); - if (!commonX86.isEmpty()) - rc += QString::fromLocal8Bit(commonX86).split(pathSep); - const QByteArray common = qgetenv("CommonProgramFiles"); - if (!common.isEmpty()) - rc += QString::fromLocal8Bit(common).split(pathSep); - return rc; -} - -// Find the "devices.xml" file containing the SDKs -static QString devicesXmlFile(QString *errorMessage) -{ - const QString devicesFile = QLatin1String(SYMBIAN_DEVICES_FILE); - // Try registry - const QSettings settings(QLatin1String(SYMBIAN_SDKS_KEY), QSettings::NativeFormat); - const QString devicesRegistryXmlPath = settings.value(QLatin1String(SYMBIAN_PATH_KEY)).toString(); - if (!devicesRegistryXmlPath.isEmpty()) - return QDir::cleanPath(devicesRegistryXmlPath + QLatin1Char('/') + devicesFile); - // Look up common program data files - const QString symbianDir = QLatin1String("/symbian/"); - foreach(const QString &commonDataDir, commonProgramFilesPaths()) { - const QFileInfo fi(commonDataDir + symbianDir + devicesFile); - if (fi.isFile()) - return fi.absoluteFilePath(); - } - // None found... - *errorMessage = QString::fromLatin1("The file '%1' containing the device SDK configuration " - "could not be found looking at the registry key " - "%2\\%3 or the common program data directories."). - arg(devicesFile, QLatin1String(SYMBIAN_SDKS_KEY), - QLatin1String(SYMBIAN_PATH_KEY)); - return QString(); -} - -bool AutoDetectS60Devices::detectDevices() -{ - devicesList().clear(); - m_errorString.clear(); - const QString devicesXmlPath = devicesXmlFile(&m_errorString); - if (devicesXmlPath.isEmpty()) - return false; - QFile devicesFile(devicesXmlPath); - if (!devicesFile.open(QIODevice::ReadOnly|QIODevice::Text)) { - m_errorString = QString::fromLatin1("Could not open the devices file %1: %2").arg(devicesXmlPath, devicesFile.errorString()); - return false; - } - QXmlStreamReader xml(&devicesFile); - while (!xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == DEVICES_LIST) { - if (xml.attributes().value("version") == "1.0") { - // Look for correct device - while (!(xml.isEndElement() && xml.name() == DEVICES_LIST) && !xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == DEVICE) { - Device device; - device.id = xml.attributes().value(DEVICE_ID).toString(); - device.name = xml.attributes().value(DEVICE_NAME).toString(); - if (xml.attributes().value(DEVICE_DEFAULT).toString() == "yes") - device.isDefault = true; - else - device.isDefault = false; - while (!(xml.isEndElement() && xml.name() == DEVICE) && !xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == DEVICE_EPOCROOT) { - device.epocRoot = QDir::fromNativeSeparators(xml.readElementText()); - } else if (xml.isStartElement() && xml.name() == DEVICE_TOOLSROOT) { - device.toolsRoot = QDir::fromNativeSeparators(xml.readElementText()); - } - } - if (device.toolsRoot.isEmpty()) - device.toolsRoot = device.epocRoot; - devicesList().append(device); - } - } - } else { - xml.raiseError("Invalid 'devices' element version."); - } - } - } - devicesFile.close(); - if (xml.hasError()) { - m_errorString = QString::fromLatin1("Syntax error in devices file %1: %2"). - arg(devicesXmlPath, xml.errorString()); - return false; - } - return true; -} - -void AutoDetectS60Devices::readSettings() -{ - // Read the associated Qt version from the settings - // and set on the autodetected SDKs. - bool changed = false; - const QSettings *settings = Core::ICore::instance()->settings(); - foreach (const StringStringPair &p, readSdkQtAssociationSettings(settings, QLatin1String(GNUPOC_SETTINGS_GROUP))) { - const int index = findByEpocRoot(p.first); - if (index != -1 && devicesList().at(index).qt != p.second) { - devicesList()[index].qt = p.second; - changed = true; - } - } - if (changed) - emit qtVersionsChanged(); -} - -void AutoDetectS60Devices::writeSettings() -{ - writeSdkQtAssociationSettings(Core::ICore::instance()->settings(), QLatin1String(AUTODETECT_SETTINGS_GROUP)); -} - -// ========== AutoDetectS60QtDevices - -AutoDetectS60QtDevices::AutoDetectS60QtDevices(QObject *parent) : - AutoDetectS60Devices(parent) -{ -} - -// Detect a Qt version that is installed into a Symbian SDK -static QString detect_SDK_installedQt(const QString &epocRoot) -{ - const QString coreLibDllFileName = epocRoot + QLatin1String("/epoc32/release/winscw/udeb/QtCore.dll"); - QFile coreLibDllFile(coreLibDllFileName); - if (!coreLibDllFile.exists() || !coreLibDllFile.open(QIODevice::ReadOnly)) - return QString(); - - // Do not normalize these backslashes since they are in ARM binaries: - const QByteArray indicator("\\src\\corelib\\kernel\\qobject.h"); - const int indicatorlength = indicator.size(); - const int chunkSize = 10000; - - int index = -1; - QByteArray buffer; - while (true) { - buffer = coreLibDllFile.read(chunkSize); - index = buffer.indexOf(indicator); - if (index >= 0) - break; - if (buffer.size() < chunkSize || coreLibDllFile.atEnd()) - return QString(); - coreLibDllFile.seek(coreLibDllFile.pos() - indicatorlength); - } - coreLibDllFile.close(); - - int lastIndex = index; - while (index >= 0 && buffer.at(index)) - --index; - if (index < 0) - return QString(); - - index += 2; // the 0 and another byte for some reason - return QDir(QString::fromLatin1(buffer.mid(index, lastIndex-index))).absolutePath(); -} - -bool AutoDetectS60QtDevices::detectQtForDevices() -{ - bool changed = false; - const int deviceCount = devicesList().size(); - for (int i = 0; i < deviceCount; ++i) { - Device &device = devicesList()[i]; - if (device.qt.isEmpty()) { - device.qt = detect_SDK_installedQt(device.epocRoot); - if (device.qt.isEmpty()) { - qWarning("Unable to detect Qt version for '%s'.", qPrintable(device.epocRoot)); - } else { - changed = true; - } - } - } - if (changed) - emit qtVersionsChanged(); - return true; -} - -bool AutoDetectS60QtDevices::detectDevices() -{ - return AutoDetectS60Devices::detectDevices() && detectQtForDevices(); -} - -// ------- GnuPocS60Devices -GnuPocS60Devices::GnuPocS60Devices(QObject *parent) : - S60Devices(parent) -{ -} - -S60Devices::Device GnuPocS60Devices::createDevice(const QString &epoc, const QString &qtDir) -{ - Device device; - device.id = device.name = QLatin1String("GnuPoc"); - device.toolsRoot = device.epocRoot = epoc; - device.qt = qtDir; - return device; -} - -// GnuPoc settings are just the pairs of EpocRoot and Qt Dir. -void GnuPocS60Devices::readSettings() -{ - // Read out numbered pairs of EpocRoot/QtDir as many as exist - // "SymbianSDK1=/epoc,/qt". - devicesList().clear(); - int defaultIndex = 0; - const QSettings *settings = Core::ICore::instance()->settings(); - const StringStringPairList devices =readSdkQtAssociationSettings(settings, QLatin1String(GNUPOC_SETTINGS_GROUP), &defaultIndex); - foreach (const StringStringPair &p, devices) - devicesList().append(createDevice(p.first, p.second)); - // Ensure a default - if (!devicesList().isEmpty()) { - if (defaultIndex >= 0 && defaultIndex < devicesList().size()) { - devicesList()[defaultIndex].isDefault = true; - } else { - devicesList().front().isDefault = true; - } - } -} - -void GnuPocS60Devices::writeSettings() -{ - writeSdkQtAssociationSettings(Core::ICore::instance()->settings(), QLatin1String(GNUPOC_SETTINGS_GROUP)); -} - -QDebug operator<<(QDebug db, const S60Devices::Device &d) -{ - QDebug nospace = db.nospace(); - nospace << "id='" << d.id << "' name='" << d.name << "' default=" - << d.isDefault << " Epoc='" << d.epocRoot << "' tools='" - << d.toolsRoot << "' Qt='" << d.qt << '\''; - return db; -} - -QDebug operator<<(QDebug dbg, const S60Devices &d) -{ - foreach(const S60Devices::Device &device, d.devices()) - dbg << device; - return dbg; -} - -} // namespace Internal -} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devices.h b/src/plugins/qt4projectmanager/qt-s60/s60devices.h deleted file mode 100644 index 6ebd29245a667682fefb68403b8b8840f02541f3..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/qt-s60/s60devices.h +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** No Commercial Usage -** -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef S60DEVICES_H -#define S60DEVICES_H - -#include <projectexplorer/toolchain.h> - -#include <QtCore/QObject> -#include <QtCore/QString> -#include <QtCore/QList> -#include <QtCore/QPair> - -QT_BEGIN_NAMESPACE -class QDebug; -class QSettings; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { -namespace Internal { - -// List of S60 devices. -class S60Devices : public QObject -{ - Q_OBJECT -public: - struct Device { - Device(); - bool equals(const Device &rhs) const; - - QString toHtml() const; - - QString id; - QString name; - bool isDefault; - QString epocRoot; - QString toolsRoot; - QString qt; - }; - - // Construct a devices object, does autodetection if applicable - // and restores settings. - static S60Devices *createS60Devices(QObject *parent); - - QList<Device> devices() const; - // Set devices, write settings and emit changed signals accordingly. - void setDevices(const QList<Device> &device); - - Device deviceForId(const QString &id) const; - Device deviceForEpocRoot(const QString &root) const; - Device defaultDevice() const; - - int findByEpocRoot(const QString &er) const; - -signals: - void qtVersionsChanged(); - -protected: - typedef QPair<QString, QString> StringStringPair; - typedef QList<StringStringPair> StringStringPairList; - - explicit S60Devices(QObject *parent = 0); - - const QList<Device> &devicesList() const; - QList<Device> &devicesList(); - - int findById(const QString &id) const; - - // Helpers to serialize the association of Symbian SDK<->Qt - // to QSettings (pair of SDK/Qt). - static StringStringPairList readSdkQtAssociationSettings(const QSettings *settings, - const QString &group, - int *defaultIndex = 0); - void writeSdkQtAssociationSettings(QSettings *settings, const QString &group) const; - -private: - virtual void readSettings(); // empty stubs - virtual void writeSettings(); - - QList<Device> m_devices; -}; - -inline bool operator==(const S60Devices::Device &d1, const S60Devices::Device &d2) -{ return d1.equals(d2); } -inline bool operator!=(const S60Devices::Device &d1, const S60Devices::Device &d2) -{ return !d1.equals(d2); } - -// Autodetected Symbian Devices (as parsed from devices.xml file on Windows) -// with a manually set version of Qt. Currently not used, but might be by -// makefile-based builds on Windows. -class AutoDetectS60Devices : public S60Devices -{ - Q_OBJECT -public: - explicit AutoDetectS60Devices(QObject *parent = 0); - virtual bool detectDevices(); - QString errorString() const; - -private: - // Write and restore Qt-SDK associations. - virtual void readSettings(); - virtual void writeSettings(); - - QString m_errorString; -}; - -// Autodetected Symbian-Qt-Devices (with Qt installed -// into the SDK) for ABLD, Raptor. Completely autodetected. -class AutoDetectS60QtDevices : public AutoDetectS60Devices -{ - Q_OBJECT -public: - explicit AutoDetectS60QtDevices(QObject *parent = 0); - // Overwritten to detect associated Qt versions in addition. - virtual bool detectDevices(); - -private: - // No settings as it is completely autodetected. - virtual void readSettings() {} - virtual void writeSettings() {} - - bool detectQtForDevices(); -}; - -// Manually configured Symbian Devices completely based on QSettings. -class GnuPocS60Devices : public S60Devices -{ - Q_OBJECT -public: - explicit GnuPocS60Devices(QObject *parent = 0); - - static Device createDevice(const QString &epoc, const QString &qtDir); - -private: - virtual void readSettings(); - virtual void writeSettings(); -}; - -QDebug operator<<(QDebug dbg, const S60Devices::Device &d); -QDebug operator<<(QDebug dbg, const S60Devices &d); - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // S60DEVICES_H diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp deleted file mode 100644 index 0be75b506e0f2cd799390663fec221cb7b885a58..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** No Commercial Usage -** -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "s60devicespreferencepane.h" -#include "ui_s60devicespreferencepane.h" - -#include <qt4projectmanager/qt4projectmanagerconstants.h> - -#include <utils/qtcassert.h> -#include <coreplugin/coreconstants.h> - -#include <QtCore/QDir> -#include <QtCore/QtDebug> -#include <QtCore/QSharedPointer> - -#include <QtGui/QFileDialog> -#include <QtGui/QMessageBox> -#include <QtGui/QIcon> -#include <QtGui/QApplication> -#include <QtGui/QStyle> -#include <QtGui/QStandardItemModel> -#include <QtGui/QStandardItem> - -enum { deviceRole = Qt::UserRole + 1 }; - -enum Columns { DefaultColumn, EpocColumn, QtColumn, ColumnCount }; - -typedef QSharedPointer<Qt4ProjectManager::Internal::S60Devices::Device> DevicePtr; -Q_DECLARE_METATYPE(DevicePtr) - -typedef QList<QStandardItem *> StandardItemList; - -namespace Qt4ProjectManager { -namespace Internal { - -static inline DevicePtr deviceFromItem(const QStandardItem *item) -{ - return qvariant_cast<DevicePtr>(item->data(deviceRole)); -} - -// Device model storing a shared pointer to the device as user data. -// Provides a checkable 'default' column which works exclusively. -class S60DevicesModel : public QStandardItemModel { - Q_OBJECT -public: - typedef QList<S60Devices::Device> DeviceList; - - explicit S60DevicesModel(bool defaultColumnCheckable, QObject *parent = 0); - - void setDevices(const DeviceList &list); - DeviceList devices() const; - void appendDevice(const S60Devices::Device &device); - -private slots: - void slotItemChanged(QStandardItem *item); - -private: - const bool m_defaultColumnCheckable; -}; - -S60DevicesModel::S60DevicesModel(bool defaultColumnCheckable, QObject *parent) : - QStandardItemModel(0, ColumnCount, parent), - m_defaultColumnCheckable(defaultColumnCheckable) -{ - QStringList headers; - headers << S60DevicesBaseWidget::tr("Default") - << S60DevicesBaseWidget::tr("SDK Location") - << S60DevicesBaseWidget::tr("Qt Location"); - setHorizontalHeaderLabels(headers); - - if (m_defaultColumnCheckable) - connect(this, SIGNAL(itemChanged(QStandardItem*)), - this, SLOT(slotItemChanged(QStandardItem*))); -} - -void S60DevicesModel::appendDevice(const S60Devices::Device &device) -{ - // Create SDK/Qt column items with shared pointer to entry as data. - const QVariant deviceData = qVariantFromValue(DevicePtr(new S60Devices::Device(device))); - - const Qt::ItemFlags flags = Qt::ItemIsEnabled|Qt::ItemIsSelectable; - - QStandardItem *defaultItem = new QStandardItem; - if (m_defaultColumnCheckable) { - defaultItem->setCheckable(true); - defaultItem->setCheckState(device.isDefault ? Qt::Checked : Qt::Unchecked); - // Item is only checkable if it is not the default. - Qt::ItemFlags checkFlags = flags; - if (!device.isDefault) - checkFlags |= Qt::ItemIsUserCheckable; - defaultItem->setFlags(checkFlags); - } else { - defaultItem->setIcon(device.isDefault ? QIcon(QLatin1String(":/extensionsystem/images/ok.png")) : QIcon()); - } - - defaultItem->setData(deviceData); - - QStandardItem *epocItem = new QStandardItem(QDir::toNativeSeparators(device.epocRoot)); - epocItem->setFlags(flags); - epocItem->setData(deviceData); - - const QString qtDesc = device.qt.isEmpty() ? - S60DevicesModel::tr("No Qt installed") : - QDir::toNativeSeparators(device.qt); - QStandardItem *qtItem = new QStandardItem(qtDesc); - qtItem->setFlags(flags); - qtItem->setData(deviceData); - - const QString tooltip = device.toHtml(); - epocItem->setToolTip(tooltip); - qtItem->setToolTip(tooltip); - - StandardItemList row; - row << defaultItem << epocItem << qtItem; - appendRow(row); -} - -void S60DevicesModel::setDevices(const DeviceList &list) -{ - removeRows(0, rowCount()); - foreach(const S60Devices::Device &device, list) - appendDevice(device); -} - -S60DevicesModel::DeviceList S60DevicesModel::devices() const -{ - S60DevicesModel::DeviceList rc; - const int count = rowCount(); - for (int r = 0; r < count; r++) - rc.push_back(S60Devices::Device(*deviceFromItem(item(r, 0)))); - return rc; -} - -void S60DevicesModel::slotItemChanged(QStandardItem *changedItem) -{ - // Sync all "default" checkmarks. Emulate an exclusive group - // by enabling only the unchecked items (preventing the user from unchecking) - // and uncheck all other items. Protect against recursion. - if (changedItem->column() != DefaultColumn || changedItem->checkState() != Qt::Checked) - return; - const int row = changedItem->row(); - const int count = rowCount(); - for (int r = 0; r < count; r++) { - QStandardItem *rowItem = item(r, DefaultColumn); - if (r == row) { // Prevent uncheck. - rowItem->setFlags(rowItem->flags() & ~Qt::ItemIsUserCheckable); - deviceFromItem(rowItem)->isDefault = true; - } else { - // Uncheck others. - rowItem->setCheckState(Qt::Unchecked); - rowItem->setFlags(rowItem->flags() | Qt::ItemIsUserCheckable); - deviceFromItem(rowItem)->isDefault = false; - } - } -} - -// --------------- S60DevicesBaseWidget -S60DevicesBaseWidget::S60DevicesBaseWidget(unsigned flags, QWidget *parent) : - QWidget(parent), - m_ui(new Ui::S60DevicesPreferencePane), - m_model(new S60DevicesModel(flags & DeviceDefaultCheckable)) -{ - m_ui->setupUi(this); - connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addDevice())); - connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeDevice())); - connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); - connect(m_ui->changeQtButton, SIGNAL(clicked()), this, SLOT(changeQtVersion())); - - m_ui->list->setModel(m_model); - connect(m_ui->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(currentChanged(QModelIndex,QModelIndex))); - - m_ui->addButton->setVisible(flags & ShowAddButton); - m_ui->removeButton->setVisible(flags & ShowAddButton); - m_ui->removeButton->setEnabled(false); - m_ui->changeQtButton->setVisible(flags & ShowChangeQtButton); - m_ui->removeButton->setEnabled(false); - m_ui->refreshButton->setVisible(flags & ShowRefreshButton); -} - -S60DevicesBaseWidget::~S60DevicesBaseWidget() -{ - delete m_ui; - delete m_model; -} - -QStandardItem *S60DevicesBaseWidget::currentItem() const -{ - // Return the column-0 item. - QModelIndex current = m_ui->list->currentIndex(); - if (current.isValid()) { - if (current.row() != 0) - current = current.sibling(current.row(), 0); - return m_model->itemFromIndex(current); - } - return 0; -} - -S60DevicesBaseWidget::DeviceList S60DevicesBaseWidget::devices() const -{ - return m_model->devices(); -} - -void S60DevicesBaseWidget::setDevices(const DeviceList &s60devices, - const QString &errorString) -{ - m_model->setDevices(s60devices); - - for (int c = 0; c < ColumnCount; c++) - m_ui->list->resizeColumnToContents(c); - - if (errorString.isEmpty()) { - clearErrorLabel(); - } else { - setErrorLabel(errorString); - } -} - -void S60DevicesBaseWidget::changeQtVersion() -{ - if (const QStandardItem *item = currentItem()) { - const QString qtDir = promptDirectory(tr("Choose Qt folder")); - if (!qtDir.isEmpty()) { - const DevicePtr device = deviceFromItem(item); - device->qt = qtDir; - } - } -} - -void S60DevicesBaseWidget::removeDevice() -{ - if (const QStandardItem *item = currentItem()) - m_model->removeRows(item->row(), 1); -} - -void S60DevicesBaseWidget::currentChanged(const QModelIndex ¤t, - const QModelIndex & /* previous */) -{ - const bool hasItem = current.isValid(); - m_ui->changeQtButton->setEnabled(hasItem); - m_ui->removeButton->setEnabled(hasItem); -} - -void S60DevicesBaseWidget::setErrorLabel(const QString& t) -{ - m_ui->errorLabel->setText(t); - m_ui->errorLabel->setVisible(true); -} - -void S60DevicesBaseWidget::clearErrorLabel() -{ - m_ui->errorLabel->setVisible(false); -} - -QString S60DevicesBaseWidget::promptDirectory(const QString &title) -{ - return QFileDialog::getExistingDirectory(this, title); -} - -void S60DevicesBaseWidget::appendDevice(const S60Devices::Device &d) -{ - m_model->appendDevice(d); -} - -int S60DevicesBaseWidget::deviceCount() const -{ - return m_model->rowCount(); -} - -// ============ AutoDetectS60DevicesWidget - -AutoDetectS60DevicesWidget::AutoDetectS60DevicesWidget(QWidget *parent, - AutoDetectS60Devices *devices, - bool changeQtVersionEnabled) : - S60DevicesBaseWidget(ShowRefreshButton | (changeQtVersionEnabled ? unsigned(ShowChangeQtButton) : 0u), - parent), - m_devices(devices) -{ - refresh(); -} - -void AutoDetectS60DevicesWidget::refresh() -{ - m_devices->detectDevices(); - setDevices(m_devices->devices(), m_devices->errorString()); -} - -// ============ GnuPocS60DevicesWidget -GnuPocS60DevicesWidget::GnuPocS60DevicesWidget(QWidget *parent) : - S60DevicesBaseWidget(ShowAddButton|ShowRemoveButton|ShowChangeQtButton|DeviceDefaultCheckable, - parent) -{ -} - -void GnuPocS60DevicesWidget::addDevice() -{ - // 1) Prompt for GnuPoc - const QString epocRoot = promptDirectory(tr("Step 1 of 2: Choose GnuPoc folder")); - if (epocRoot.isEmpty()) - return; - // 2) Prompt for Qt. Catch equal inputs just in case someone clicks very rapidly. - QString qtDir; - while (true) { - qtDir = promptDirectory(tr("Step 2 of 2: Choose Qt folder")); - if (qtDir.isEmpty()) - return; - if (qtDir == epocRoot) { - QMessageBox::warning(this, tr("Adding GnuPoc"), - tr("GnuPoc and Qt folders must not be identical.")); - } else { - break; - } - } - // Add a device, make default if first. - S60Devices::Device device = GnuPocS60Devices::createDevice(epocRoot, qtDir); - if (deviceCount() == 0) - device.isDefault = true; - appendDevice(device); -} - -// ================= S60DevicesPreferencePane -S60DevicesPreferencePane::S60DevicesPreferencePane(S60Devices *devices, QObject *parent) - : Core::IOptionsPage(parent), - m_widget(0), - m_devices(devices) -{ -} - -S60DevicesPreferencePane::~S60DevicesPreferencePane() -{ -} - -QString S60DevicesPreferencePane::id() const -{ - return QLatin1String("Z.S60 SDKs"); -} - -QString S60DevicesPreferencePane::displayName() const -{ - return tr("S60 SDKs"); -} - -QString S60DevicesPreferencePane::category() const -{ - return QLatin1String(Constants::QT_SETTINGS_CATEGORY); -} - -QString S60DevicesPreferencePane::displayCategory() const -{ - return QCoreApplication::translate("Qt4ProjectManager", Constants::QT_SETTINGS_CATEGORY); -} - -QIcon S60DevicesPreferencePane::categoryIcon() const -{ - return QIcon(Constants::QT_SETTINGS_CATEGORY_ICON); -} - -S60DevicesBaseWidget *S60DevicesPreferencePane::createWidget(QWidget *parent) const -{ - // Symbian ABLD/Raptor: Qt installed into SDK, cannot change - if (AutoDetectS60QtDevices *aqd = qobject_cast<AutoDetectS60QtDevices *>(m_devices)) - return new AutoDetectS60DevicesWidget(parent, aqd, false); - // Not used yet: Manual association of Qt with auto-detected SDK - if (AutoDetectS60Devices *ad = qobject_cast<AutoDetectS60Devices *>(m_devices)) - return new AutoDetectS60DevicesWidget(parent, ad, true); - if (GnuPocS60Devices *gd = qobject_cast<GnuPocS60Devices*>(m_devices)) { - GnuPocS60DevicesWidget *gw = new GnuPocS60DevicesWidget(parent); - gw->setDevices(gd->devices()); - return gw; - } - return 0; // Huh? -} - -QWidget *S60DevicesPreferencePane::createPage(QWidget *parent) -{ - if (m_widget) - delete m_widget; - m_widget = createWidget(parent); - QTC_ASSERT(m_widget, return 0) - return m_widget; -} - -void S60DevicesPreferencePane::apply() -{ - if (!m_widget) // page was never shown - return; - - m_devices->setDevices(m_widget->devices()); -} - -void S60DevicesPreferencePane::finish() -{ -} - -} // namespace Internal -} // namespace Qt4ProjectManager - -#include "s60devicespreferencepane.moc" diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h deleted file mode 100644 index 2c4340245824acfcace7542c3504c2f628633f66..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.h +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** No Commercial Usage -** -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef S60DEVICESPREFERENCEPANE_H -#define S60DEVICESPREFERENCEPANE_H - -#include "s60devices.h" -#include <coreplugin/dialogs/ioptionspage.h> - -#include <QtCore/QPointer> -#include <QtGui/QWidget> - -QT_BEGIN_NAMESPACE -class QStandardItem; -class QAbstractButton; -class QModelIndex; -QT_END_NAMESPACE - -namespace Qt4ProjectManager { -namespace Internal { -class AutoDetectS60Devices; -class GnuPocS60Devices; -class S60DevicesModel; - -namespace Ui { - class S60DevicesPreferencePane; -} - -// Base pane listing Symbian SDKs with "Change Qt" version functionality. -class S60DevicesBaseWidget : public QWidget -{ - Q_OBJECT -public: - typedef QList<S60Devices::Device> DeviceList; - - enum Flags { ShowAddButton = 0x1, ShowRemoveButton = 0x2, - ShowChangeQtButton =0x4, ShowRefreshButton = 0x8, - DeviceDefaultCheckable = 0x10 }; - - virtual ~S60DevicesBaseWidget(); - - DeviceList devices() const; - void setDevices(const DeviceList &dl, const QString &errorString = QString()); - -protected: - explicit S60DevicesBaseWidget(unsigned flags, QWidget *parent = 0); - - void setErrorLabel(const QString&); - void clearErrorLabel(); - - QString promptDirectory(const QString &title); - void appendDevice(const S60Devices::Device &d); - int deviceCount() const; - - QStandardItem *currentItem() const; - -private slots: - void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); - void changeQtVersion(); - void removeDevice(); - virtual void addDevice() {} // Default does nothing - virtual void refresh() {} // Default does nothing - -private: - Ui::S60DevicesPreferencePane *m_ui; - S60DevicesModel *m_model; -}; - -// Widget for autodetected SDK's showing a refresh button. -class AutoDetectS60DevicesWidget : public S60DevicesBaseWidget -{ - Q_OBJECT -public: - explicit AutoDetectS60DevicesWidget(QWidget *parent, - AutoDetectS60Devices *devices, - bool changeQtVersionEnabled); - -private slots: - virtual void refresh(); - -private: - AutoDetectS60Devices *m_devices; -}; - -// Widget for manually configured SDK's showing a add/remove buttons. -class GnuPocS60DevicesWidget : public S60DevicesBaseWidget -{ - Q_OBJECT -public: - explicit GnuPocS60DevicesWidget(QWidget *parent = 0); - -private slots: - virtual void addDevice(); -}; - -// Options Pane. -class S60DevicesPreferencePane : public Core::IOptionsPage -{ - Q_OBJECT -public: - explicit S60DevicesPreferencePane(S60Devices *devices, QObject *parent = 0); - ~S60DevicesPreferencePane(); - - QString id() const; - QString displayName() const; - QString category() const; - QString displayCategory() const; - QIcon categoryIcon() const; - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -private: - S60DevicesBaseWidget *createWidget(QWidget *parent) const; - - QPointer<S60DevicesBaseWidget> m_widget; - S60Devices *m_devices; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // S60DEVICESPREFERENCEPANE_H diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui b/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui deleted file mode 100644 index 081924ca2ebb4103cecb7ce7a2f0cd38c9251f24..0000000000000000000000000000000000000000 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicespreferencepane.ui +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qt4ProjectManager::Internal::S60DevicesPreferencePane</class> - <widget class="QWidget" name="Qt4ProjectManager::Internal::S60DevicesPreferencePane"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>366</width> - <height>231</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="list"> - <property name="indentation"> - <number>0</number> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="uniformRowHeights"> - <bool>true</bool> - </property> - <property name="allColumnsShowFocus"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="buttonLayout"> - <item> - <widget class="QPushButton" name="refreshButton"> - <property name="toolTip"> - <string>Refresh</string> - </property> - <property name="text"> - <string>Refresh</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="addButton"> - <property name="toolTip"> - <string>Add</string> - </property> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="toolTip"> - <string>Remove</string> - </property> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="changeQtButton"> - <property name="toolTip"> - <string>Change Qt version</string> - </property> - <property name="text"> - <string>Change Qt Version</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="errorLabel"> - <property name="styleSheet"> - <string notr="true">background-color: red;</string> - </property> - <property name="text"> - <string>Error</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp index 1275b7aad10814023cd4244603ed4b6cd9095ed7..343c23e9dd4d5ea9f9a30cc402341f01ebba2a96 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp @@ -187,7 +187,7 @@ QString S60EmulatorRunConfiguration::executable() const { Qt4BuildConfiguration *qt4bc = qt4Target()->activeBuildConfiguration(); QtVersion *qtVersion = qt4bc->qtVersion(); - QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot; + QString baseDir = qtVersion->systemRoot(); QString qmakeBuildConfig = "urel"; if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) qmakeBuildConfig = "udeb"; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp index 9a5e7b5d69f988e1761d63cd720d6f5e42418044..12473c14036b2e0613e77e086122156065ee1e60 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp @@ -32,9 +32,9 @@ **************************************************************************/ #include "s60manager.h" -#include "qtversionmanager.h" +//#include "qtversionmanager.h" -#include "s60devicespreferencepane.h" +//#include "s60devicespreferencepane.h" #include "s60emulatorrunconfiguration.h" #include "s60devicerunconfiguration.h" #include "s60createpackagestep.h" @@ -60,10 +60,6 @@ #include <QtCore/QDir> -namespace { - const char S60_AUTODETECTION_SOURCE[] = "QTS60"; -} - namespace Qt4ProjectManager { namespace Internal { @@ -109,8 +105,7 @@ private: S60Manager *S60Manager::instance() { return m_instance; } -S60Manager::S60Manager(QObject *parent) - : QObject(parent), m_devices(S60Devices::createS60Devices(this)) +S60Manager::S60Manager(QObject *parent) : QObject(parent) { m_instance = this; @@ -118,10 +113,6 @@ S60Manager::S60Manager(QObject *parent) addAutoReleasedObject(new RvctToolChainFactory); addAutoReleasedObject(new WinscwToolChainFactory); -#ifdef QTCREATOR_WITH_S60 - addAutoReleasedObject(new S60DevicesPreferencePane(m_devices, this)); -#endif - addAutoReleasedObject(new S60EmulatorRunConfigurationFactory); addAutoReleasedObject(new RunControlFactory<S60EmulatorRunControl, S60EmulatorRunConfiguration> (QLatin1String(ProjectExplorer::Constants::RUNMODE), @@ -137,9 +128,6 @@ S60Manager::S60Manager(QObject *parent) addAutoReleasedObject(new S60PublishingWizardFactoryOvi); - updateQtVersions(); - connect(m_devices, SIGNAL(qtVersionsChanged()), - this, SLOT(updateQtVersions())); connect(Core::ICore::instance()->mainWindow(), SIGNAL(deviceChange()), SymbianUtils::SymbianDeviceManager::instance(), SLOT(update())); } @@ -167,108 +155,5 @@ void S60Manager::addAutoReleasedObject(QObject *o) m_pluginObjects.push_back(o); } -QString S60Manager::deviceIdFromDetectionSource(const QString &autoDetectionSource) const -{ - if (autoDetectionSource.startsWith(S60_AUTODETECTION_SOURCE)) - return autoDetectionSource.mid(QString(S60_AUTODETECTION_SOURCE).length()+1); - return QString(); -} - -static inline QString qmakeFromQtDir(const QString &qtDir) -{ - QString qmake = qtDir + QLatin1String("/bin/qmake"); -#ifdef Q_OS_WIN - qmake += QLatin1String(".exe"); -#endif - return qmake; -} - -void S60Manager::updateQtVersions() -{ - // This assumes that the QtVersionManager has already read - // the Qt versions from the settings - QtVersionManager *versionManager = QtVersionManager::instance(); - QList<QtVersion *> versions = versionManager->versions(); - QList<QtVersion *> handledVersions; - QList<QtVersion *> versionsToAdd; - foreach (const S60Devices::Device &device, m_devices->devices()) { - if (device.qt.isEmpty()) // no Qt version found for this sdk - continue; - QtVersion *deviceVersion = 0; - // look if we have a respective Qt version already - foreach (QtVersion *version, versions) { - if (version->isAutodetected() - && deviceIdFromDetectionSource(version->autodetectionSource()) == device.id) { - deviceVersion = version; - break; - } - } - if (deviceVersion) { - deviceVersion->setQMakeCommand(qmakeFromQtDir(device.qt)); - deviceVersion->setDisplayName(QString("%1 (Qt %2)").arg(device.id, deviceVersion->qtVersionString())); - handledVersions.append(deviceVersion); - } else { - deviceVersion = new QtVersion(QString("%1 (Qt %2)").arg(device.id), qmakeFromQtDir(device.qt), - true, QString("%1.%2").arg(S60_AUTODETECTION_SOURCE, device.id)); - deviceVersion->setDisplayName(deviceVersion->displayName().arg(deviceVersion->qtVersionString())); - versionsToAdd.append(deviceVersion); - } - deviceVersion->setS60SDKDirectory(device.epocRoot); - } - // remove old autodetected versions - foreach (QtVersion *version, versions) { - if (version->isAutodetected() - && version->autodetectionSource().startsWith(S60_AUTODETECTION_SOURCE) - && !handledVersions.contains(version)) { - versionManager->removeVersion(version); - } - } - // add new versions - foreach (QtVersion *version, versionsToAdd) { - versionManager->addVersion(version); - } -} - -S60Devices::Device S60Manager::deviceForQtVersion(const Qt4ProjectManager::QtVersion *version) const -{ - Q_ASSERT(version); - S60Devices::Device device; - QString deviceId; - if (version->isAutodetected()) - deviceId = deviceIdFromDetectionSource(version->autodetectionSource()); - if (deviceId.isEmpty()) { // it's not an s60 autodetected version - // try to find a device entry belonging to the root given in Qt prefs - QString sdkRoot = version->s60SDKDirectory(); - if (sdkRoot.isEmpty()) { // no sdk explicitly set in the preferences - // check if EPOCROOT is set and use that - QString epocRootEnv = QProcessEnvironment::systemEnvironment() - .value(QLatin1String("EPOCROOT")); - if (!epocRootEnv.isEmpty()) - sdkRoot = QDir::fromNativeSeparators(epocRootEnv); - } - if (sdkRoot.isEmpty()) { // no sdk set via preference or EPOCROOT - // try default device - device = m_devices->defaultDevice(); - } else { - device = m_devices->deviceForEpocRoot(sdkRoot); - } - if (device.epocRoot.isEmpty()) { // no device found - // check if we can construct a dummy one - if (QFile::exists(QString::fromLatin1("%1/epoc32").arg(sdkRoot))) { - device.epocRoot = sdkRoot; - device.toolsRoot = device.epocRoot; - device.isDefault = false; - device.name = QString::fromLatin1("Manual"); - device.id = QString::fromLatin1("Manual"); - } - } - // override any Qt version that might be still autodetected - device.qt = QFileInfo(QFileInfo(version->qmakeCommand()).path()).path(); - } else { - device = m_devices->deviceForId(deviceId); - } - return device; -} - } // namespace internal } // namespace qt4projectmanager diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.h b/src/plugins/qt4projectmanager/qt-s60/s60manager.h index a4460bcedb73d456770358f907f08234f62d9055..58c512a888cb8e1c5b39b230d6912c4a54ace700 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.h @@ -34,8 +34,6 @@ #ifndef S60MANAGER_H #define S60MANAGER_H -#include "s60devices.h" - #include <QtCore/QObject> namespace ProjectExplorer { @@ -43,9 +41,7 @@ class ToolChain; } namespace Qt4ProjectManager { -class QtVersion; namespace Internal { -class S60Devices; class S60Manager : public QObject { @@ -55,21 +51,12 @@ public: ~S60Manager(); static S60Manager *instance(); - S60Devices *devices() const { return m_devices; } - S60Devices::Device deviceForQtVersion(const Qt4ProjectManager::QtVersion *version) const; - QString deviceIdFromDetectionSource(const QString &autoDetectionSource) const; - static QString platform(const ProjectExplorer::ToolChain *tc); -private slots: - void updateQtVersions(); - private: void addAutoReleasedObject(QObject *p); static S60Manager *m_instance; - - S60Devices *m_devices; QObjectList m_pluginObjects; }; diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index 80cb33f4d69fbbe08c8f53802c1e1f96c115c6cb..6ad45d75f3f2c389c3f7e4694b49e2052f7a6f7b 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -592,7 +592,7 @@ void QtOptionsPageWidget::updateState() m_versionUi->nameEdit->setEnabled(enabled && !isAutodetected); m_versionUi->qmakePath->setEnabled(enabled && !isAutodetected); bool s60SDKPathEnabled = enabled && - (isAutodetected ? version->s60SDKDirectory().isEmpty() : true); + (isAutodetected ? version->systemRoot().isEmpty() : true); m_versionUi->s60SDKPath->setEnabled(s60SDKPathEnabled); updateDebuggingHelperUi(); @@ -628,7 +628,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) if (qtAbi.os() == ProjectExplorer::Abi::SymbianOS) { makeS60Visible(true); - m_versionUi->s60SDKPath->setPath(QDir::toNativeSeparators(m_versions.at(index)->s60SDKDirectory())); + m_versionUi->s60SDKPath->setPath(QDir::toNativeSeparators(m_versions.at(index)->systemRoot())); m_versionUi->sbsV2Path->setPath(m_versions.at(index)->sbsV2Directory()); m_versionUi->sbsV2Path->setEnabled(m_versions.at(index)->isBuildWithSymbianSbsV2()); } @@ -776,8 +776,7 @@ void QtOptionsPageWidget::updateCurrentS60SDKDirectory() int currentItemIndex = indexForTreeItem(currentItem); if (currentItemIndex < 0) return; - m_versions[currentItemIndex]->setS60SDKDirectory( - QDir::fromNativeSeparators(m_versionUi->s60SDKPath->path())); + m_versions[currentItemIndex]->setSystemRoot(m_versionUi->s60SDKPath->path()); } void QtOptionsPageWidget::updateCurrentSbsV2Directory() @@ -787,8 +786,7 @@ void QtOptionsPageWidget::updateCurrentSbsV2Directory() int currentItemIndex = indexForTreeItem(currentItem); if (currentItemIndex < 0) return; - m_versions[currentItemIndex]->setSbsV2Directory( - QDir::fromNativeSeparators(m_versionUi->sbsV2Path->path())); + m_versions[currentItemIndex]->setSbsV2Directory(m_versionUi->sbsV2Path->path()); } QList<QtVersion *> QtOptionsPageWidget::versions() const diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 3a1e107c74a4c2db894d5da30077af6c479d0f21..bae2bf390fef684d0a842e2cce98738e35e75f4e 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -171,7 +171,7 @@ QtVersionManager::QtVersionManager() id, isAutodetected, autodetectionSource); - version->setS60SDKDirectory(s->value("S60SDKDirectory").toString()); + version->setSystemRoot(s->value("S60SDKDirectory").toString()); version->setSbsV2Directory(s->value(QLatin1String("SBSv2Directory")).toString()); // Update from 2.1 or earlier: @@ -213,12 +213,8 @@ QtVersionManager::QtVersionManager() addNewVersionsFromInstaller(); updateSystemVersion(); - writeVersionsIntoSettings(); - - updateDocumentation(); - // cannot call from ctor, needs to get connected extenernally first - QTimer::singleShot(0, this, SLOT(updateExamples())); + QTimer::singleShot(0, this, SLOT(updateSettings())); } QtVersionManager::~QtVersionManager() @@ -300,8 +296,12 @@ void QtVersionManager::updateDocumentation() helpManager->registerDocumentation(files); } -void QtVersionManager::updateExamples() +void QtVersionManager::updateSettings() { + writeVersionsIntoSettings(); + + updateDocumentation(); + QtVersion *version = 0; QList<QtVersion*> candidates; @@ -367,7 +367,7 @@ void QtVersionManager::writeVersionsIntoSettings() s->setValue("isAutodetected", version->isAutodetected()); if (version->isAutodetected()) s->setValue("autodetectionSource", version->autodetectionSource()); - s->setValue("S60SDKDirectory", version->s60SDKDirectory()); + s->setValue("S60SDKDirectory", version->systemRoot()); s->setValue(QLatin1String("SBSv2Directory"), version->sbsV2Directory()); ++it; } @@ -444,7 +444,7 @@ void QtVersionManager::addNewVersionsFromInstaller() if (QFile::exists(newVersionData[1])) { QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ ); if (newVersionData.count() >= 3) - version->setS60SDKDirectory(QDir::fromNativeSeparators(newVersionData[2])); + version->setSystemRoot(QDir::fromNativeSeparators(newVersionData[2])); if (newVersionData.count() >= 4) version->setSbsV2Directory(QDir::fromNativeSeparators(newVersionData[3])); @@ -573,7 +573,7 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions) if (!changedVersions.isEmpty()) updateDocumentation(); - updateExamples(); + updateSettings(); writeVersionsIntoSettings(); if (!changedVersions.isEmpty()) @@ -1333,38 +1333,17 @@ QString QtVersion::qmlviewerCommand() const return m_qmlviewerCommand; } -QString QtVersion::systemRoot() const +void QtVersion::setSystemRoot(const QString &root) { - if (m_systemRoot.isNull()) { - if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID) - || supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) { - S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(this); - - m_systemRoot = device.epocRoot; - if (!m_systemRoot.endsWith(QLatin1Char('/'))) - m_systemRoot.append(QLatin1Char('/')); + if (root == m_systemRoot) + return; + m_systemRoot = root; + m_abiUpToDate = false; +} - } else if (supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) || - supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID)) { - QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(this)) - + 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")) { - m_systemRoot = MaemoGlobal::maddeRoot(this) - + QLatin1String("/sysroots/") + list.at(1); - } - } - } - } - if (m_systemRoot.isNull()) - m_systemRoot = QLatin1String(""); - } +QString QtVersion::systemRoot() const +{ + updateAbiAndMkspec(); return m_systemRoot; } @@ -1392,6 +1371,8 @@ void QtVersion::updateAbiAndMkspec() const if (m_id == -1 || m_abiUpToDate) return; + m_abiUpToDate = true; + m_targetIds.clear(); m_abis.clear(); @@ -1570,9 +1551,35 @@ void QtVersion::updateAbiAndMkspec() const m_targetIds.clear(); m_targetIds.insert(QLatin1String(Constants::QT_SIMULATOR_TARGET_ID)); } - ProFileCacheManager::instance()->decRefCount(); - m_abiUpToDate = true; + + // Set up systemroot + if (supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) + || supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID)) { + if (m_systemRoot.isNull()) { + QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(this)) + + 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")) { + m_systemRoot = MaemoGlobal::maddeRoot(this) + + QLatin1String("/sysroots/") + list.at(1); + } + } + } + } + } else if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID) + || supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) { + if (!m_systemRoot.endsWith(QLatin1Char('/'))) + m_systemRoot.append(QLatin1Char('/')); + } else { + m_systemRoot = QLatin1String(""); + } } QString QtVersion::resolveLink(const QString &path) const @@ -1622,17 +1629,6 @@ QString QtVersion::qtCorePath() const return QString(); } -QString QtVersion::s60SDKDirectory() const -{ - return m_s60SDKDirectory; -} - -void QtVersion::setS60SDKDirectory(const QString &directory) -{ - m_s60SDKDirectory = directory; - m_abiUpToDate = false; -} - QString QtVersion::sbsV2Directory() const { return m_sbsV2Directory; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 13c762be3eb912e4abaa6bed1b28511834361552..a73423d4c3aef6fe7844a1bf89c3cbc8811a52b7 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -109,6 +109,7 @@ public: QString linguistCommand() const; QString qmlviewerCommand() const; QString systemRoot() const; + void setSystemRoot(const QString &); bool supportsTargetId(const QString &id) const; QSet<QString> supportedTargetIds() const; @@ -132,8 +133,6 @@ public: // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information QHash<QString,QString> versionInfo() const; - QString s60SDKDirectory() const; - void setS60SDKDirectory(const QString &directory); QString sbsV2Directory() const; void setSbsV2Directory(const QString &directory); @@ -213,7 +212,6 @@ private: mutable bool m_hasQmlDebuggingLibrary; // controlled by m_versionInfoUpdate mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate - QString m_s60SDKDirectory; QString m_sbsV2Directory; mutable QString m_systemRoot; @@ -297,7 +295,7 @@ signals: void updateExamples(QString, QString, QString); private slots: - void updateExamples(); + void updateSettings(); private: // This function is really simplistic... static bool equals(QtVersion *a, QtVersion *b);