int LinuxDeviceConfigurations::indexForInternalId(LinuxDeviceConfiguration::Id internalId) const { for (int i = 0; i < m_devConfigs.count(); ++i) { if (deviceAt(i)->m_internalId == internalId) return i; } return -1; }
int MaemoPerTargetDeviceConfigurationListModel::indexForInternalId(LinuxDeviceConfiguration::Id id) const { const int count = rowCount(); for (int i = 0; i < count; ++i) { if (deviceAt(i)->internalId() == id) return i; } return -1; }
int TypeSpecificDeviceConfigurationListModel::indexForId(Core::Id id) const { const int count = rowCount(); for (int i = 0; i < count; ++i) { if (deviceAt(i)->id() == id) return i; } return -1; }
void LinuxDeviceConfigurations::removeConfiguration(int idx) { Q_ASSERT(idx >= 0 && idx < rowCount()); beginRemoveRows(QModelIndex(), idx, idx); const bool wasDefault = deviceAt(idx)->m_isDefault; const QString osType = deviceAt(idx)->osType(); m_devConfigs.removeAt(idx); endRemoveRows(); if (wasDefault) { for (int i = 0; i < m_devConfigs.count(); ++i) { if (deviceAt(i)->osType() == osType) { m_devConfigs.at(i)->m_isDefault = true; const QModelIndex changedIndex = index(i, 0); emit dataChanged(changedIndex, changedIndex); break; } } } }
QVariant MaemoPerTargetDeviceConfigurationListModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= rowCount() || role != Qt::DisplayRole) return QVariant(); const LinuxDeviceConfiguration::ConstPtr &devConf = deviceAt(index.row()); Q_ASSERT(devConf); QString displayedName = devConf->name(); if (devConf->isDefault() && devConf->osType() == m_targetOsType) displayedName += QLatin1Char(' ') + tr("(default)"); return displayedName; }
QVariant LinuxDeviceConfigurations::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= rowCount() || role != Qt::DisplayRole) return QVariant(); const LinuxDeviceConfiguration::ConstPtr devConf = deviceAt(index.row()); QString name = devConf->name(); if (devConf->isDefault()) { name += QLatin1Char(' ') + tr("(default for %1)") .arg(RemoteLinuxUtils::osTypeToString(devConf->osType())); } return name; }
QVariant TypeSpecificDeviceConfigurationListModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= rowCount() || role != Qt::DisplayRole) return QVariant(); const IDevice::ConstPtr &device = deviceAt(index.row()); Q_ASSERT(device); QString displayedName = device->displayName(); if (deviceMatches(device) && DeviceManager::instance()->defaultDevice(device->type()) == device) { displayedName = tr("%1 (default)").arg(displayedName); } return displayedName; }
LinuxDeviceConfiguration::ConstPtr LinuxDeviceConfigurations::find(LinuxDeviceConfiguration::Id id) const { const int index = indexForInternalId(id); return index == -1 ? LinuxDeviceConfiguration::ConstPtr() : deviceAt(index); }