Commit 51112975 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Move current device configuration to deploy configuration.

It used to be in the deploy steps itself, which is theoretically
more flexible, but offers no advantage in practice and also causes
a lot of hassle.

Change-Id: I0eafaf8477067fced86b7a05fd94d72a35e02bb7
Reviewed-on: http://codereview.qt.nokia.com/654

Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent a68aff70
......@@ -31,10 +31,7 @@
**************************************************************************/
#include "abstractlinuxdevicedeploystep.h"
#include "linuxdeviceconfigurations.h"
#include "maemoconstants.h"
#include "maemodeploystepwidget.h"
#include "maemopertargetdeviceconfigurationlistmodel.h"
#include "linuxdeviceconfiguration.h"
#include "qt4maemodeployconfiguration.h"
using namespace ProjectExplorer;
......@@ -44,13 +41,22 @@ namespace Internal {
AbstractLinuxDeviceDeployStep::AbstractLinuxDeviceDeployStep(DeployConfiguration *dc)
: m_helper(qobject_cast<Qt4MaemoDeployConfiguration *>(dc))
: m_deployConfiguration(qobject_cast<Qt4MaemoDeployConfiguration *>(dc))
{
}
AbstractLinuxDeviceDeployStep::~AbstractLinuxDeviceDeployStep()
{
}
LinuxDeviceConfiguration::ConstPtr AbstractLinuxDeviceDeployStep::deviceConfiguration() const
{
return m_deviceConfiguration;
}
bool AbstractLinuxDeviceDeployStep::isDeploymentPossible(QString &whyNot) const
{
if (!m_helper.deviceConfig()) {
if (!m_deployConfiguration->deviceConfiguration()) {
whyNot = tr("No valid device set.");
return false;
}
......@@ -61,49 +67,7 @@ bool AbstractLinuxDeviceDeployStep::initialize(QString &errorMsg)
{
if (!isDeploymentPossible(errorMsg))
return false;
m_helper.prepareDeployment();
return true;
}
LinuxDeviceDeployStepHelper::LinuxDeviceDeployStepHelper(Qt4MaemoDeployConfiguration *dc)
: m_deployConfiguration(dc)
{
m_deviceConfig = dc->deviceConfigModel()->defaultDeviceConfig();
connect(dc->deviceConfigModel().data(), SIGNAL(updated()),
SLOT(handleDeviceConfigurationsUpdated()));
}
LinuxDeviceDeployStepHelper::~LinuxDeviceDeployStepHelper() {}
void LinuxDeviceDeployStepHelper::handleDeviceConfigurationsUpdated()
{
setDeviceConfig(LinuxDeviceConfigurations::instance()->internalId(m_deviceConfig));
}
void LinuxDeviceDeployStepHelper::setDeviceConfig(LinuxDeviceConfiguration::Id internalId)
{
m_deviceConfig = deployConfiguration()->deviceConfigModel()->find(internalId);
emit deviceConfigChanged();
}
void LinuxDeviceDeployStepHelper::setDeviceConfig(int i)
{
m_deviceConfig = deployConfiguration()->deviceConfigModel()->deviceAt(i);
emit deviceConfigChanged();
}
QVariantMap LinuxDeviceDeployStepHelper::toMap() const
{
QVariantMap map;
map.insert(DeviceIdKey,
LinuxDeviceConfigurations::instance()->internalId(m_deviceConfig));
return map;
}
bool LinuxDeviceDeployStepHelper::fromMap(const QVariantMap &map)
{
setDeviceConfig(map.value(DeviceIdKey, LinuxDeviceConfiguration::InvalidId).toULongLong());
m_deviceConfiguration = m_deployConfiguration->deviceConfiguration();
return true;
}
......
......@@ -32,68 +32,37 @@
#ifndef ABSTRACTLINUXDEVICEDEPLOYSTEP_H
#define ABSTRACTLINUXDEVICEDEPLOYSTEP_H
#include "linuxdeviceconfiguration.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QSharedPointer>
#include <QtCore/QVariantMap>
namespace ProjectExplorer { class DeployConfiguration; }
namespace RemoteLinux {
class LinuxDeviceConfiguration;
namespace Internal {
class Qt4MaemoDeployConfiguration;
class LinuxDeviceDeployStepHelper : public QObject
{
Q_OBJECT
public:
LinuxDeviceDeployStepHelper(Qt4MaemoDeployConfiguration *dc);
~LinuxDeviceDeployStepHelper();
QSharedPointer<const LinuxDeviceConfiguration> deviceConfig() const { return m_deviceConfig; }
QSharedPointer<const LinuxDeviceConfiguration> cachedDeviceConfig() const { return m_cachedDeviceConfig; }
Qt4MaemoDeployConfiguration *deployConfiguration() const { return m_deployConfiguration; }
void setDeviceConfig(int i);
void prepareDeployment() { m_cachedDeviceConfig = m_deviceConfig; }
QVariantMap toMap() const;
bool fromMap(const QVariantMap &map);
signals:
void deviceConfigChanged();
private:
void setDeviceConfig(LinuxDeviceConfiguration::Id internalId);
Q_SLOT void handleDeviceConfigurationsUpdated();
QSharedPointer<const LinuxDeviceConfiguration> m_deviceConfig;
QSharedPointer<const LinuxDeviceConfiguration> m_cachedDeviceConfig;
Qt4MaemoDeployConfiguration * const m_deployConfiguration;
};
class AbstractLinuxDeviceDeployStep
{
Q_DECLARE_TR_FUNCTIONS(AbstractLinuxDeviceDeployStep)
public:
virtual ~AbstractLinuxDeviceDeployStep() {}
virtual ~AbstractLinuxDeviceDeployStep();
Qt4MaemoDeployConfiguration *maemoDeployConfig() const { return m_helper.deployConfiguration(); }
Qt4MaemoDeployConfiguration *maemoDeployConfig() const { return m_deployConfiguration; }
bool isDeploymentPossible(QString &whyNot) const;
LinuxDeviceDeployStepHelper &helper() { return m_helper; }
const LinuxDeviceDeployStepHelper &helper() const { return m_helper; }
protected:
AbstractLinuxDeviceDeployStep(ProjectExplorer::DeployConfiguration *dc);
QSharedPointer<const LinuxDeviceConfiguration> deviceConfiguration() const;
bool initialize(QString &errorMsg);
private:
virtual bool isDeploymentPossibleInternal(QString &whynot) const=0;
LinuxDeviceDeployStepHelper m_helper;
Qt4MaemoDeployConfiguration * const m_deployConfiguration;
mutable QSharedPointer<const LinuxDeviceConfiguration> m_deviceConfiguration;
};
} // namespace Internal
......
......@@ -129,14 +129,13 @@ void AbstractMaemoDeployStep::run(QFutureInterface<bool> &fi)
BuildStepConfigWidget *AbstractMaemoDeployStep::createConfigWidget()
{
return new MaemoDeployStepWidget(this);
return new MaemoDeployStepBaseWidget(this);
}
QVariantMap AbstractMaemoDeployStep::toMap() const
{
QVariantMap map(BuildStep::toMap());
addDeployTimesToMap(map);
map.unite(helper().toMap());
return map;
}
......@@ -163,8 +162,6 @@ bool AbstractMaemoDeployStep::fromMap(const QVariantMap &map)
{
if (!BuildStep::fromMap(map))
return false;
if (!helper().fromMap(map))
return false;
getDeployTimesFromMap(map);
return true;
}
......@@ -247,8 +244,8 @@ void AbstractMaemoDeployStep::start()
}
m_hasError = false;
if (isDeploymentNeeded(helper().cachedDeviceConfig()->sshParameters().host)) {
if (helper().cachedDeviceConfig()->type() == LinuxDeviceConfiguration::Emulator
if (isDeploymentNeeded(deviceConfiguration()->sshParameters().host)) {
if (deviceConfiguration()->type() == LinuxDeviceConfiguration::Emulator
&& !MaemoQemuManager::instance().qemuIsRunning()) {
MaemoQemuManager::instance().startRuntime();
raiseError(tr("Cannot deploy: Qemu was not running. "
......@@ -271,7 +268,7 @@ void AbstractMaemoDeployStep::handleConnectionFailure()
return;
const QString errorMsg = m_baseState == Connecting
? MaemoGlobal::failedToConnectToServerMessage(m_connection, helper().cachedDeviceConfig())
? MaemoGlobal::failedToConnectToServerMessage(m_connection, deviceConfiguration())
: tr("Connection error: %1").arg(m_connection->errorString());
raiseError(errorMsg);
setDeploymentFinished();
......@@ -282,7 +279,7 @@ void AbstractMaemoDeployStep::connectToDevice()
ASSERT_STATE(QList<BaseState>() << BaseInactive);
setBaseState(Connecting);
m_connection = SshConnectionManager::instance().acquireConnection(helper().cachedDeviceConfig()->sshParameters());
m_connection = SshConnectionManager::instance().acquireConnection(deviceConfiguration()->sshParameters());
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this,
SLOT(handleConnectionFailure()));
if (m_connection->state() == SshConnection::Connected) {
......@@ -374,6 +371,11 @@ const Qt4BuildConfiguration *AbstractMaemoDeployStep::qt4BuildConfiguration() co
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
}
SshConnection::Ptr AbstractMaemoDeployStep::connection() const
{
return m_connection;
}
MaemoDeployEventHandler::MaemoDeployEventHandler(AbstractMaemoDeployStep *deployStep,
QFutureInterface<bool> &future)
: m_deployStep(deployStep), m_future(future), m_eventLoop(new QEventLoop),
......
......@@ -90,7 +90,7 @@ protected:
QString deployMountPoint() const;
const Qt4ProjectManager::Qt4BuildConfiguration *qt4BuildConfiguration() const;
QSharedPointer<Utils::SshConnection> connection() const { return m_connection; }
QSharedPointer<Utils::SshConnection> connection() const;
private slots:
void start();
......
......@@ -30,6 +30,8 @@
**************************************************************************/
#include "maemodebugsupport.h"
#include <remotelinux/linuxdeviceconfiguration.h>
#include "maemosshrunner.h"
namespace RemoteLinux {
......
......@@ -153,7 +153,7 @@ void AbstractMaemoDeployByMountStep::handleMountDebugOutput(const QString &outpu
void AbstractMaemoDeployByMountStep::mount()
{
m_extendedState = Mounting;
m_mounter->setupMounts(connection(), helper().cachedDeviceConfig(),
m_mounter->setupMounts(connection(), deviceConfiguration(),
mountSpecifications(), qt4BuildConfiguration());
}
......@@ -259,8 +259,7 @@ void MaemoMountAndInstallDeployStep::deploy()
{
const QString remoteFilePath = deployMountPoint() + QLatin1Char('/')
+ QFileInfo(packagingStep()->packageFilePath()).fileName();
m_installer->installPackage(connection(), helper().cachedDeviceConfig(),
remoteFilePath, false);
m_installer->installPackage(connection(), deviceConfiguration(), remoteFilePath, false);
}
void MaemoMountAndInstallDeployStep::cancelInstallation()
......@@ -367,7 +366,7 @@ QList<MaemoMountSpecification> MaemoMountAndCopyDeployStep::mountSpecifications(
void MaemoMountAndCopyDeployStep::deploy()
{
m_copyFacility->copyFiles(connection(), helper().cachedDeviceConfig(),
m_copyFacility->copyFiles(connection(), deviceConfiguration(),
m_filesToCopy, deployMountPoint());
}
......
......@@ -33,10 +33,15 @@
#include "maemodeployconfigurationwidget.h"
#include "ui_maemodeployconfigurationwidget.h"
#include "linuxdeviceconfigurations.h"
#include "maemodeployablelistmodel.h"
#include "maemodeployables.h"
#include "maemoglobal.h"
#include "maemopertargetdeviceconfigurationlistmodel.h"
#include "maemosettingspages.h"
#include "qt4maemodeployconfiguration.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <QtGui/QFileDialog>
......@@ -65,7 +70,16 @@ void MaemoDeployConfigurationWidget::init(DeployConfiguration *dc)
m_deployConfig = qobject_cast<Qt4MaemoDeployConfiguration *>(dc);
Q_ASSERT(m_deployConfig);
ui->modelComboBox->setModel(m_deployConfig->deployables().data());
connect(ui->manageDevConfsLabel, SIGNAL(linkActivated(QString)),
SLOT(showDeviceConfigurations()));
ui->deviceConfigsComboBox->setModel(m_deployConfig->deviceConfigModel().data());
connect(ui->deviceConfigsComboBox, SIGNAL(activated(int)),
SLOT(handleSelectedDeviceConfigurationChanged(int)));
connect(m_deployConfig, SIGNAL(deviceConfigurationListChanged()),
SLOT(handleDeviceConfigurationListChanged()));
ui->projectsComboBox->setModel(m_deployConfig->deployables().data());
connect(m_deployConfig->deployables().data(), SIGNAL(modelAboutToBeReset()),
SLOT(handleModelListToBeReset()));
......@@ -74,7 +88,7 @@ void MaemoDeployConfigurationWidget::init(DeployConfiguration *dc)
connect(m_deployConfig->deployables().data(), SIGNAL(modelReset()),
SLOT(handleModelListReset()), Qt::QueuedConnection);
connect(ui->modelComboBox, SIGNAL(currentIndexChanged(int)),
connect(ui->projectsComboBox, SIGNAL(currentIndexChanged(int)),
SLOT(setModel(int)));
connect(ui->addDesktopFileButton, SIGNAL(clicked()),
SLOT(addDesktopFile()));
......@@ -92,12 +106,12 @@ void MaemoDeployConfigurationWidget::handleModelListToBeReset()
void MaemoDeployConfigurationWidget::handleModelListReset()
{
QTC_ASSERT(m_deployConfig->deployables()->modelCount() == ui->modelComboBox->count(), return);
QTC_ASSERT(m_deployConfig->deployables()->modelCount() == ui->projectsComboBox->count(), return);
if (m_deployConfig->deployables()->modelCount() > 0) {
if (ui->modelComboBox->currentIndex() == -1)
ui->modelComboBox->setCurrentIndex(0);
if (ui->projectsComboBox->currentIndex() == -1)
ui->projectsComboBox->setCurrentIndex(0);
else
setModel(ui->modelComboBox->currentIndex());
setModel(ui->projectsComboBox->currentIndex());
}
}
......@@ -117,9 +131,27 @@ void MaemoDeployConfigurationWidget::setModel(int row)
ui->addIconButton->setEnabled(canAddIconFile);
}
void MaemoDeployConfigurationWidget::handleSelectedDeviceConfigurationChanged(int index)
{
disconnect(m_deployConfig, SIGNAL(deviceConfigurationListChanged()), this,
SLOT(handleDeviceConfigurationListChanged()));
m_deployConfig->setDeviceConfiguration(index);
connect(m_deployConfig, SIGNAL(deviceConfigurationListChanged()),
SLOT(handleDeviceConfigurationListChanged()));
}
void MaemoDeployConfigurationWidget::handleDeviceConfigurationListChanged()
{
const LinuxDeviceConfiguration::ConstPtr &devConf = m_deployConfig->deviceConfiguration();
const LinuxDeviceConfiguration::Id internalId
= LinuxDeviceConfigurations::instance()->internalId(devConf);
const int newIndex = m_deployConfig->deviceConfigModel()->indexForInternalId(internalId);
ui->deviceConfigsComboBox->setCurrentIndex(newIndex);
}
void MaemoDeployConfigurationWidget::addDesktopFile()
{
const int modelRow = ui->modelComboBox->currentIndex();
const int modelRow = ui->projectsComboBox->currentIndex();
if (modelRow == -1)
return;
MaemoDeployableListModel *const model
......@@ -131,7 +163,7 @@ void MaemoDeployConfigurationWidget::addDesktopFile()
void MaemoDeployConfigurationWidget::addIcon()
{
const int modelRow = ui->modelComboBox->currentIndex();
const int modelRow = ui->projectsComboBox->currentIndex();
if (modelRow == -1)
return;
......@@ -167,5 +199,11 @@ void MaemoDeployConfigurationWidget::addIcon()
ui->tableView->resizeRowsToContents();
}
void MaemoDeployConfigurationWidget::showDeviceConfigurations()
{
Core::ICore::instance()->showOptionsDialog(MaemoDeviceConfigurationsSettingsPage::Category,
MaemoDeviceConfigurationsSettingsPage::Id);
}
} // namespace Internal
} // namespace RemoteLinux
......@@ -59,8 +59,11 @@ private:
Q_SLOT void handleModelListToBeReset();
Q_SLOT void handleModelListReset();
Q_SLOT void setModel(int row);
Q_SLOT void handleSelectedDeviceConfigurationChanged(int index);
Q_SLOT void handleDeviceConfigurationListChanged();
Q_SLOT void addDesktopFile();
Q_SLOT void addIcon();
Q_SLOT void showDeviceConfigurations();
Ui::MaemoDeployConfigurationWidget *ui;
Qt4MaemoDeployConfiguration * m_deployConfig;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>315</height>
<width>570</width>
<height>407</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,36 +15,74 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Device configuration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="deviceConfigsComboBox"/>
</item>
<item>
<widget class="QLabel" name="manageDevConfsLabel">
<property name="text">
<string>&lt;a href=&quot;irrelevant&quot;&gt;Manage device configurations&lt;/a&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="installLabel">
<property name="toolTip">
<string>These show the INSTALLS settings from the project file(s).</string>
</property>
<property name="text">
<string>&lt;b&gt;Files to install for subproject:&lt;/b&gt;</string>
<string>Files to install for subproject:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="modelComboBox">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="projectsComboBox">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
......
......@@ -31,32 +31,24 @@
**************************************************************************/
#include "maemodeploystepwidget.h"
#include "ui_maemodeploystepwidget.h"
#include "abstractmaemodeploystep.h"
#include "linuxdeviceconfigurations.h"
#include "maemosettingspages.h"
#include "maemoglobal.h"
#include "maemopertargetdeviceconfigurationlistmodel.h"
#include "remotelinuxrunconfiguration.h"
#include "qt4maemodeployconfiguration.h"
#include "qt4maemotarget.h"
#include <coreplugin/icore.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <QtGui/QVBoxLayout>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
MaemoDeployStepBaseWidget::MaemoDeployStepBaseWidget(AbstractLinuxDeviceDeployStep *step) :
ui(new Ui::MaemoDeployStepWidget),
m_step(step)
MaemoDeployStepBaseWidget::MaemoDeployStepBaseWidget(AbstractLinuxDeviceDeployStep *step)
: m_step(step)
{
ui->setupUi(this);
BuildStepList * const list = step->maemoDeployConfig()->stepList();
connect(list, SIGNAL(stepInserted(int)), SIGNAL(updateSummary()));
connect(list, SIGNAL(stepMoved(int,int)), SIGNAL(updateSummary()));
......@@ -64,30 +56,12 @@ MaemoDeployStepBaseWidget::MaemoDeployStepBaseWidget(AbstractLinuxDeviceDeploySt
connect(list, SIGNAL(aboutToRemoveStep(int)),
SLOT(handleStepToBeRemoved(int)));
ui->deviceConfigComboBox->setModel(m_step->maemoDeployConfig()->deviceConfigModel().data());
connect(&m_step->helper(), SIGNAL(deviceConfigChanged()),
SLOT(handleDeviceUpdate()));
handleDeviceUpdate();
connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
connect(ui->manageDevConfsLabel, SIGNAL(linkActivated(QString)),
SLOT(showDeviceConfigurations()));
connect(m_step->maemoDeployConfig(), SIGNAL(currentDeviceConfigurationChanged()),
SIGNAL(updateSummary()));
}
MaemoDeployStepBaseWidget::~MaemoDeployStepBaseWidget()
{
delete ui;
}
void MaemoDeployStepBaseWidget::handleDeviceUpdate()
{
const LinuxDeviceConfiguration::ConstPtr &devConf = m_step->helper().deviceConfig();
const LinuxDeviceConfiguration::Id internalId
= LinuxDeviceConfigurations::instance()->internalId(devConf);
const int newIndex = m_step->maemoDeployConfig()->deviceConfigModel()
->indexForInternalId(internalId);
ui->deviceConfigComboBox->setCurrentIndex(newIndex);
emit updateSummary();
}
void MaemoDeployStepBaseWidget::handleStepToBeRemoved(int step)
......@@ -108,31 +82,7 @@ QString MaemoDeployStepBaseWidget::summaryText() const
+ QLatin1String("</font>");
}
return tr("<b>%1 using device</b>: %2").arg(dynamic_cast<BuildStep *>(m_step)->displayName(),
MaemoGlobal::deviceConfigurationName(m_step->helper().deviceConfig()));
}
void MaemoDeployStepBaseWidget::setCurrentDeviceConfig(int index)
{
disconnect(&m_step->helper(), SIGNAL(deviceConfigChanged()), this,
SLOT(handleDeviceUpdate()));
m_step->helper().setDeviceConfig(index);
connect(&m_step->helper(), SIGNAL(deviceConfigChanged()),
SLOT(handleDeviceUpdate()));
updateSummary();
}
void MaemoDeployStepBaseWidget::showDeviceConfigurations()
{