| 1174 | } |
| 1175 | |
| 1176 | void |
| 1177 | ProjectFileManager::AddImportedTracks(const FilePath &fileName, |
| 1178 | TrackHolders &&newTracks) |
| 1179 | { |
| 1180 | auto &project = mProject; |
| 1181 | auto &history = ProjectHistory::Get( project ); |
| 1182 | auto &projectFileIO = ProjectFileIO::Get( project ); |
| 1183 | auto &tracks = TrackList::Get( project ); |
| 1184 | |
| 1185 | std::vector<Track*> results; |
| 1186 | |
| 1187 | SelectUtilities::SelectNone( project ); |
| 1188 | |
| 1189 | wxFileName fn(fileName); |
| 1190 | |
| 1191 | bool initiallyEmpty = tracks.empty(); |
| 1192 | wxString trackNameBase = fn.GetName(); |
| 1193 | int i = -1; |
| 1194 | |
| 1195 | // Fix the bug 2109. |
| 1196 | // In case the project had soloed tracks before importing, |
| 1197 | // all newly imported tracks are muted. |
| 1198 | const bool projectHasSolo = |
| 1199 | !(tracks.Any<PlayableTrack>() + &PlayableTrack::GetSolo).empty(); |
| 1200 | if (projectHasSolo) { |
| 1201 | for (auto &group : newTracks) |
| 1202 | if (auto pTrack = dynamic_cast<PlayableTrack*>(group.get())) |
| 1203 | pTrack->SetMute(true); |
| 1204 | } |
| 1205 | |
| 1206 | for (auto &group : newTracks) { |
| 1207 | if (auto pTrack = dynamic_cast<WaveTrack*>(group.get())) |
| 1208 | results.push_back(pTrack); |
| 1209 | tracks.Add(group); |
| 1210 | } |
| 1211 | newTracks.clear(); |
| 1212 | |
| 1213 | // Now name them |
| 1214 | |
| 1215 | // Add numbers to track names only if there is more than one (mono or stereo) |
| 1216 | // track (not necessarily, more than one channel) |
| 1217 | const bool useSuffix = results.size() > 1; |
| 1218 | |
| 1219 | for (const auto &newTrack : results) { |
| 1220 | ++i; |
| 1221 | newTrack->SetSelected(true); |
| 1222 | if (useSuffix) |
| 1223 | //i18n-hint Name default name assigned to a clip on track import |
| 1224 | newTrack->SetName(XC("%s %d", "clip name template") |
| 1225 | .Format(trackNameBase, i + 1).Translation()); |
| 1226 | else |
| 1227 | newTrack->SetName(trackNameBase); |
| 1228 | |
| 1229 | newTrack->TypeSwitch([&](WaveTrack &wt) { |
| 1230 | const auto trackName = wt.GetName(); |
| 1231 | for (const auto &interval : wt.Intervals()) |
| 1232 | interval->SetName(trackName); |
| 1233 | }); |
no test coverage detected