Delete curve/curves
| 333 | |
| 334 | // Delete curve/curves |
| 335 | void EqualizationCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event)) |
| 336 | { |
| 337 | // We could count them here |
| 338 | // And then put in a 'Delete N items?' prompt. |
| 339 | |
| 340 | #if 0 // 'one at a time' prompt code |
| 341 | // Get the first one to be deleted |
| 342 | long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 343 | // Take care, mList and mEditCurves will get out of sync as curves are deleted |
| 344 | int deleted = 0; |
| 345 | long highlight = -1; |
| 346 | |
| 347 | while(item >= 0) |
| 348 | { |
| 349 | if(item == mList->GetItemCount()-1) //unnamed |
| 350 | { |
| 351 | EQUtils::DoMessageBox(mName, |
| 352 | XO("You cannot delete the 'unnamed' curve."), |
| 353 | XO("Can't delete 'unnamed'") ); |
| 354 | } |
| 355 | else |
| 356 | { |
| 357 | // Create the prompt |
| 358 | auto quest = XO("Delete '%s'?") |
| 359 | .Format(mEditCurves[ item-deleted ].Name); |
| 360 | |
| 361 | // Ask for confirmation before removal |
| 362 | int ans = EQUtils::DoMessageBox(mName, |
| 363 | quest, |
| 364 | XO("Confirm Deletion") ); |
| 365 | if( ans == wxYES ) |
| 366 | { // Remove the curve from the array |
| 367 | mEditCurves.erase( mEditCurves.begin() + (item - deleted) ); |
| 368 | deleted++; |
| 369 | } |
| 370 | else |
| 371 | highlight = item-deleted; // if user presses 'No', select that curve |
| 372 | } |
| 373 | // get next selected item |
| 374 | item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 375 | } |
| 376 | |
| 377 | if(highlight == -1) |
| 378 | PopulateList(mEditCurves.size()-1); // set 'unnamed' as the selected curve |
| 379 | else |
| 380 | PopulateList(highlight); // user said 'No' to deletion |
| 381 | #else // 'DELETE all N' code |
| 382 | int count = mList->GetSelectedItemCount(); |
| 383 | long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 384 | // Create the prompt |
| 385 | TranslatableString quest; |
| 386 | if( count > 1 ) |
| 387 | quest = XO("Delete %d items?").Format( count ); |
| 388 | else |
| 389 | if( count == 1 ) |
| 390 | quest = XO("Delete '%s'?").Format( mEditCurves[ item ].Name ); |
| 391 | else |
| 392 | return; |
nothing calls this directly
no test coverage detected