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

Method OnInsert

src/LabelDialog.cpp:549–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549void LabelDialog::OnInsert(wxCommandEvent &event)
550{
551 int cnt = mData.size();
552 int row = 0;
553 int index = 0;
554
555 // Make sure the edit control isn't active before inserting any rows
556 if (mGrid->IsCellEditControlShown()) {
557 mGrid->HideCellEditControl();
558 }
559
560 // Attempt to guess which track the label should reside on
561 if (cnt > 0) {
562 row = mGrid->GetGridCursorRow();
563 if (row > 0 && row >= cnt) {
564 index = make_iterator_range( mTrackNames )
565 .index( mGrid->GetCellValue(row - 1, Col_Track) );
566 }
567 else {
568 index = make_iterator_range( mTrackNames )
569 .index( mGrid->GetCellValue(row, Col_Track) );
570 }
571 }
572
573 // Insert NEW label before or after the current row
574 if (event.GetId() == ID_INSERTA && row < cnt) {
575 row++;
576 }
577 mData.insert(mData.begin() + row, RowData(index, wxT(""), SelectedRegion()));
578
579 // Repopulate the grid
580 TransferDataToWindow();
581
582 // Reposition cursor to NEW row/col and put user into edit mode to
583 // set the label name
584 mGrid->SetGridCursor(row, Col_Label);
585 mGrid->EnableCellEditControl(true);
586 mGrid->ShowCellEditControl();
587}
588
589void LabelDialog::OnRemove(wxCommandEvent & WXUNUSED(event))
590{

Callers

nothing calls this directly

Calls 8

make_iterator_rangeFunction · 0.85
GetIdMethod · 0.80
RowDataClass · 0.70
SelectedRegionClass · 0.70
sizeMethod · 0.45
indexMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected