void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
      {
      if (n == 0)
            return;
      if (o)
            saveCurrent(o);
      // retrieve staff type corresponding to new current item in type list
      int idx = n->data(Qt::UserRole).toInt();
      StaffType* st = staffTypes[idx];

      // switch to stack page and set props specific to each staff group

      switch(st->group()) {
            case STANDARD_STAFF_GROUP:
                  {
                  StaffTypePitched* ps = static_cast<StaffTypePitched*>(st);
                  stack->setCurrentIndex(0);
                  name->setText(st->name());
                  lines->setValue(st->lines());
                  lineDistance->setValue(st->lineDistance().val());
                  genClef->setChecked(st->genClef());
                  showBarlines->setChecked(st->showBarlines());
                  genTimesig->setChecked(st->genTimesig());
                  genKeysigPitched->setChecked(ps->genKeysig());
                  showLedgerLinesPitched->setChecked(ps->showLedgerLines());
                  stemlessPitched->setChecked(st->slashStyle());
                  }
                  break;

            case TAB_STAFF_GROUP:
                  {
                  StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
                  blockTabPreviewSignals(true);
                  setDlgFromTab(stt);
                  name->setText(stt->name());   // setDlgFromTab() does not copy the name and it shouldn't
                  stack->setCurrentIndex(1);
                  blockTabPreviewSignals(false);
                  }
                  break;

            case PERCUSSION_STAFF_GROUP:
                  {
                  StaffTypePercussion* ps = static_cast<StaffTypePercussion*>(st);
                  blockPercPreviewSignals(true);
                  setDlgFromPerc(ps);
                  name->setText(ps->name());   // setDlgFromPerc() does not copy the name and it shouldn't
                  stack->setCurrentIndex(2);
                  blockPercPreviewSignals(false);
                  }
                  break;
            }
      }
void EditStaffType::createNewType()
      {
      //
      // initialize new StaffType with current selected one
      //
      int idx       = staffTypeList->currentItem()->data(Qt::UserRole).toInt();
      StaffType* ns = staffTypes[idx]->clone();

      ns->setName(createUniqueStaffTypeName(ns->group()));

      staffTypes.append(ns);
      QListWidgetItem* item = new QListWidgetItem(ns->name());
      item->setData(Qt::UserRole, staffTypes.size() - 1);
      staffTypeList->addItem(item);
      staffTypeList->setCurrentItem(item);
      modified = true;
      }
Example #3
0
void EditStaff::fillStaffTypeCombo()
      {
      Score* score   = staff->score();
      int curIdx     = 0;
      int n          = score->staffTypes().size();
      // can this instrument accept tabs or drum set?
      bool canUseTabs = instrument.stringData() && instrument.stringData()->strings() > 0;
      bool canUsePerc = instrument.useDrumset();
      staffType->clear();
      for (int idx = 0; idx < n; ++idx) {
            StaffType* st = score->staffType(idx);
            if ( (canUseTabs && st->group() == TAB_STAFF_GROUP)
                        || ( canUsePerc && st->group() == PERCUSSION_STAFF_GROUP)
                        || (!canUsePerc && st->group() == STANDARD_STAFF_GROUP) ) {
                  staffType->addItem(st->name(), idx);
                  if (st == staff->staffType())
                        curIdx = staffType->count() - 1;
                  }
            }
      staffType->setCurrentIndex(curIdx);
      }
Example #4
0
void EditStaffType::createNewType()
      {
      //
      // initialize new StaffType with current selected one
      //
      int idx       = staffTypeList->currentItem()->data(Qt::UserRole).toInt();
      StaffType* ns = staffTypes[idx]->clone();

      //
      // create unique new name for StaffType
      //
      // count how many types there are already of the same group of the new type
      for (int i = idx = 0; i < staffTypes.count(); i++)
            if (staffTypes[i]->group() == ns->group())
                  idx++;
      QString name;
      switch (ns->group())
      {
            case STANDARD_STAFF_GROUP:
                  name = QString("Standard-%1 [*]").arg(idx);
                  break;
            case PERCUSSION_STAFF_GROUP:
                  name = QString("Perc-%1 [*]").arg(idx);
                  break;
            case TAB_STAFF_GROUP:
                  name = QString("Tab-%1 [*]").arg(idx);
                  break;
      }
      ns->setName(name);

      staffTypes.append(ns);
      QListWidgetItem* item = new QListWidgetItem(ns->name());
      item->setData(Qt::UserRole, staffTypes.size() - 1);
      staffTypeList->addItem(item);
      staffTypeList->setCurrentItem(item);
      modified = true;
      }
void EditStaffType::saveCurrent(QListWidgetItem* o)
      {
      bool        modif = false;                            // assume no modifications
      int         idx   = o->data(Qt::UserRole).toInt();
      StaffType*  st    = staffTypes[idx];

      // if any of the common properties is modified
      if (name->text()              != st->name()
         || st->lines()             != lines->value()
         || st->lineDistance().val()!= lineDistance->value()
         || st->genClef()           != genClef->isChecked()
         || st->showBarlines()      != showBarlines->isChecked()
         || st->genTimesig()        != genTimesig->isChecked()
         ) {
            modif = true;
            }

      // or if any of the props specific to each group is modified
      switch(st->group()) {
            case STANDARD_STAFF_GROUP:
                  {
                  StaffTypePitched* sp = static_cast<StaffTypePitched*>(st);
                  if (sp->genKeysig()         != genKeysigPitched->isChecked()
                     || sp->showLedgerLines() != showLedgerLinesPitched->isChecked()
                     || st->slashStyle()      != stemlessPitched->isChecked()
                     ) {
                        modif = true;
                        }
                  }
                  break;

            case TAB_STAFF_GROUP:
                  {
                  StaffTypeTablature*  stt = static_cast<StaffTypeTablature*>(st);
                  TablatureMinimStyle minimStyle = minimNoneRadio->isChecked() ? TAB_MINIM_NONE :
                        (minimShortRadio->isChecked() ? TAB_MINIM_SHORTER : TAB_MINIM_SLASHED);
                  if (stt->durationFontName()    != durFontName->currentText()
                     || stt->durationFontSize() != durFontSize->value()
                     || stt->durationFontUserY()!= durY->value()
                     || stt->fretFontName()     != fretFontName->currentText()
                     || stt->fretFontSize()     != fretFontSize->value()
                     || stt->fretFontUserY()    != fretY->value()
                     || stt->linesThrough()     != linesThroughRadio->isChecked()
                     || stt->onLines()          != onLinesRadio->isChecked()
                     || stt->upsideDown()       != upsideDown->isChecked()
                     || stt->useNumbers()       != numbersRadio->isChecked()
                     || ( noteValuesNone->isChecked() && (!stt->slashStyle() ||  stt->genDurations()) )
                     || ( noteValuesSymb->isChecked() && (!stt->slashStyle() || !stt->genDurations()) )
                     // if stems, there are more values to take into account
                     || ( noteValuesStems->isChecked()&& ( stt->slashStyle() ||  stt->genDurations()
                              || stt->stemsDown()     != stemBelowRadio->isChecked()
                              || stt->stemThrough()   != stemThroughRadio->isChecked()
                              || stt->minimStyle()    != minimStyle)
                          )
                     || stt->showRests()        != showRests->isChecked()
                     ) {
                        modif = true;
                        }
                  }
                  break;

            case PERCUSSION_STAFF_GROUP:
                  {
                  StaffTypePercussion* sp = static_cast<StaffTypePercussion*>(st);
                  if (sp->genKeysig()         != genKeysigPercussion->isChecked()
                     || sp->showLedgerLines() != showLedgerLinesPercussion->isChecked()
                     || st->slashStyle()      != stemlessPercussion->isChecked()
                     ) {
                        modif = true;
                        }
                  }
                  break;
            }

      if (modif) {
            // save common properties
            // save-group specific properties
            if(name->text().isEmpty()) {
                  QString n = createUniqueStaffTypeName(st->group());
                  name->setText(n);
                  o->setText(n);
                  }
            switch(st->group()) {
                  case STANDARD_STAFF_GROUP:
                        {
                        StaffTypePitched* stp = static_cast<StaffTypePitched*>(st);
                        stp->setName(name->text());
                        stp->setLines(lines->value());
                        stp->setLineDistance(Spatium(lineDistance->value()));
                        stp->setShowBarlines(showBarlines->isChecked());
                        stp->setGenClef(genClef->isChecked());
                        stp->setGenTimesig(genTimesig->isChecked());
                        stp->setGenKeysig(genKeysigPitched->isChecked());
                        stp->setShowLedgerLines(showLedgerLinesPitched->isChecked());
                        stp->setSlashStyle(stemlessPitched->isChecked());
                        }
                        break;
                  case TAB_STAFF_GROUP:
                        {
                        StaffTypeTablature*  stt = static_cast<StaffTypeTablature*>(st);
                        setTabFromDlg(stt);
                        }
                        break;
                  case PERCUSSION_STAFF_GROUP:
                        {
                        StaffTypePercussion* stp = static_cast<StaffTypePercussion*>(st);
                        setPercFromDlg(stp);
                        }
                        break;
                  }
            modified = true;
            }
      }