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

Maemo: Allow user to set default device configuration.

Task-number: QTCREATORBUG-3486
parent 61cbad96
......@@ -432,6 +432,27 @@ void MaemoDeviceConfigurations::setPortsSpec(int i, const QString &portsSpec)
m_devConfigs.at(i)->m_portsSpec = portsSpec;
}
void MaemoDeviceConfigurations::setDefaultDevice(int idx)
{
Q_ASSERT(idx >= 0 && idx < rowCount());
if (m_devConfigs.at(idx)->m_isDefault)
return;
QModelIndex oldDefaultIndex;
for(int i = 0; i < m_devConfigs.count(); ++i) {
const MaemoDeviceConfig::Ptr &oldDefaultDev = m_devConfigs.at(i);
if (oldDefaultDev->m_isDefault) {
oldDefaultDev->m_isDefault = false;
oldDefaultIndex = index(i, 0);
break;
}
}
Q_ASSERT(oldDefaultIndex.isValid());
emit dataChanged(oldDefaultIndex, oldDefaultIndex);
m_devConfigs.at(idx)->m_isDefault = true;
const QModelIndex newDefaultIndex = index(idx, 0);
emit dataChanged(newDefaultIndex, newDefaultIndex);
}
MaemoDeviceConfigurations::MaemoDeviceConfigurations(QObject *parent)
: QAbstractListModel(parent)
{
......
......@@ -104,6 +104,7 @@ public:
QString name() const { return m_name; }
DeviceType type() const { return m_type; }
QString portsSpec() const { return m_portsSpec; }
bool isDefault() const { return m_isDefault; }
Id internalId() const { return m_internalId; }
static QString portsRegExpr();
......@@ -164,6 +165,7 @@ public:
void setDeviceType(int i, const MaemoDeviceConfig::DeviceType type);
void setSshParameters(int i, const Core::SshConnectionParameters &params);
void setPortsSpec(int i, const QString &portsSpec);
void setDefaultDevice(int index);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index,
......
......@@ -164,6 +164,8 @@ void MaemoDeviceConfigurationsSettingsWidget::initGui()
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
SLOT(currentConfigChanged(int)));
currentConfigChanged(currentIndex());
connect(m_ui->defaultDeviceButton, SIGNAL(clicked()),
SLOT(setDefaultDevice()));
}
void MaemoDeviceConfigurationsSettingsWidget::addConfig()
......@@ -194,6 +196,7 @@ void MaemoDeviceConfigurationsSettingsWidget::deleteConfig()
void MaemoDeviceConfigurationsSettingsWidget::displayCurrent()
{
const MaemoDeviceConfig::ConstPtr &current = currentConfig();
m_ui->defaultDeviceButton->setEnabled(!current->isDefault());
const SshConnectionParameters &sshParams = current->sshParameters();
if (current->type() == MaemoDeviceConfig::Physical)
m_ui->deviceButton->setChecked(true);
......@@ -356,6 +359,12 @@ void MaemoDeviceConfigurationsSettingsWidget::setDefaultKeyFilePath()
m_devConfigs->setDefaultSshKeyFilePath(m_ui->keyFileLineEdit->path());
}
void MaemoDeviceConfigurationsSettingsWidget::setDefaultDevice()
{
m_devConfigs->setDefaultDevice(currentIndex());
m_ui->defaultDeviceButton->setEnabled(false);
}
void MaemoDeviceConfigurationsSettingsWidget::setPrivateKey(const QString &path)
{
m_ui->keyFileLineEdit->setPath(path);
......@@ -456,6 +465,7 @@ void MaemoDeviceConfigurationsSettingsWidget::currentConfigChanged(int index)
m_ui->remoteProcessesButton->setEnabled(false);
clearDetails();
m_ui->detailsWidget->setEnabled(false);
m_ui->defaultDeviceButton->setEnabled(false);
} else {
m_ui->removeConfigButton->setEnabled(true);
m_ui->testConfigButton->setEnabled(true);
......
......@@ -85,6 +85,7 @@ private slots:
void handleFreePortsChanged();
void showRemoteProcesses();
void setDefaultKeyFilePath();
void setDefaultDevice();
// For configuration testing.
void testConfig();
......
......@@ -422,6 +422,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="defaultDeviceButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Set As Default</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment