Any instrument which does not have string data is given a default guitar-like string set.
Changed to a default empty string set. This also allows to filter out TAB staff types in staff props dlg box for an instrument without strings defined.
This commit is contained in:
parent
d7231267c6
commit
537501f90d
8 changed files with 47 additions and 62 deletions
|
@ -133,7 +133,7 @@ InstrumentData::~InstrumentData()
|
|||
|
||||
Tablature* InstrumentData::tablature() const
|
||||
{
|
||||
return _tablature ? _tablature : &guitarTablature;
|
||||
return _tablature ? _tablature : &emptyStringData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#include "score.h"
|
||||
#include "undo.h"
|
||||
|
||||
static int guitarStrings[6] = { 40, 45, 50, 55, 59, 64 };
|
||||
//static int guitarStrings[6] = { 40, 45, 50, 55, 59, 64 };
|
||||
|
||||
Tablature guitarTablature(23, 6, guitarStrings);
|
||||
Tablature emptyStringData(0, 0, 0);
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Tablature
|
||||
|
@ -26,6 +26,12 @@ Tablature guitarTablature(23, 6, guitarStrings);
|
|||
|
||||
bool Tablature::bFretting = false;
|
||||
|
||||
Tablature::Tablature()
|
||||
{
|
||||
_frets = 0;
|
||||
stringTable = QList<int>();
|
||||
}
|
||||
|
||||
Tablature::Tablature(int numFrets, int numStrings, int strings[])
|
||||
{
|
||||
_frets = numFrets;
|
||||
|
|
|
@ -28,7 +28,7 @@ class Tablature {
|
|||
static bool bFretting;
|
||||
|
||||
public:
|
||||
Tablature() {}
|
||||
Tablature();
|
||||
Tablature(int numFrets, int numStrings, int strings[]);
|
||||
Tablature(int numFrets, QList<int>& strings);
|
||||
bool convertPitch(int pitch, int* string, int* fret) const;
|
||||
|
@ -46,6 +46,6 @@ public:
|
|||
void writeMusicXML(Xml& xml) const;
|
||||
};
|
||||
|
||||
extern Tablature guitarTablature;
|
||||
extern Tablature emptyStringData;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,20 +49,9 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)
|
|||
|
||||
Part* part = staff->part();
|
||||
instrument = *part->instr();
|
||||
|
||||
Score* score = part->score();
|
||||
int curIdx = 0;
|
||||
int n = score->staffTypes().size();
|
||||
printf("staff types %d\n", n);
|
||||
for (int idx = 0; idx < n; ++idx) {
|
||||
StaffType* st = score->staffType(idx);
|
||||
printf(" %d <%s>\n", idx, qPrintable(st->name()));
|
||||
staffType->addItem(st->name(), idx);
|
||||
if (st == s->staffType())
|
||||
curIdx = idx;
|
||||
}
|
||||
staffType->setCurrentIndex(curIdx);
|
||||
|
||||
fillStaffTypeCombo();
|
||||
small->setChecked(staff->small());
|
||||
invisible->setChecked(staff->invisible());
|
||||
spinExtraDistance->setValue(s->userDist() / score->spatium());
|
||||
|
@ -81,6 +70,29 @@ printf(" %d <%s>\n", idx, qPrintable(st->name()));
|
|||
connect(editStringData, SIGNAL(clicked()), SLOT(editStringDataClicked()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// fillStaffTypecombo
|
||||
//---------------------------------------------------------
|
||||
|
||||
void EditStaff::fillStaffTypeCombo()
|
||||
{
|
||||
Score* score = staff->score();
|
||||
int curIdx = 0;
|
||||
int n = score->staffTypes().size();
|
||||
// can this instrument accept tabs?
|
||||
bool acceptTab = instrument.tablature() && instrument.tablature()->strings() != 0;
|
||||
staffType->clear();
|
||||
for (int idx = 0; idx < n; ++idx) {
|
||||
StaffType* st = score->staffType(idx);
|
||||
if (acceptTab || st->group() != TAB_STAFF) {
|
||||
staffType->addItem(st->name(), idx);
|
||||
if (st == staff->staffType())
|
||||
curIdx = idx;
|
||||
}
|
||||
}
|
||||
staffType->setCurrentIndex(curIdx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// updateInstrument
|
||||
//---------------------------------------------------------
|
||||
|
@ -333,9 +345,14 @@ void EditStaff::editStringDataClicked()
|
|||
EditStringData* esd = new EditStringData(this, &stringList, &frets);
|
||||
if (esd->exec()) {
|
||||
Tablature * tab = new Tablature(frets, stringList);
|
||||
// detect number of strings going from 0 to !0 or vice versa
|
||||
bool redoStaffTypeCombo =
|
||||
(stringList.size() != 0) != (instrument.tablature()->strings() != 0);
|
||||
instrument.setTablature(tab);
|
||||
int numStr = tab ? tab->strings() : 0;
|
||||
numOfStrings->setText(QString::number(numStr));
|
||||
if (redoStaffTypeCombo)
|
||||
fillStaffTypeCombo();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class EditStaff : public QDialog, private Ui::EditStaffBase {
|
|||
int _minPitchA, _maxPitchA, _minPitchP, _maxPitchP;
|
||||
|
||||
void apply();
|
||||
void fillStaffTypeCombo();
|
||||
void setInterval(const Interval&);
|
||||
void updateInstrument();
|
||||
|
||||
|
|
|
@ -35,17 +35,6 @@ EditStringData::EditStringData(QWidget *parent, QList<int> * strings, int * fret
|
|||
// 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--) {
|
||||
|
@ -73,21 +62,8 @@ EditStringData::EditStringData(QWidget *parent, QList<int> * strings, int * fret
|
|||
|
||||
EditStringData::~EditStringData()
|
||||
{
|
||||
// delete ui;
|
||||
}
|
||||
/*
|
||||
void EditStringData::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------
|
||||
// deleteStringClicked
|
||||
//---------------------------------------------------------
|
||||
|
@ -136,15 +112,6 @@ void EditStringData::newStringClicked()
|
|||
|
||||
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)
|
||||
|
|
|
@ -21,13 +21,8 @@
|
|||
#ifndef EDITSTRINGDATA_H
|
||||
#define EDITSTRINGDATA_H
|
||||
|
||||
//#include <QDialog>
|
||||
#include "ui_editstringdata.h"
|
||||
/*
|
||||
namespace Ui {
|
||||
class EditStringData;
|
||||
}
|
||||
*/
|
||||
|
||||
class EditStringData : public QDialog, private Ui::EditStringDataBase {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -41,12 +36,8 @@ class EditStringData : public QDialog, private Ui::EditStringDataBase {
|
|||
~EditStringData();
|
||||
|
||||
protected:
|
||||
// void changeEvent(QEvent *e);
|
||||
QString midiCodeToStr(int midiCode);
|
||||
|
||||
//private:
|
||||
// Ui::EditStringData *ui;
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
void deleteStringClicked();
|
||||
|
|
|
@ -118,7 +118,10 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue