forked from qt-creator/qt-creator
Maemo: Allow user to set default device configuration.
Task-number: QTCREATORBUG-3486
This commit is contained in:
@@ -432,6 +432,27 @@ void MaemoDeviceConfigurations::setPortsSpec(int i, const QString &portsSpec)
|
|||||||
m_devConfigs.at(i)->m_portsSpec = 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)
|
MaemoDeviceConfigurations::MaemoDeviceConfigurations(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
DeviceType type() const { return m_type; }
|
DeviceType type() const { return m_type; }
|
||||||
QString portsSpec() const { return m_portsSpec; }
|
QString portsSpec() const { return m_portsSpec; }
|
||||||
|
bool isDefault() const { return m_isDefault; }
|
||||||
Id internalId() const { return m_internalId; }
|
Id internalId() const { return m_internalId; }
|
||||||
static QString portsRegExpr();
|
static QString portsRegExpr();
|
||||||
|
|
||||||
@@ -164,6 +165,7 @@ public:
|
|||||||
void setDeviceType(int i, const MaemoDeviceConfig::DeviceType type);
|
void setDeviceType(int i, const MaemoDeviceConfig::DeviceType type);
|
||||||
void setSshParameters(int i, const Core::SshConnectionParameters ¶ms);
|
void setSshParameters(int i, const Core::SshConnectionParameters ¶ms);
|
||||||
void setPortsSpec(int i, const QString &portsSpec);
|
void setPortsSpec(int i, const QString &portsSpec);
|
||||||
|
void setDefaultDevice(int index);
|
||||||
|
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
virtual QVariant data(const QModelIndex &index,
|
virtual QVariant data(const QModelIndex &index,
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ void MaemoDeviceConfigurationsSettingsWidget::initGui()
|
|||||||
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
|
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
|
||||||
SLOT(currentConfigChanged(int)));
|
SLOT(currentConfigChanged(int)));
|
||||||
currentConfigChanged(currentIndex());
|
currentConfigChanged(currentIndex());
|
||||||
|
connect(m_ui->defaultDeviceButton, SIGNAL(clicked()),
|
||||||
|
SLOT(setDefaultDevice()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeviceConfigurationsSettingsWidget::addConfig()
|
void MaemoDeviceConfigurationsSettingsWidget::addConfig()
|
||||||
@@ -194,6 +196,7 @@ void MaemoDeviceConfigurationsSettingsWidget::deleteConfig()
|
|||||||
void MaemoDeviceConfigurationsSettingsWidget::displayCurrent()
|
void MaemoDeviceConfigurationsSettingsWidget::displayCurrent()
|
||||||
{
|
{
|
||||||
const MaemoDeviceConfig::ConstPtr ¤t = currentConfig();
|
const MaemoDeviceConfig::ConstPtr ¤t = currentConfig();
|
||||||
|
m_ui->defaultDeviceButton->setEnabled(!current->isDefault());
|
||||||
const SshConnectionParameters &sshParams = current->sshParameters();
|
const SshConnectionParameters &sshParams = current->sshParameters();
|
||||||
if (current->type() == MaemoDeviceConfig::Physical)
|
if (current->type() == MaemoDeviceConfig::Physical)
|
||||||
m_ui->deviceButton->setChecked(true);
|
m_ui->deviceButton->setChecked(true);
|
||||||
@@ -356,6 +359,12 @@ void MaemoDeviceConfigurationsSettingsWidget::setDefaultKeyFilePath()
|
|||||||
m_devConfigs->setDefaultSshKeyFilePath(m_ui->keyFileLineEdit->path());
|
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)
|
void MaemoDeviceConfigurationsSettingsWidget::setPrivateKey(const QString &path)
|
||||||
{
|
{
|
||||||
m_ui->keyFileLineEdit->setPath(path);
|
m_ui->keyFileLineEdit->setPath(path);
|
||||||
@@ -456,6 +465,7 @@ void MaemoDeviceConfigurationsSettingsWidget::currentConfigChanged(int index)
|
|||||||
m_ui->remoteProcessesButton->setEnabled(false);
|
m_ui->remoteProcessesButton->setEnabled(false);
|
||||||
clearDetails();
|
clearDetails();
|
||||||
m_ui->detailsWidget->setEnabled(false);
|
m_ui->detailsWidget->setEnabled(false);
|
||||||
|
m_ui->defaultDeviceButton->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
m_ui->removeConfigButton->setEnabled(true);
|
m_ui->removeConfigButton->setEnabled(true);
|
||||||
m_ui->testConfigButton->setEnabled(true);
|
m_ui->testConfigButton->setEnabled(true);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ private slots:
|
|||||||
void handleFreePortsChanged();
|
void handleFreePortsChanged();
|
||||||
void showRemoteProcesses();
|
void showRemoteProcesses();
|
||||||
void setDefaultKeyFilePath();
|
void setDefaultKeyFilePath();
|
||||||
|
void setDefaultDevice();
|
||||||
|
|
||||||
// For configuration testing.
|
// For configuration testing.
|
||||||
void testConfig();
|
void testConfig();
|
||||||
|
|||||||
@@ -422,6 +422,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user