Esempio n. 1
0
void LinuxDeviceConfigurations::addConfiguration(const LinuxDeviceConfiguration::Ptr &devConfig)
{
    // Ensure uniqueness of name.
    QString name = devConfig->name();
    if (hasConfig(name)) {
        const QString nameTemplate = name + QLatin1String(" (%1)");
        int suffix = 2;
        do
            name = nameTemplate.arg(QString::number(suffix++));
        while (hasConfig(name));
    }
    devConfig->setName(name);

    devConfig->setInternalId(m_nextId++);
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    if (!defaultDeviceConfig(devConfig->osType()))
        devConfig->setDefault(true);
    m_devConfigs << devConfig;
    endInsertRows();
}
Esempio n. 2
0
void MaemoDeviceConfigurationsSettingsWidget::addConfig()
{
    const QList<ILinuxDeviceConfigurationFactory *> &factories
        = ExtensionSystem::PluginManager::instance()->getObjects<ILinuxDeviceConfigurationFactory>();

    if (factories.isEmpty()) // Can't happen, because this plugin provides the generic one.
        return;

    const ILinuxDeviceConfigurationFactory *factory;

    if (factories.count() == 1) {
        // Don't show dialog when there's nothing to choose from.
        // TODO: This is transitional. Remove it once the MADDE plugin exists.
        factory = factories.first();
    } else {
        LinuxDeviceFactorySelectionDialog d;
        if (d.exec() != QDialog::Accepted)
            return;
        factory = d.selectedFactory();
    }

    ILinuxDeviceConfigurationWizard *wizard = factory->createWizard();
    if (wizard->exec() != QDialog::Accepted)
        return;

    LinuxDeviceConfiguration::Ptr devConf = wizard->deviceConfiguration();
    QString name = devConf->name();
    if (m_devConfigs->hasConfig(name)) {
        const QString nameTemplate = name + QLatin1String(" (%1)");
        int suffix = 2;
        do
            name = nameTemplate.arg(QString::number(suffix++));
        while (m_devConfigs->hasConfig(name));
    }
    devConf->setName(name);
    m_devConfigs->addConfiguration(devConf);
    m_ui->removeConfigButton->setEnabled(true);
    m_ui->configurationComboBox->setCurrentIndex(m_ui->configurationComboBox->count()-1);

    delete wizard;
}