| 164 | } |
| 165 | |
| 166 | void launchAs( int id ) |
| 167 | { |
| 168 | //qCDebug(SHELL) << "Launching id:" << id; |
| 169 | QPair<QString,QString> info = launchAsInfo[id]; |
| 170 | //qCDebug(SHELL) << "fetching type and mode:" << info.first << info.second; |
| 171 | LaunchConfigurationType* type = launchConfigurationTypeForId( info.first ); |
| 172 | ILaunchMode* mode = q->launchModeForId( info.second ); |
| 173 | |
| 174 | //qCDebug(SHELL) << "got mode and type:" << type << type->id() << mode << mode->id(); |
| 175 | if( type && mode ) |
| 176 | { |
| 177 | const auto launchers = type->launchers(); |
| 178 | auto it = std::find_if(launchers.begin(), launchers.end(), [&](ILauncher* l) { |
| 179 | //qCDebug(SHELL) << "available launcher" << l << l->id() << l->supportedModes(); |
| 180 | return (l->supportedModes().contains(mode->id())); |
| 181 | }); |
| 182 | if (it != launchers.end()) { |
| 183 | ILauncher* launcher = *it; |
| 184 | |
| 185 | QStringList itemPath = Core::self()->projectController()->projectModel()->pathFromIndex(contextItem->index()); |
| 186 | auto it = std::find_if(launchConfigurations.constBegin(), launchConfigurations.constEnd(), |
| 187 | [&] (LaunchConfiguration* l) { |
| 188 | QStringList path = l->config().readEntry(Strings::ConfiguredFromProjectItemEntry(), QStringList()); |
| 189 | if (l->type() == type && path == itemPath) { |
| 190 | qCDebug(SHELL) << "already generated ilaunch" << path; |
| 191 | return true; |
| 192 | } |
| 193 | return false; |
| 194 | }); |
| 195 | ILaunchConfiguration* ilaunch = (it != launchConfigurations.constEnd()) ? *it : nullptr; |
| 196 | |
| 197 | if (!ilaunch) { |
| 198 | ilaunch = q->createLaunchConfiguration( type, |
| 199 | qMakePair( mode->id(), launcher->id() ), |
| 200 | contextItem->project(), |
| 201 | contextItem->text() ); |
| 202 | auto* launch = static_cast<LaunchConfiguration*>(ilaunch); |
| 203 | type->configureLaunchFromItem( launch->config(), contextItem ); |
| 204 | launch->config().writeEntry(Strings::ConfiguredFromProjectItemEntry(), itemPath); |
| 205 | //qCDebug(SHELL) << "created config, launching"; |
| 206 | } else { |
| 207 | //qCDebug(SHELL) << "reusing generated config, launching"; |
| 208 | } |
| 209 | q->setDefaultLaunch(ilaunch); |
| 210 | q->execute( mode->id(), ilaunch ); |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | void updateCurrentLaunchAction() |
| 216 | { |
no test coverage detected