| 131 | } |
| 132 | |
| 133 | QString LaunchConfiguration::launcherForMode(const QString& mode) const |
| 134 | { |
| 135 | Q_D(const LaunchConfiguration); |
| 136 | |
| 137 | QStringList modes = d->baseGroup.readEntry("Configured Launch Modes", QStringList()); |
| 138 | int idx = modes.indexOf( mode ); |
| 139 | if( idx != -1 ) |
| 140 | { |
| 141 | const QStringList launcherIds = d->baseGroup.readEntry("Configured Launchers", QStringList()); |
| 142 | if (launcherIds.count() > idx ) { |
| 143 | const auto& id = launcherIds.at(idx); |
| 144 | const auto typeLaunchers = type()->launchers(); |
| 145 | for (ILauncher* l : typeLaunchers) { |
| 146 | if (l->id() == id) { |
| 147 | return id; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // No launcher configured, if it's debug mode, prefer GDB if available. |
| 154 | if( mode == QLatin1String("debug") ) |
| 155 | { |
| 156 | const auto launchers = type()->launchers(); |
| 157 | for (ILauncher* l : launchers) { |
| 158 | if( l->supportedModes().contains( mode ) && l->id() == QLatin1String("gdb") ) |
| 159 | { |
| 160 | return l->id(); |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | // Otherwise, lets just try with the first one in the list and hope it works |
| 165 | const auto launchers = type()->launchers(); |
| 166 | for (ILauncher* l : launchers) { |
| 167 | if( l->supportedModes().contains( mode ) ) |
| 168 | { |
| 169 | return l->id(); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return QString(); |
| 174 | } |
| 175 | |
| 176 | void LaunchConfiguration::setLauncherForMode(const QString& mode, const QString& id) |
| 177 | { |