void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion, QtVersion::QmakeBuildConfig buildConfiguration)
{
    QMakeStep *qmakeStep = m_project->qmakeStep();
    MakeStep *makeStep = m_project->makeStep();

    bool debug = buildConfiguration & QtVersion::DebugBuild;
    // Check that bc.name is not already in use
    if (m_project->buildConfigurations().contains(name)) {
        int i =1;
        do {
            ++i;
        } while (m_project->buildConfigurations().contains(name + " " + QString::number(i)));
        name.append(" " + QString::number(i));
    }

    // Add the buildconfiguration
    m_project->addBuildConfiguration(name);
    // set some options for qmake and make
    if (buildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
        makeStep->setValue(name, "makeargs", QStringList() << (debug ? "debug" : "release"));

    qmakeStep->setValue(name, "buildConfiguration", int(buildConfiguration));

    // Finally set the qt version
    bool defaultQtVersion = (qtversion == 0);
    if (defaultQtVersion)
        m_project->setQtVersion(name, 0);
    else
        m_project->setQtVersion(name, qtversion->uniqueId());

}
void Qt4BuildConfigWidget::importLabelClicked()
{
    if (m_ui->shadowBuildCheckBox->isChecked()) {
        QString directory = m_ui->shadowBuildDirEdit->path();
        if (!directory.isEmpty()) {
            QtVersionManager *vm = m_pro->qt4ProjectManager()->versionManager();
            QString qtPath = vm->findQtVersionFromMakefile(directory);
            if (!qtPath.isEmpty()) {
                QtVersion *version = vm->qtVersionForDirectory(qtPath);
                if (!version) {
                    version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath);
                    vm->addVersion(version);
                }
                QtVersion::QmakeBuildConfig qmakeBuildConfig = version->defaultBuildConfig();
                qmakeBuildConfig = vm->scanMakefileForQmakeConfig(directory, qmakeBuildConfig);

                // So we got all the information now apply it...
                m_pro->setQtVersion(m_buildConfiguration, version->uniqueId());
                // Combo box will be updated at the end

                // Find qmakestep...
                QMakeStep *qmakeStep = m_pro->qmakeStep();
                MakeStep *makeStep = m_pro->makeStep();

                qmakeStep->setValue(m_buildConfiguration, "buildConfiguration", int(qmakeBuildConfig));
                // Adjust command line arguments, this is ugly as hell
                // If we are switching to BuildAll we want "release" in there and no "debug"
                // or "debug" in there and no "release"
                // If we are switching to not BuildAl we want neither "release" nor "debug" in there
                QStringList makeCmdArguments = makeStep->value(m_buildConfiguration, "makeargs").toStringList();
                bool debug = qmakeBuildConfig & QtVersion::DebugBuild;
                if (qmakeBuildConfig & QtVersion::BuildAll) {
                    makeCmdArguments.removeAll(debug ? "release" : "debug");
                    if (!makeCmdArguments.contains(debug ? "debug" : "release"))
                        makeCmdArguments.append(debug ? "debug" : "release");
                } else {
                    makeCmdArguments.removeAll("debug");
                    makeCmdArguments.removeAll("remove");
                }
                makeStep->setValue(m_buildConfiguration, "makeargs", makeCmdArguments);
            }
        }
    }
    setupQtVersionsComboBox();
}