Maemo: Allow user to set default device configuration.

Task-number: QTCREATORBUG-3486
This commit is contained in:
Christian Kandeler
2011-01-13 15:00:48 +01:00
parent 61cbad9612
commit a8bea59d88
5 changed files with 44 additions and 0 deletions

View File

@@ -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)
{