Пример #1
0
void EditStaff::updateInstrument()
      {
      setInterval(instrument.transpose());

      QList<StaffNameDoc>& nl = instrument.shortNames();
      QTextDocumentFragment df = nl.isEmpty() ? QTextDocumentFragment() : nl[0].name;
      shortName->setHtml(df.toHtml());

      nl = instrument.longNames();
      df = nl.isEmpty() ? QTextDocumentFragment() : nl[0].name;
      longName->setHtml(df.toHtml());

      if (partName->text() == instrumentName->text())    // Updates part name is no custom name has been set before
            partName->setText(instrument.trackName());

      instrumentName->setText(instrument.trackName());

      _minPitchA = instrument.minPitchA();
      _maxPitchA = instrument.maxPitchA();
      _minPitchP = instrument.minPitchP();
      _maxPitchP = instrument.maxPitchP();
      minPitchA->setText(midiCodeToStr(_minPitchA));
      maxPitchA->setText(midiCodeToStr(_maxPitchA));
      minPitchP->setText(midiCodeToStr(_minPitchP));
      maxPitchP->setText(midiCodeToStr(_maxPitchP));

      int numStr = instrument.stringData() ? instrument.stringData()->strings() : 0;
      numOfStrings->setText(QString::number(numStr));
      }
Пример #2
0
void EditStaff::updateInstrument()
      {
      updateInterval(instrument.transpose());

      QList<StaffName>& snl = instrument.shortNames();
      QString df = snl.isEmpty() ? "" : snl[0].name();
      shortName->setPlainText(df);

      QList<StaffName>& lnl = instrument.longNames();
      df = lnl.isEmpty() ? "" : lnl[0].name();

      longName->setPlainText(df);

      if (partName->text() == instrumentName->text())    // Updates part name if no custom name has been set before
            partName->setText(instrument.trackName());

      instrumentName->setText(instrument.trackName());

      _minPitchA = instrument.minPitchA();
      _maxPitchA = instrument.maxPitchA();
      _minPitchP = instrument.minPitchP();
      _maxPitchP = instrument.maxPitchP();
      minPitchA->setText(midiCodeToStr(_minPitchA));
      maxPitchA->setText(midiCodeToStr(_maxPitchA));
      minPitchP->setText(midiCodeToStr(_minPitchP));
      maxPitchP->setText(midiCodeToStr(_maxPitchP));
      singleNoteDynamics->setChecked(instrument.singleNoteDynamics());
      instrument.switchExpressive(synti, instrument.singleNoteDynamics());

      // only show string data controls if instrument has strings
      int numStr = instrument.stringData() ? instrument.stringData()->strings() : 0;
      stringDataFrame->setVisible(numStr > 0);
      numOfStrings->setText(QString::number(numStr));
      }
Пример #3
0
void EditStringData::newStringClicked()
      {
      int         i, newCode;

      EditPitch* ep = new EditPitch(this);
      if ( (newCode=ep->exec()) != -1) {
            // find sorted postion for new string tuning value
/*            for(i=_stringsLoc.size()-1; i >= 0 && newCode > _stringsLoc[i]; i--)
                  ;
            // insert in local string list and in dlg list control
            _stringsLoc.insert(i+1, newCode);
            stringList->insertItem(i+1, midiCodeToStr(newCode));
            // select last added item and ensure buttons are active
            stringList->setCurrentRow(i+1);
*/
            // add below selected string o at the end if no selected string
            i = stringList->currentRow();
            if(i < 0)
                  i = stringList->count() - 1;
            // insert in local string list and in dlg list control
            _stringsLoc.insert(i+1, newCode);
            stringList->insertItem(i+1, midiCodeToStr(newCode));
            // select last added item and ensure buttons are active
            stringList->setCurrentRow(i+1);
            editString->setEnabled(true);
            deleteString->setEnabled(true);
            _modified = true;
            }
      }
Пример #4
0
void EditStaff::editStringDataClicked()
      {
      int                     frets = instrument.stringData()->frets();
      QList<instrString>      stringList = instrument.stringData()->stringList();

      EditStringData* esd = new EditStringData(this, &stringList, &frets);
      esd->setWindowModality(Qt::WindowModal);
      if (esd->exec()) {
            StringData stringData(frets, stringList);

            // update instrument pitch ranges as necessary
            if (stringList.size() > 0) {
                  // get new string range bottom and top
                  // as we have to choose an int size, INT16 are surely beyond midi pitch limits
                  int oldHighestStringPitch     = INT16_MIN;
                  int highestStringPitch        = INT16_MIN;
                  int lowestStringPitch         = INT16_MAX;
                  for (const instrString& str : stringList) {
                        if (str.pitch > highestStringPitch) highestStringPitch = str.pitch;
                        if (str.pitch < lowestStringPitch)  lowestStringPitch  = str.pitch;
                        }
                  // get old string range bottom
                  for (const instrString& str : instrument.stringData()->stringList())
                        if (str.pitch > oldHighestStringPitch) oldHighestStringPitch = str.pitch;
                  // if there were no string, arbitrarely set old top to maxPitchA
                  if (oldHighestStringPitch == INT16_MIN)
                        oldHighestStringPitch = instrument.maxPitchA();

                  // range bottom is surely the pitch of the lowest string
                  instrument.setMinPitchA(lowestStringPitch);
                  instrument.setMinPitchP(lowestStringPitch);
                  // range top should keep the same interval with the highest string it has now
                  instrument.setMaxPitchA(instrument.maxPitchA() + highestStringPitch - oldHighestStringPitch);
                  instrument.setMaxPitchP(instrument.maxPitchP() + highestStringPitch - oldHighestStringPitch);
                  // update dlg controls
                  minPitchA->setText(midiCodeToStr(instrument.minPitchA()));
                  maxPitchA->setText(midiCodeToStr(instrument.maxPitchA()));
                  minPitchP->setText(midiCodeToStr(instrument.minPitchP()));
                  maxPitchP->setText(midiCodeToStr(instrument.maxPitchP()));
                  // if no longer there is any string, leave everything as it is now
                  }

            // update instrument data and dlg controls
            instrument.setStringData(stringData);
            numOfStrings->setText(QString::number(stringData.strings()));
            }
      }
Пример #5
0
void EditStaff::maxPitchPClicked()
      {
      int         newCode;

      EditPitch* ep = new EditPitch(this, instrument.maxPitchP() );
      if ( (newCode=ep->exec()) != -1) {
            maxPitchP->setText(midiCodeToStr(newCode));
            _maxPitchP = newCode;
            }
      }
Пример #6
0
void EditStaff::minPitchAClicked()
      {
      int         newCode;

      EditPitch* ep = new EditPitch(this, instrument.minPitchA() );
      if ( (newCode=ep->exec()) != -1) {
            minPitchA->setText(midiCodeToStr(newCode));
            _minPitchA = newCode;
            }
      }
Пример #7
0
void EditStaff::maxPitchPClicked()
      {
      int         newCode;
      EditPitch ep(this, instrument.maxPitchP());
      ep.setWindowModality(Qt::WindowModal);
      if ( (newCode = ep.exec()) != -1) {
            maxPitchP->setText(midiCodeToStr(newCode));
            _maxPitchP = newCode;
            }
      }
Пример #8
0
void EditStaff::minPitchPClicked()
      {
      int         newCode;
      EditPitch* ep = new EditPitch(this, instrument.minPitchP() );
      ep->setWindowModality(Qt::WindowModal);
      if ( (newCode=ep->exec()) != -1) {
            minPitchP->setText(midiCodeToStr(newCode));
            _minPitchP = newCode;
            }
      }
Пример #9
0
void EditStringData::editStringClicked()
      {
      int         i = stringList->currentRow();
      int         newCode;

      EditPitch* ep = new EditPitch(this, _stringsLoc[i]);
      if ( (newCode=ep->exec()) != -1) {
            // update item value in local string list and item text in dlg list control
            _stringsLoc[i] = newCode;
            QListWidgetItem * item = stringList->item(i);
            item->setText(midiCodeToStr(newCode));
            _modified = true;
            }
      }
Пример #10
0
EditStringData::EditStringData(QWidget *parent, QList<int> * strings, int * frets)
   : QDialog(parent)
      {
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
      _strings = strings;
      // if any string, insert into string list control and select the first one
      if(_strings->size()) {
            int   i, j;
            // insert into local working copy sorting by decreasing MIDI code value
/*            foreach(i, *_strings) {
                  for(j=_stringsLoc.size()-1; j >= 0 && i > _stringsLoc[j]; j--)
                        ;
                  _stringsLoc.insert(j+1, i);
                  }
            // add to string list dlg control
            foreach(i, _stringsLoc)
                  stringList->addItem(midiCodeToStr(i));
            stringList->setCurrentRow(0);
*/
            // insert into local working copy and into string list dlg control
            // IN REVERSED ORDER
            for(i=_strings->size()-1; i >= 0; i--) {
                  j = (*_strings)[i];
                  _stringsLoc.append(j);
                  stringList->addItem(midiCodeToStr(j));
                  }
            stringList->setCurrentRow(0);
            }
      // if no string yet, disable buttons acting on individual string
      else {
            editString->setEnabled(false);
            deleteString->setEnabled(false);
            }

      _frets = frets;
      numOfFrets->setValue(*_frets);

      connect(deleteString, SIGNAL(clicked()), SLOT(deleteStringClicked()));
      connect(editString,   SIGNAL(clicked()), SLOT(editStringClicked()));
      connect(newString,    SIGNAL(clicked()), SLOT(newStringClicked()));
      connect(stringList,   SIGNAL(doubleClicked(QModelIndex)), SLOT(editStringClicked()));
      _modified = false;
      }