MCPcopy Create free account
hub / github.com/audacity/audacity / TransferDataFromWindow

Method TransferDataFromWindow

src/LabelDialog.cpp:370–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370bool LabelDialog::TransferDataFromWindow()
371{
372 int cnt = mData.size();
373 int i;
374 int tndx = 0;
375
376 // Clear label tracks of labels
377 for (auto lt : mTracks->Any<LabelTrack>()) {
378 ++tndx;
379 if (!mSelectedTrack) {
380 for (i = lt->GetNumLabels() - 1; i >= 0 ; i--) {
381 lt->DeleteLabel(i);
382 }
383 }
384 else if (mSelectedTrack == lt && mIndex > -1) {
385 lt->DeleteLabel(mIndex);
386 }
387 else
388 // Do nothing to the nonselected tracks
389 ;
390 }
391
392 // Create any added tracks
393 while (tndx < (int)mTrackNames.size() - 1) {
394
395 // Extract the name
396 wxString name = mTrackNames[tndx + 1].AfterFirst(wxT('-')).Mid(1);
397
398 // Create the NEW track and add to track list
399 auto newTrack = std::make_shared<LabelTrack>();
400 newTrack->SetName(name);
401 mTracks->Add( newTrack );
402 tndx++;
403 }
404
405 // Repopulate with updated labels
406 for (i = 0; i < cnt; i++) {
407 RowData &rd = mData[i];
408
409 // Look for track with matching index
410 tndx = 1;
411 LabelTrack *lt{};
412 for (auto t : mTracks->Any<LabelTrack>()) {
413 lt = t;
414 if (rd.index == tndx++) {
415 break;
416 }
417 }
418 wxASSERT(lt);
419 if (!lt)
420 return false;
421
422 // Add the label to it
423 lt->AddLabel(rd.selectedRegion, rd.title);
424 LabelTrackView::Get( *lt ).ResetTextSelection();
425 }
426
427 return true;

Callers

nothing calls this directly

Calls 8

GetFunction · 0.85
GetNumLabelsMethod · 0.80
DeleteLabelMethod · 0.80
ResetTextSelectionMethod · 0.80
sizeMethod · 0.45
SetNameMethod · 0.45
AddMethod · 0.45
AddLabelMethod · 0.45

Tested by

no test coverage detected