From fc6ec44021ffb17f80bcd4dd3d093bdc0a1b24cf Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Sat, 4 Dec 2010 03:42:47 +0000 Subject: Completed port of MidiInstrument, which fixes trackinfo instr. prog spinboxes not updating. --- muse2/ChangeLog | 2 ++ muse2/muse/instruments/minstrument.cpp | 41 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 19 deletions(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index a2f97124..37977eb4 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -2,6 +2,8 @@ - Ported all copy/paste/drag/drop coding. Including pianoroll, drumedit, pcanvas, prcanvas, dcanvas, and effect rack. Test OK cut, copy, paste, also drag n drop various files to arranger and rack. (Tim) - Fixed arranger menu cut/copy enabling. Was never right before. Test OK cut and copy. (Tim) + - Completed port of MidiInstrument. Fixed its populatePatchPopup(), which fixes midi trackinfo + instrument selection not updating h-bank, l-bank, and prog spinboxes. (Tim) 02.12.2010 - Ported alayout, tlist, arranger (Orcan) - Minor tweak in the HeaderNew API to set column widths easier. Also commented out the diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp index 9f6159dc..4f0dcc3a 100644 --- a/muse2/muse/instruments/minstrument.cpp +++ b/muse2/muse/instruments/minstrument.cpp @@ -8,8 +8,9 @@ #include -#include -#include +#include +#include +#include #include "minstrument.h" #include "midiport.h" @@ -186,7 +187,7 @@ static void loadIDF(QFileInfo* fi) if (f == 0) return; if (debugMsg) - printf("READ IDF %s\n", fi->filePath().latin1()); + printf("READ IDF %s\n", fi->filePath().toLatin1().data()); Xml xml(f); bool skipmode = true; @@ -245,7 +246,7 @@ void initMidiInstruments() genericMidiInstrument = new MidiInstrument(QWidget::tr("generic midi")); midiInstruments.push_back(genericMidiInstrument); if (debugMsg) - printf("load user instrument definitions from <%s>\n", museUserInstruments.latin1()); + printf("load user instrument definitions from <%s>\n", museUserInstruments.toLatin1().data()); QDir usrInstrumentsDir(museUserInstruments, QString("*.idf")); if (usrInstrumentsDir.exists()) { QFileInfoList list = usrInstrumentsDir.entryInfoList(); @@ -264,7 +265,7 @@ void initMidiInstruments() //} if (debugMsg) - printf("load instrument definitions from <%s>\n", museInstruments.latin1()); + printf("load instrument definitions from <%s>\n", museInstruments.toLatin1().data()); QDir instrumentsDir(museInstruments, QString("*.idf")); if (instrumentsDir.exists()) { QFileInfoList list = instrumentsDir.entryInfoList(); @@ -275,7 +276,7 @@ void initMidiInstruments() } } else - printf("Instrument directory not found: %s\n", museInstruments.latin1()); + printf("Instrument directory not found: %s\n", museInstruments.toLatin1().data()); } @@ -613,7 +614,7 @@ void Patch::write(int level, Xml& xml) // s += QString(" mode=\"%d\"").arg(typ); //s += QString(" hbank=\"%1\" lbank=\"%2\" prog=\"%3\"").arg(hbank).arg(lbank).arg(prog); //xml.tagE(s); - xml.nput(level, " 1) { _initScript = new char[len]; @@ -753,14 +754,14 @@ void MidiInstrument::write(int level, Xml& xml) xml.tag(level, "muse version=\"1.0\""); //xml.stag(QString("MidiInstrument name=\"%1\"").arg(Xml::xmlString(iname()))); level++; - //xml.tag(level, "MidiInstrument name=\"%s\"", Xml::xmlString(iname()).latin1()); - xml.nput(level, ""); @@ -776,8 +777,8 @@ void MidiInstrument::write(int level, Xml& xml) PatchGroup* pgp = *g; const PatchList& pl = pgp->patches; //xml.stag(QString("PatchGroup name=\"%1\"").arg(Xml::xmlString(g->name))); - //xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(g->name).latin1()); - xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).latin1()); + //xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(g->name).toLatin1().data()); + xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().data()); level++; //for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p) for (ciPatch p = pl.begin(); p != pl.end(); ++p) @@ -846,7 +847,7 @@ const char* MidiInstrument::getPatchName(int channel, int prog, MType mode, bool && (hbank == mp->hbank || !hb || mp->hbank == -1) && (lbank == mp->lbank || !lb || mp->lbank == -1)) - return mp->name.latin1(); + return mp->name.toLatin1().data(); } } return ""; @@ -874,8 +875,7 @@ void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, b if (pg.size() > 1) { for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) { PatchGroup* pgp = *i; - QMenu* pm = new QMenu(menu); - pm->setCheckable(false); + QMenu* pm = menu->addMenu(pgp->name); pm->setFont(config.fonts[0]); const PatchList& pl = pgp->patches; for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) { @@ -886,11 +886,12 @@ void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, b { int id = ((mp->hbank & 0xff) << 16) + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff); - pm->insertItem(mp->name, id); + QAction* act = pm->addAction(mp->name); + //act->setCheckable(true); + act->setData(id); } } - menu->insertItem(pgp->name, pm); } } else if (pg.size() == 1 ){ @@ -901,7 +902,9 @@ void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, b if (mp->typ & mask) { int id = ((mp->hbank & 0xff) << 16) + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff); - menu->insertItem(mp->name, id); + QAction* act = menu->addAction(mp->name); + //act->setCheckable(true); + act->setData(id); } } } -- cgit v1.2.3