Files
qt-creator/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepwidget.cpp

112 lines
3.1 KiB
C++
Raw Normal View History

#include "maemodeploystepwidget.h"
#include "ui_maemodeploystepwidget.h"
#include "maemodeploystep.h"
#include "maemodeployablelistmodel.h"
#include "maemodeployablelistwidget.h"
#include "maemodeployables.h"
#include "maemodeviceconfiglistmodel.h"
#include "maemorunconfiguration.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/target.h>
namespace Qt4ProjectManager {
namespace Internal {
MaemoDeployStepWidget::MaemoDeployStepWidget(MaemoDeployStep *step) :
ProjectExplorer::BuildStepConfigWidget(),
ui(new Ui::MaemoDeployStepWidget),
m_step(step)
{
ui->setupUi(this);
connect(m_step->deployables(), SIGNAL(modelsCreated()), this,
SLOT(handleModelsCreated()));
handleModelsCreated();
}
MaemoDeployStepWidget::~MaemoDeployStepWidget()
{
delete ui;
}
void MaemoDeployStepWidget::init()
{
#ifdef DEPLOY_VIA_MOUNT
ui->mountPortSpinBox->setValue(m_step->mountPort());
connect(ui->mountPortSpinBox, SIGNAL(valueChanged(int)), this,
SLOT(handleMountPortEdited(int)));
#else
ui->mountPortLabel->hide();
ui->mountPortSpinBox->hide();
#endif
2010-07-16 18:06:17 +02:00
handleDeviceConfigModelChanged();
connect(m_step->buildConfiguration()->target(),
SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
2010-07-16 18:06:17 +02:00
this, SLOT(handleDeviceConfigModelChanged()));
connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
}
2010-07-16 18:06:17 +02:00
void MaemoDeployStepWidget::handleDeviceConfigModelChanged()
{
const MaemoDeviceConfigListModel * const oldModel
= qobject_cast<MaemoDeviceConfigListModel *>(ui->deviceConfigComboBox->model());
if (oldModel)
disconnect(oldModel, 0, this, 0);
MaemoDeviceConfigListModel * const devModel = m_step->deviceConfigModel();
ui->deviceConfigComboBox->setModel(devModel);
connect(devModel, SIGNAL(currentChanged()), this,
SLOT(handleDeviceUpdate()));
connect(devModel, SIGNAL(modelReset()), this,
SLOT(handleDeviceUpdate()));
handleDeviceUpdate();
}
void MaemoDeployStepWidget::handleDeviceUpdate()
{
ui->deviceConfigComboBox->setCurrentIndex(m_step->deviceConfigModel()
->currentIndex());
emit updateSummary();
}
QString MaemoDeployStepWidget::summaryText() const
{
return tr("<b>Deploy to device</b>: ") + m_step->deviceConfig().name;
}
QString MaemoDeployStepWidget::displayName() const
{
return QString();
}
void MaemoDeployStepWidget::handleModelsCreated()
{
ui->tabWidget->clear();
for (int i = 0; i < m_step->deployables()->modelCount(); ++i) {
MaemoDeployableListModel * const model
= m_step->deployables()->modelAt(i);
ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model),
model->projectName());
}
}
void MaemoDeployStepWidget::setCurrentDeviceConfig(int index)
{
m_step->deviceConfigModel()->setCurrentIndex(index);
}
void MaemoDeployStepWidget::handleMountPortEdited(int newPort)
{
#ifdef DEPLOY_VIA_MOUNT
m_step->setMountPort(newPort);
2010-08-13 09:19:27 +02:00
#else
Q_UNUSED(newPort);
#endif
}
} // namespace Internal
} // namespace Qt4ProjectManager