RemoteLinux: Make mapping between targets and devices more flexible.

Until now, the mapping was based exclusively on the device type. The new
approach is more flexible and less static, allowing e.g. the set of
supported devices to depend on the current build settings.

Change-Id: Iec92bdf9fee647477b166f7624c2364a821e5cbd
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2012-03-19 17:35:44 +01:00
parent 63244127a8
commit 5ef51887db
12 changed files with 92 additions and 67 deletions

View File

@@ -147,7 +147,7 @@ void MaemoDeployConfigurationWidget::addIcon()
{
DeployableFilesPerProFile * const proFileInfo = m_remoteLinuxWidget->currentModel();
const int iconDim
= MaemoGlobal::applicationIconSize(deployConfiguration()->target()->supportedDeviceType());
= MaemoGlobal::applicationIconSize(deployConfiguration()->target());
const QString origFilePath = QFileDialog::getOpenFileName(this,
tr("Choose Icon (will be scaled to %1x%1 pixels, if necessary)").arg(iconDim),
proFileInfo->projectDir(), QLatin1String("(*.png)"));
@@ -212,7 +212,7 @@ QString MaemoDeployConfigurationWidget::remoteIconFilePath(const DeployableFiles
QString MaemoDeployConfigurationWidget::remoteIconDir() const
{
return QString::fromLatin1("/usr/share/icons/hicolor/%1x%1/apps")
.arg(MaemoGlobal::applicationIconSize(deployConfiguration()->target()->supportedDeviceType()));
.arg(MaemoGlobal::applicationIconSize(deployConfiguration()->target()));
}
} // namespace Internal

View File

@@ -33,6 +33,7 @@
#include "maemoconstants.h"
#include "maemoqemumanager.h"
#include "qt4maemotarget.h"
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qtsupport/baseqtversion.h>
@@ -127,9 +128,9 @@ QString MaemoGlobal::devrootshPath()
return QLatin1String("/usr/lib/mad-developer/devrootsh");
}
int MaemoGlobal::applicationIconSize(const QString &deviceType)
int MaemoGlobal::applicationIconSize(const ProjectExplorer::Target *target)
{
return deviceType == QLatin1String(HarmattanOsType) ? 80 : 64;
return qobject_cast<const Qt4HarmattanTarget *>(target) ? 80 : 64;
}
QString MaemoGlobal::remoteSudo(const QString &deviceType, const QString &uname)

View File

@@ -45,13 +45,9 @@ class QProcess;
class QString;
QT_END_NAMESPACE
namespace QtSupport {
class BaseQtVersion;
}
namespace RemoteLinux {
class LinuxDeviceConfiguration;
}
namespace QtSupport { class BaseQtVersion; }
namespace RemoteLinux { class LinuxDeviceConfiguration; }
namespace ProjectExplorer { class Target; }
namespace Madde {
namespace Internal {
@@ -97,7 +93,7 @@ public:
static QString homeDirOnDevice(const QString &uname);
static QString devrootshPath();
static int applicationIconSize(const QString &deviceType);
static int applicationIconSize(const ProjectExplorer::Target *target);
static QString remoteSudo(const QString &deviceType, const QString &uname);
static QString remoteSourceProfilesCommand();
static Utils::PortList freePorts(const QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> &devConf,

View File

@@ -122,8 +122,8 @@ bool adaptTagValue(QByteArray &document, const QByteArray &fieldName,
AbstractQt4MaemoTarget::AbstractQt4MaemoTarget(Qt4Project *parent, const QString &id,
const QString &supportedDeviceType, const QString &qmakeScope) :
AbstractEmbeddedLinuxTarget(parent, id, supportedDeviceType),
const QString &qmakeScope) :
AbstractEmbeddedLinuxTarget(parent, id),
m_filesWatcher(new Utils::FileSystemWatcher(this)),
m_deploymentSettingsAssistant(new DeploymentSettingsAssistant(qmakeScope,
QLatin1String("/opt"), deploymentInfo())),
@@ -375,8 +375,8 @@ void AbstractQt4MaemoTarget::raiseError(const QString &reason)
}
AbstractDebBasedQt4MaemoTarget::AbstractDebBasedQt4MaemoTarget(Qt4Project *parent,
const QString &id, const QString &supportedDeviceType, const QString &qmakeScope)
: AbstractQt4MaemoTarget(parent, id, supportedDeviceType, qmakeScope)
const QString &id, const QString &qmakeScope)
: AbstractQt4MaemoTarget(parent, id, qmakeScope)
{
}
@@ -958,8 +958,8 @@ QString AbstractDebBasedQt4MaemoTarget::shortDayOfWeekName(const QDateTime &dt)
AbstractRpmBasedQt4MaemoTarget::AbstractRpmBasedQt4MaemoTarget(Qt4Project *parent,
const QString &id, const QString &supportedDeviceType, const QString &qmakeScope)
: AbstractQt4MaemoTarget(parent, id, supportedDeviceType, qmakeScope)
const QString &id, const QString &qmakeScope)
: AbstractQt4MaemoTarget(parent, id, qmakeScope)
{
}
@@ -1124,14 +1124,18 @@ bool AbstractRpmBasedQt4MaemoTarget::setValueForTag(const QByteArray &tag,
}
Qt4Maemo5Target::Qt4Maemo5Target(Qt4Project *parent, const QString &id)
: AbstractDebBasedQt4MaemoTarget(parent, id, QLatin1String(Maemo5OsType),
QLatin1String("maemo5"))
: AbstractDebBasedQt4MaemoTarget(parent, id, QLatin1String("maemo5"))
{
setDisplayName(defaultDisplayName());
}
Qt4Maemo5Target::~Qt4Maemo5Target() {}
bool Qt4Maemo5Target::supportsDevice(const ProjectExplorer::IDevice::ConstPtr &device) const
{
return device->type() == QLatin1String(Maemo5OsType);
}
QString Qt4Maemo5Target::defaultDisplayName()
{
return QApplication::translate("Qt4ProjectManager::Qt4Target", "Maemo5",
@@ -1164,14 +1168,18 @@ QByteArray Qt4Maemo5Target::defaultSection() const
}
Qt4HarmattanTarget::Qt4HarmattanTarget(Qt4Project *parent, const QString &id)
: AbstractDebBasedQt4MaemoTarget(parent, id, QLatin1String(HarmattanOsType),
QLatin1String("contains(MEEGO_EDITION,harmattan)"))
: AbstractDebBasedQt4MaemoTarget(parent, id, QLatin1String("contains(MEEGO_EDITION,harmattan)"))
{
setDisplayName(defaultDisplayName());
}
Qt4HarmattanTarget::~Qt4HarmattanTarget() {}
bool Qt4HarmattanTarget::supportsDevice(const ProjectExplorer::IDevice::ConstPtr &device) const
{
return device->type() == QLatin1String(HarmattanOsType);
}
QString Qt4HarmattanTarget::defaultDisplayName()
{
return QApplication::translate("Qt4ProjectManager::Qt4Target", "Harmattan",
@@ -1235,7 +1243,7 @@ QByteArray Qt4HarmattanTarget::defaultSection() const
Qt4MeegoTarget::Qt4MeegoTarget(Qt4Project *parent, const QString &id)
: AbstractRpmBasedQt4MaemoTarget(parent, id, QLatin1String(MeeGoOsType),
: AbstractRpmBasedQt4MaemoTarget(parent, id,
QLatin1String("!isEmpty(MEEGO_VERSION_MAJOR):!contains(MEEGO_EDITION,harmattan)"))
{
setDisplayName(defaultDisplayName());
@@ -1243,6 +1251,11 @@ Qt4MeegoTarget::Qt4MeegoTarget(Qt4Project *parent, const QString &id)
Qt4MeegoTarget::~Qt4MeegoTarget() {}
bool Qt4MeegoTarget::supportsDevice(const ProjectExplorer::IDevice::ConstPtr &device) const
{
return device->type() == QLatin1String(MeeGoOsType);
}
QString Qt4MeegoTarget::defaultDisplayName()
{
return QApplication::translate("Qt4ProjectManager::Qt4Target",

View File

@@ -57,7 +57,7 @@ class AbstractQt4MaemoTarget : public RemoteLinux::AbstractEmbeddedLinuxTarget
Q_OBJECT
public:
explicit AbstractQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id,
const QString &supportedDeviceType, const QString &qmakeScope);
const QString &qmakeScope);
virtual ~AbstractQt4MaemoTarget();
void createApplicationProFiles(bool reparse);
@@ -120,7 +120,7 @@ class AbstractDebBasedQt4MaemoTarget : public AbstractQt4MaemoTarget
Q_OBJECT
public:
AbstractDebBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id,
const QString &supportedDeviceType, const QString &qmakeScope);
const QString &qmakeScope);
~AbstractDebBasedQt4MaemoTarget();
QString debianDirPath() const;
@@ -193,7 +193,7 @@ class AbstractRpmBasedQt4MaemoTarget : public AbstractQt4MaemoTarget
Q_OBJECT
public:
AbstractRpmBasedQt4MaemoTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id,
const QString &supportedDeviceType, const QString &qmakeScope);
const QString &qmakeScope);
~AbstractRpmBasedQt4MaemoTarget();
virtual bool allowsRemoteMounts() const { return false; }
@@ -240,6 +240,8 @@ public:
const QString &id);
virtual ~Qt4Maemo5Target();
virtual bool supportsDevice(const QSharedPointer<const ProjectExplorer::IDevice> &device) const;
virtual bool allowsRemoteMounts() const { return true; }
virtual bool allowsPackagingDisabling() const { return true; }
virtual bool allowsQmlDebugging() const { return false; }
@@ -264,6 +266,8 @@ public:
const QString &id);
virtual ~Qt4HarmattanTarget();
virtual bool supportsDevice(const QSharedPointer<const ProjectExplorer::IDevice> &device) const;
virtual bool allowsRemoteMounts() const { return false; }
virtual bool allowsPackagingDisabling() const { return false; }
virtual bool allowsQmlDebugging() const { return true; }
@@ -289,6 +293,7 @@ public:
explicit Qt4MeegoTarget(Qt4ProjectManager::Qt4Project *parent,
const QString &id);
virtual ~Qt4MeegoTarget();
virtual bool supportsDevice(const QSharedPointer<const ProjectExplorer::IDevice> &device) const;
static QString defaultDisplayName();
private:
virtual QString specFileName() const;

View File

@@ -41,14 +41,11 @@ using namespace Qt4ProjectManager;
namespace RemoteLinux {
AbstractEmbeddedLinuxTarget::AbstractEmbeddedLinuxTarget(Qt4Project *parent, const QString &id,
const QString &supportedDeviceType) :
AbstractEmbeddedLinuxTarget::AbstractEmbeddedLinuxTarget(Qt4Project *parent, const QString &id) :
Qt4BaseTarget(parent, id),
m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)),
m_supportedDeviceType(supportedDeviceType),
m_deploymentInfo(new DeploymentInfo(this)),
m_deviceConfigModel(new Internal::TypeSpecificDeviceConfigurationListModel(supportedDeviceType,
this))
m_deviceConfigModel(new Internal::TypeSpecificDeviceConfigurationListModel(this))
{
}

View File

@@ -36,9 +36,13 @@
#include <qt4projectmanager/qt4target.h>
#include <QSharedPointer>
#include <QString>
namespace ProjectExplorer { class IBuildConfigurationFactory; }
namespace ProjectExplorer {
class IBuildConfigurationFactory;
class IDevice;
}
namespace Qt4ProjectManager { class Qt4BuildConfigurationFactory; }
namespace RemoteLinux {
@@ -49,20 +53,21 @@ class REMOTELINUX_EXPORT AbstractEmbeddedLinuxTarget : public Qt4ProjectManager:
{
Q_OBJECT
public:
AbstractEmbeddedLinuxTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id,
const QString &supportedDeviceType);
AbstractEmbeddedLinuxTarget(Qt4ProjectManager::Qt4Project *parent, const QString &id);
ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;
QString supportedDeviceType() const { return m_supportedDeviceType; }
DeploymentInfo *deploymentInfo() const { return m_deploymentInfo; }
Internal::TypeSpecificDeviceConfigurationListModel *deviceConfigModel() const {
return m_deviceConfigModel;
}
virtual bool supportsDevice(const QSharedPointer<const ProjectExplorer::IDevice> &device) const = 0;
signals:
void supportedDevicesChanged();
private:
Qt4ProjectManager::Qt4BuildConfigurationFactory * const m_buildConfigurationFactory;
const QString m_supportedDeviceType;
DeploymentInfo * const m_deploymentInfo;
Internal::TypeSpecificDeviceConfigurationListModel * const m_deviceConfigModel;
};

View File

@@ -36,6 +36,7 @@
#include "remotelinuxrunconfiguration.h"
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4nodes.h>
#include <qt4projectmanager/qt4project.h>
@@ -47,8 +48,7 @@ namespace RemoteLinux {
namespace Internal {
GenericEmbeddedLinuxTarget::GenericEmbeddedLinuxTarget(Qt4ProjectManager::Qt4Project *parent,
const QString &id) :
AbstractEmbeddedLinuxTarget(parent, id, QLatin1String(Constants::GenericLinuxOsType))
const QString &id) : AbstractEmbeddedLinuxTarget(parent, id)
{
setDisplayName(tr("Embedded Linux"));
}
@@ -71,6 +71,11 @@ Utils::FileName GenericEmbeddedLinuxTarget::mkspec(const Qt4ProjectManager::Qt4B
return version->mkspec();
}
bool GenericEmbeddedLinuxTarget::supportsDevice(const ProjectExplorer::IDevice::ConstPtr &device) const
{
return device->type() == QLatin1String(Constants::GenericLinuxOsType);
}
void GenericEmbeddedLinuxTarget::createApplicationProFiles(bool reparse)
{
if (!reparse)

View File

@@ -50,6 +50,7 @@ public:
void createApplicationProFiles(bool reparse);
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Node *n);
Utils::FileName mkspec(const Qt4ProjectManager::Qt4BuildConfiguration *bc) const;
bool supportsDevice(const QSharedPointer<const ProjectExplorer::IDevice> &device) const;
private:
friend class EmbeddedLinuxTargetFactory;

View File

@@ -82,7 +82,7 @@ RemoteLinuxDeployConfiguration::~RemoteLinuxDeployConfiguration()
void RemoteLinuxDeployConfiguration::initialize()
{
d->deviceConfiguration = target()->deviceConfigModel()->defaultDeviceConfig();
connect(target()->deviceConfigModel(), SIGNAL(updated()),
connect(target()->deviceConfigModel(), SIGNAL(modelReset()),
SLOT(handleDeviceConfigurationListUpdated()));
}

View File

@@ -31,20 +31,22 @@
**************************************************************************/
#include "typespecificdeviceconfigurationlistmodel.h"
#include "remotelinux_constants.h"
#include "abstractembeddedlinuxtarget.h"
#include <projectexplorer/devicesupport/devicemanager.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
TypeSpecificDeviceConfigurationListModel::TypeSpecificDeviceConfigurationListModel(const QString &deviceType,
QObject *parent) : QAbstractListModel(parent), m_targetDeviceType(deviceType)
TypeSpecificDeviceConfigurationListModel::TypeSpecificDeviceConfigurationListModel(AbstractEmbeddedLinuxTarget *target)
: QAbstractListModel(target)
{
const DeviceManager * const devConfs = DeviceManager::instance();
connect(devConfs, SIGNAL(updated()), this, SIGNAL(updated()));
connect(devConfs, SIGNAL(updated()), this, SIGNAL(modelReset()));
connect(target, SIGNAL(supportedDevicesChanged()), this, SIGNAL(modelReset()));
}
TypeSpecificDeviceConfigurationListModel::~TypeSpecificDeviceConfigurationListModel()
@@ -58,10 +60,8 @@ int TypeSpecificDeviceConfigurationListModel::rowCount(const QModelIndex &parent
int count = 0;
const DeviceManager * const devConfs = DeviceManager::instance();
const int devConfsCount = devConfs->deviceCount();
if (m_targetDeviceType == QLatin1String(Constants::GenericLinuxOsType))
return devConfsCount;
for (int i = 0; i < devConfsCount; ++i) {
if (devConfs->deviceAt(i)->type() == m_targetDeviceType)
if (target()->supportsDevice(devConfs->deviceAt(i)))
++count;
}
return count;
@@ -75,7 +75,7 @@ QVariant TypeSpecificDeviceConfigurationListModel::data(const QModelIndex &index
const LinuxDeviceConfiguration::ConstPtr &devConf = deviceAt(index.row());
Q_ASSERT(devConf);
QString displayedName = devConf->displayName();
if (devConf->type() == m_targetDeviceType && DeviceManager::instance()
if (target()->supportsDevice(devConf) && DeviceManager::instance()
->defaultDevice(devConf->type()) == devConf) {
displayedName = tr("%1 (default)").arg(displayedName);
}
@@ -86,34 +86,34 @@ LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::dev
{
int currentRow = -1;
const DeviceManager * const devConfs = DeviceManager::instance();
if (m_targetDeviceType == QLatin1String(Constants::GenericLinuxOsType))
return devConfs->deviceAt(idx).staticCast<const LinuxDeviceConfiguration>();
const int devConfsCount = devConfs->deviceCount();
for (int i = 0; i < devConfsCount; ++i) {
const IDevice::ConstPtr device = devConfs->deviceAt(i);
if (device->type() == m_targetDeviceType
|| m_targetDeviceType == QLatin1String(Constants::GenericLinuxOsType)) {
if (++currentRow == idx)
return devConfs->deviceAt(i).staticCast<const LinuxDeviceConfiguration>();
}
if (target()->supportsDevice(device) && ++currentRow == idx)
return device.staticCast<const LinuxDeviceConfiguration>();
}
Q_ASSERT(false);
return LinuxDeviceConfiguration::ConstPtr();
QTC_ASSERT(false, return LinuxDeviceConfiguration::ConstPtr());
}
LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::defaultDeviceConfig() const
{
return DeviceManager::instance()->defaultDevice(m_targetDeviceType)
.staticCast<const LinuxDeviceConfiguration>();
const DeviceManager * const deviceManager = DeviceManager::instance();
const int deviceCount = deviceManager->deviceCount();
for (int i = 0; i < deviceCount; ++i) {
const IDevice::ConstPtr device = deviceManager->deviceAt(i);
if (target()->supportsDevice(device)
&& deviceManager->defaultDevice(device->type()) == device) {
return device.staticCast<const LinuxDeviceConfiguration>();
}
}
return LinuxDeviceConfiguration::ConstPtr();
}
LinuxDeviceConfiguration::ConstPtr TypeSpecificDeviceConfigurationListModel::find(LinuxDeviceConfiguration::Id id) const
{
const IDevice::ConstPtr &devConf = DeviceManager::instance()->find(id);
if (devConf && (devConf->type() == m_targetDeviceType
|| m_targetDeviceType == QLatin1String(Constants::GenericLinuxOsType))) {
if (devConf && target()->supportsDevice(devConf))
return devConf.staticCast<const LinuxDeviceConfiguration>();
}
return defaultDeviceConfig();
}
@@ -127,5 +127,10 @@ int TypeSpecificDeviceConfigurationListModel::indexForInternalId(LinuxDeviceConf
return -1;
}
AbstractEmbeddedLinuxTarget *TypeSpecificDeviceConfigurationListModel::target() const
{
return qobject_cast<AbstractEmbeddedLinuxTarget *>(QObject::parent());
}
} // namespace Internal
} // namespace RemoteLinux

View File

@@ -38,14 +38,14 @@
#include <QSharedPointer>
namespace RemoteLinux {
class AbstractEmbeddedLinuxTarget;
namespace Internal {
class TypeSpecificDeviceConfigurationListModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit TypeSpecificDeviceConfigurationListModel(const QString &deviceType,
QObject *parent = 0);
explicit TypeSpecificDeviceConfigurationListModel(AbstractEmbeddedLinuxTarget *target);
~TypeSpecificDeviceConfigurationListModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
@@ -57,11 +57,8 @@ public:
QSharedPointer<const LinuxDeviceConfiguration> find(LinuxDeviceConfiguration::Id id) const;
int indexForInternalId(LinuxDeviceConfiguration::Id id) const;
signals:
void updated();
private:
const QString m_targetDeviceType;
AbstractEmbeddedLinuxTarget * target() const;
};
} // namespace Internal