Logo Search packages:      
Sourcecode: canorus version File versions  Download package

void CAMainWin::on_uiRemoveVoice_triggered (  )  [private, slot]

Removes the current voice from the staff and deletes its contents.

Definition at line 1229 of file mainwin.cpp.

References CAStaff::addVoice(), CAScoreViewPort::clearSelection(), currentVoice(), CAVoice::name(), CAStaff::removeVoice(), CAVoice::staff(), and CAStaff::voiceCount().

                                           {
      CAVoice *voice = currentVoice();
      if (voice) {
            // Last voice cannot be deleted
            if (voice->staff()->voiceCount()==1) {
                  int ret = QMessageBox::critical(
                        this, tr("Canorus"),
                        tr("Cannot delete the last voice in the staff!")
                  );
                  return;
            }

            int ret = QMessageBox::warning(
                  this, tr("Canorus"),
                  tr("Are you sure do you want to delete voice\n%1 and all its notes?").arg(voice->name()),
                  QMessageBox::Yes | QMessageBox::No,
                  QMessageBox::No);

            if (ret == QMessageBox::Yes) {
                  stopPlayback();
                  CACanorus::undo()->createUndoCommand( document(), tr("voice removal", "undo") );
                  currentScoreViewPort()->clearSelection();
                  uiVoiceNum->setRealValue( voice->staff()->voiceCount()-1 );

                  voice->staff()->removeVoice(voice);
                  CACanorus::undo()->pushUndoCommand();
                  CACanorus::rebuildUI(document(), currentSheet());

                  voice->staff()->addVoice(voice);
                  delete voice; // also removes voice from the staff
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index