summaryrefslogtreecommitdiff
path: root/muse2/muse/app.cpp
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2011-05-26 00:18:47 +0000
committerTim E. Real <termtech@rogers.com>2011-05-26 00:18:47 +0000
commite8612708161b71b43d56ef47eede6cc58b035967 (patch)
tree18580394352c090068325ded37a8f53d6807c4a0 /muse2/muse/app.cpp
parenta1db21404d203bec7353099a9947778735271bfd (diff)
Moved all routing popup menu stuff from app, astrip, mstrip, mtrackinfo into new class RoutePopupMenu,
*massively* cleaning up those 4 files. Used new Route QVariant type as action data instead of integers. Moved MenuTitleItem definitions from astrip.cpp into it's own menutitleitem.cpp Added to settings: "Make popup menus stay open. Otherwise hold Ctrl."
Diffstat (limited to 'muse2/muse/app.cpp')
-rw-r--r--muse2/muse/app.cpp796
1 files changed, 10 insertions, 786 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 62871b18..72cdad6a 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -43,7 +43,7 @@
#include "mixdowndialog.h"
#include "pianoroll.h"
#include "scoreedit.h"
-#include "popupmenu.h"
+#include "routepopup.h"
#include "shortcutconfig.h"
#include "songinfo.h"
#include "ticksynth.h"
@@ -93,7 +93,6 @@ static QString* projectList[PROJECT_LIST_LEN];
extern void initMidiSynth();
extern void exitJackAudio();
extern void exitDummyAudio();
-// p3.3.39
extern void exitOSC();
#ifdef HAVE_LASH
@@ -809,7 +808,6 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
editInstrument = 0;
routingPopupMenu = 0;
progress = 0;
- //routingPopupView = 0;
appName = QString("MusE");
setWindowTitle(appName);
@@ -1658,7 +1656,6 @@ void MusE::initMidiDevices()
audio->msgInitMidiDevices();
- // Added by T356
//audio->msgIdle(false);
}
@@ -2080,7 +2077,7 @@ bool MusE::save(const QString& name, bool overwriteWarn)
if (ferror(f)) {
QString s = "Write File\n" + name + "\nfailed: "
//+ strerror(errno);
- + QString(strerror(errno)); // p4.0.0
+ + QString(strerror(errno));
QMessageBox::critical(this,
tr("MusE: Write File failed"), s);
popenFlag? pclose(f) : fclose(f);
@@ -2172,10 +2169,10 @@ void MusE::closeEvent(QCloseEvent* event)
printf("MusE: Exiting Metronome\n");
exitMetronome();
- // p3.3.47
- // Make sure to clear the menu, which deletes any sub menus.
+ // Make sure to delete the menu. ~routingPopupMenu() will NOT be called automatically.
+ // Even though it is a child of MusE, it just passes MusE onto the underlying PopupMenus. p4.0.26
if(routingPopupMenu)
- routingPopupMenu->clear();
+ delete routingPopupMenu;
#if 0
if(routingPopupView)
{
@@ -2201,10 +2198,8 @@ void MusE::closeEvent(QCloseEvent* event)
d.remove(f.completeBaseName() + ".wca");
}
- // Added by Tim. p3.3.14
-
#ifdef HAVE_LASH
- // Disconnect gracefully from LASH.
+ // Disconnect gracefully from LASH. Tim. p3.3.14
if(lash_client)
{
if(debugMsg)
@@ -2292,789 +2287,18 @@ void MusE::showTransport(bool flag)
//---------------------------------------------------------
// getRoutingPopupMenu
+// Get the special common routing popup menu. Used (so far)
+// by audio strip, midi strip, and midi trackinfo.
//---------------------------------------------------------
-PopupMenu* MusE::getRoutingPopupMenu()
+RoutePopupMenu* MusE::getRoutingPopupMenu()
{
if(!routingPopupMenu)
- routingPopupMenu = new PopupMenu(this, true);
+ routingPopupMenu = new RoutePopupMenu(this);
return routingPopupMenu;
}
//---------------------------------------------------------
-// updateRouteMenus
-//---------------------------------------------------------
-
-void MusE::updateRouteMenus(Track* track, QObject* master)
-{
- // NOTE: The purpose of this routine is to make sure the items actually reflect
- // the routing status.
- // In case for some reason a route could not be added (or removed).
- // Then the item will be properly un-checked (or checked) here.
-
- //if(!track || track != gRoutingPopupMenuMaster || track->type() == Track::AUDIO_AUX)
- //if(!track || track->type() == Track::AUDIO_AUX)
- if(!track || gRoutingPopupMenuMaster != master) // p3.3.50
- return;
-
- PopupMenu* pup = getRoutingPopupMenu();
-
- if(pup->actions().isEmpty())
- return;
-
- if(!pup->isVisible())
- return;
-
- //AudioTrack* t = (AudioTrack*)track;
- RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
-
- iRouteMenuMap imm = gRoutingMenuMap.begin();
- for(; imm != gRoutingMenuMap.end(); ++imm)
- {
- // p3.3.50 Ignore the 'toggle' items.
- if(imm->second.type == Route::MIDI_PORT_ROUTE &&
- //imm->first >= (MIDI_PORTS * MIDI_CHANNELS) && imm->first < (MIDI_PORTS * MIDI_CHANNELS + MIDI_PORTS))
- imm->second.channel == (1 << MIDI_CHANNELS) - 1) // p4.0.14 See if all channels are set, rather than using ID.
- continue;
-
-
- // p4.0.14 TODO FIXME Couldn't quite figure out the logic yet. It should be possible (I hope).
- // But not really required for now, as per above note.
- if(gIsOutRoutingPopupMenu && track->isMidiTrack() &&
- imm->second.type == Route::TRACK_ROUTE && imm->second.track->type() == Track::AUDIO_INPUT)
- return;
- #if 0
- printf("imm route:\n");
- imm->second.dump();
- if(track->isMidiTrack())
- {
- if(imm->second.type == Route::TRACK_ROUTE && imm->second.track->type() == Track::AUDIO_INPUT)
- {
- Route &aRoute = imm->second;
- int chbit = aRoute.channel;
- ///Route bRoute(track, chbit);
- ///int mdidx = bRoute.midiPort;
- int port = ((MidiTrack*)track)->outPort();
- if(port < 0 || port >= MIDI_PORTS)
- continue;
- int tchbit = 1 << ((MidiTrack*)track)->outChannel();
-
- MidiPort* mp = &midiPorts[port];
-
- ///Route bRoute(port, chbit);
-
- //int chmask = 0;
- bool found = false;
- RouteList* mprl = gIsOutRoutingPopupMenu ? mp->outRoutes() : mp->inRoutes();
- iRoute ir = mprl->begin();
- for(; ir != mprl->end(); ++ir)
- {
- printf("mp route:\n");
- ir->dump();
- ///if(aRoute.type == Route::TRACK_ROUTE) // Is the map route a track route?
- {
- if(ir->type == Route::TRACK_ROUTE && ir->track == aRoute.track) // Is the track route a midi port route?
- //&& (ir->channel & chbit) == chbit)
- //&& (ir->channel & tchbit)) // Is the exact channel mask bit(s) set?
- {
- printf("track matches\n");
- if(ir->channel & tchbit)
- {
- found = true;
- printf("found: bit matches\n");
- }
- break;
- }
- }
- ///else
- ///if(*ir == aRoute)
- ///{
- //found = true;
- /// break;
- ///}
- }
- //pup->setItemChecked(imm->first, found);
- //printf("MusE::updateRouteMenus setItemChecked\n");
- // TODO: MusE-2: Convert this, fastest way is to change the routing map, otherwise this requires a lookup.
- //if(pup->isItemChecked(imm->first) != (irl != rl->end()))
- // pup->setItemChecked(imm->first, irl != rl->end());
- QAction* act = pup->findActionFromData(imm->first);
- //printf("set act checked to:%d\n", ir != mprl->end());
- //if(act && act->isChecked() != (ir != mprl->end()))
- // act->setChecked(ir != mprl->end());
- printf("set act checked to:%d\n", found);
- if(act && act->isChecked() != found)
- act->setChecked(found);
-
- //return;
- }
- }
- #endif
-
- //bool found = false;
- iRoute irl = rl->begin();
- for(; irl != rl->end(); ++irl)
- {
- if(imm->second.type == Route::MIDI_PORT_ROUTE) // p3.3.50 Is the map route a midi port route?
- {
- if(irl->type == Route::MIDI_PORT_ROUTE && irl->midiPort == imm->second.midiPort // Is the track route a midi port route?
- && (irl->channel & imm->second.channel) == imm->second.channel) // Is the exact channel mask bit(s) set?
- {
- //found = true;
- break;
- }
- }
- else
- if(*irl == imm->second)
- {
- //found = true;
- break;
- }
- }
- //pup->setItemChecked(imm->first, found);
- //printf("MusE::updateRouteMenus setItemChecked\n");
- // TODO: MusE-2: Convert this, fastest way is to change the routing map, otherwise this requires a lookup.
- //if(pup->isItemChecked(imm->first) != (irl != rl->end()))
- // pup->setItemChecked(imm->first, irl != rl->end());
- QAction* act = pup->findActionFromData(imm->first);
- if(act && act->isChecked() != (irl != rl->end()))
- act->setChecked(irl != rl->end());
- }
-}
-
-//---------------------------------------------------------
-// routingPopupMenuActivated
-//---------------------------------------------------------
-
-void MusE::routingPopupMenuActivated(Track* track, int n)
-{
- //if(!track || (track != gRoutingPopupMenuMaster))
- if(!track)
- return;
-
- if(track->isMidiTrack())
- {
- PopupMenu* pup = getRoutingPopupMenu();
-
- if(pup->actions().isEmpty())
- return;
-
- //MidiTrack* t = (MidiTrack*)track;
- RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
-
- if(n == -1)
- return;
-
- if(!gIsOutRoutingPopupMenu && n == 0) // p4.0.17
- {
- muse->configMidiPorts();
- return;
- }
-
- iRouteMenuMap imm = gRoutingMenuMap.find(n);
- if(imm == gRoutingMenuMap.end())
- return;
-
- // Support Midi Port to Audio Input track routes. p4.0.14 Tim.
- if(imm->second.type == Route::TRACK_ROUTE)
- {
- //if(gIsOutRoutingPopupMenu) // Try to avoid splitting like this.
- {
- Route &aRoute = imm->second;
- int chbit = aRoute.channel;
- int port = ((MidiTrack*)track)->outPort();
- if(port < 0 || port >= MIDI_PORTS)
- return;
-
- MidiPort* mp = &midiPorts[port];
- ///MidiDevice* md = mp->device();
-
- // This is desirable, but could lead to 'hidden' routes unless we add more support
- // such as removing the existing routes when user changes flags.
- // So for now, just list all valid ports whether read or write.
- ///if(!md)
- /// return;
- ///if(!(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2)))
- /// return;
-
- //int channel = ((MidiTrack*)track->outChannel();
- Route bRoute(port, chbit);
-
- int chmask = 0;
- RouteList* mprl = gIsOutRoutingPopupMenu ? mp->outRoutes() : mp->inRoutes();
- iRoute ir = mprl->begin();
- for (; ir != mprl->end(); ++ir)
- {
- if(ir->type == Route::TRACK_ROUTE && ir->track == aRoute.track) // Is there already a route to this port?
- {
- chmask = ir->channel; // Grab the channel mask.
- break;
- }
- }
- //if (iir != rl->end())
- if ((chmask & chbit) == chbit) // Is the channel's bit(s) set?
- {
- // disconnect
- if(gIsOutRoutingPopupMenu)
- audio->msgRemoveRoute(bRoute, aRoute);
- else
- audio->msgRemoveRoute(aRoute, bRoute);
- }
- else
- {
- // connect
- if(gIsOutRoutingPopupMenu)
- audio->msgAddRoute(bRoute, aRoute);
- else
- audio->msgAddRoute(aRoute, bRoute);
- }
-
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
-
- }
- return;
- }
-
-
- if(imm->second.type != Route::MIDI_PORT_ROUTE)
- return;
- Route &aRoute = imm->second;
- int chbit = aRoute.channel;
- Route bRoute(track, chbit);
- int mdidx = aRoute.midiPort;
-
- MidiPort* mp = &midiPorts[mdidx];
- MidiDevice* md = mp->device();
- //if(!md) // Removed p4.0.17 Allow connections to ports with no device.
- // return;
-
- //if(!(md->rwFlags() & 2))
- //if(!(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2)))
- if(md && !(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2))) // p4.0.17
- return;
-
- int chmask = 0;
- iRoute iir = rl->begin();
- for (; iir != rl->end(); ++iir)
- {
- //if(*iir == (dst ? bRoute : aRoute))
- //if(*iir == aRoute)
- if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == mdidx) // p3.3.50 Is there already a route to this port?
- {
- chmask = iir->channel; // p3.3.50 Grab the channel mask.
- break;
- }
- }
- //if (iir != rl->end())
- if ((chmask & chbit) == chbit) // p3.3.50 Is the channel's bit(s) set?
- {
- // disconnect
- if(gIsOutRoutingPopupMenu)
- audio->msgRemoveRoute(bRoute, aRoute);
- else
- audio->msgRemoveRoute(aRoute, bRoute);
- }
- else
- {
- // connect
- if(gIsOutRoutingPopupMenu)
- audio->msgAddRoute(bRoute, aRoute);
- else
- audio->msgAddRoute(aRoute, bRoute);
- }
-
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
- }
- else
- {
- // TODO: Try to move code from AudioStrip::routingPopupMenuActivated into here.
-
- /*
- PopupMenu* pup = getRoutingPopupMenu();
-
- printf("MusE::routingPopupMenuActivated audio n:%d count:%d\n", n, pup->count());
-
- if(pup->count() == 0)
- return;
-
- AudioTrack* t = (AudioTrack*)track;
- RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
-
- //QPoint ppt = QCursor::pos();
-
- if(n == -1)
- {
- //printf("MusE::routingPopupMenuActivated audio n = -1 deleting popup...\n");
- printf("MusE::routingPopupMenuActivated audio n = -1\n");
- ///delete pup;
- ///pup = 0;
- return;
- }
- else
- //if(n == 0)
- //{
- //printf("MusE::routingPopupMenuActivated audio n = 0 = tearOffHandle\n");
- //oR->setDown(false);
- // return;
- //}
- //else
- {
- if(gIsOutRoutingPopupMenu)
- {
- QString s(pup->text(n));
-
- //printf("AudioStrip::routingPopupMenuActivated audio text:%s\n", s.toLatin1().constData());
-
- if(track->type() == Track::AUDIO_OUTPUT)
- {
- ///delete orpup;
-
- int chan = n & 0xf;
-
- //Route srcRoute(t, -1);
- //Route srcRoute(t, chan, chans);
- //Route srcRoute(t, chan, 1);
- Route srcRoute(t, chan);
-
- //Route dstRoute(s, true, -1);
- Route dstRoute(s, true, -1, Route::JACK_ROUTE);
- //Route dstRoute(s, true, 0, Route::JACK_ROUTE);
-
- //srcRoute.channel = dstRoute.channel = chan;
- dstRoute.channel = chan;
- //dstRoute.channels = 1;
-
- // check if route src->dst exists:
- iRoute irl = rl->begin();
- for (; irl != rl->end(); ++irl) {
- if (*irl == dstRoute)
- break;
- }
- if (irl != rl->end()) {
- // disconnect if route exists
- audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
- // connect if route does not exist
- audio->msgAddRoute(srcRoute, dstRoute);
- }
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
-
- // p3.3.47
- //pup->popup(ppt, 0);
-
- //oR->setDown(false);
- return;
-
- // p3.3.46
- ///goto _redisplay;
- }
-
- iRouteMenuMap imm = gRoutingMenuMap.find(n);
- if(imm == gRoutingMenuMap.end())
- {
- ///delete orpup;
- //oR->setDown(false); // orpup->exec() catches mouse release event
- return;
- }
-
- //int chan = n >> 16;
- //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
- //chan &= 0xffff;
- //int chan = imm->second.channel;
- //int chans = imm->second.channels;
-
- //Route srcRoute(t, -1);
- //srcRoute.remoteChannel = chan;
- //Route srcRoute(t, chan, chans);
- Route srcRoute(t, imm->second.channel, imm->second.channels);
- //Route srcRoute(t, imm->second.channel);
- srcRoute.remoteChannel = imm->second.remoteChannel;
-
- //Route dstRoute(s, true, -1);
- //Route dstRoute(s, true, -1, Route::TRACK_ROUTE);
- Route &dstRoute = imm->second;
-
- // check if route src->dst exists:
- iRoute irl = rl->begin();
- for (; irl != rl->end(); ++irl) {
- if (*irl == dstRoute)
- break;
- }
- if (irl != rl->end()) {
- // disconnect if route exists
- audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
- // connect if route does not exist
- audio->msgAddRoute(srcRoute, dstRoute);
- }
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
-
- // p3.3.46
- //oR->setDown(false);
- ///goto _redisplay;
-
- // p3.3.47
- //pup->popup(ppt, 0);
- }
- else
- {
- QString s(pup->text(n));
-
- if(track->type() == Track::AUDIO_INPUT)
- {
- ///delete pup;
- int chan = n & 0xf;
-
- Route srcRoute(s, false, -1, Route::JACK_ROUTE);
- Route dstRoute(t, chan);
-
- srcRoute.channel = chan;
-
- iRoute irl = rl->begin();
- for(; irl != rl->end(); ++irl)
- {
- if(*irl == srcRoute)
- break;
- }
- if(irl != rl->end())
- // disconnect
- audio->msgRemoveRoute(srcRoute, dstRoute);
- else
- // connect
- audio->msgAddRoute(srcRoute, dstRoute);
-
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
- //iR->setDown(false); // pup->exec() catches mouse release event
- return;
-
- // p3.3.46
- ///goto _redisplay;
- }
-
- iRouteMenuMap imm = gRoutingMenuMap.find(n);
- if(imm == gRoutingMenuMap.end())
- {
- //delete pup;
- //iR->setDown(false); // pup->exec() catches mouse release event
- return;
- }
-
- //int chan = n >> 16;
- //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
- //chan &= 0xffff;
- //int chan = imm->second.channel;
- //int chans = imm->second.channels;
-
- //Route srcRoute(s, false, -1);
- //Route srcRoute(s, false, -1, Route::TRACK_ROUTE);
- Route &srcRoute = imm->second;
-
- //Route dstRoute(t, -1);
- //Route dstRoute(t, chan, chans);
- Route dstRoute(t, imm->second.channel, imm->second.channels);
- //Route dstRoute(t, imm->second.channel);
- dstRoute.remoteChannel = imm->second.remoteChannel;
-
- iRoute irl = rl->begin();
- for (; irl != rl->end(); ++irl) {
- if (*irl == srcRoute)
- break;
- }
- if (irl != rl->end()) {
- // disconnect
- audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
- // connect
- audio->msgAddRoute(srcRoute, dstRoute);
- }
- audio->msgUpdateSoloStates();
- song->update(SC_ROUTE);
-
- // p3.3.46
- //iR->setDown(false);
- ///goto _redisplay;
-
-
-
-
- }
-
- }
- */
-
- }
- //else
- //{
- //}
-}
-
-//---------------------------------------------------------
-// routingPopupMenuAboutToHide
-//---------------------------------------------------------
-
-void MusE::routingPopupMenuAboutToHide()
-{
- // Hmm, can't do this? Sub-menus stay open with this. Re-arranged, testing... Nope.
- //PopupMenu* pup = muse->getRoutingPopupMenu();
- //pup->disconnect();
- //pup->clear();
-
- gRoutingMenuMap.clear();
- gRoutingPopupMenuMaster = 0;
-}
-
-//---------------------------------------------------------
-// prepareRoutingPopupMenu
-//---------------------------------------------------------
-
-PopupMenu* MusE::prepareRoutingPopupMenu(Track* track, bool dst)
-{
- if(!track)
- return 0;
-
- if(track->isMidiTrack())
- {
- RouteList* rl = dst ? track->outRoutes() : track->inRoutes();
- //Route dst(track, -1);
-
- PopupMenu* pup = getRoutingPopupMenu();
- pup->disconnect();
- //connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
- //connect(pup, SIGNAL(aboutToHide()), SLOT(routingPopupMenuAboutToHide()));
-
- pup->clear();
- gRoutingMenuMap.clear();
-
- int gid = 0;
- QAction* act = 0;
-
- if(dst)
- {
- // Support Midi Port to Audio Input track routes. p4.0.14 Tim.
- int port = ((MidiTrack*)track)->outPort();
- if(port >= 0 && port < MIDI_PORTS)
- {
- MidiPort* mp = &midiPorts[port];
-
- // p4.0.17 Do not list synth devices! Requiring valid device is desirable,
- // but could lead to 'hidden' routes unless we add more support
- // such as removing the existing routes when user changes flags.
- // So for now, just list all valid ports whether read or write.
- if(mp->device() && !mp->device()->isSynti())
- {
- RouteList* mprl = mp->outRoutes();
- int chbits = 1 << ((MidiTrack*)track)->outChannel();
- //MidiDevice* md = mp->device();
- //if(!md)
- // continue;
-
- pup->addSeparator();
- pup->addAction(new MenuTitleItem(tr("Soloing chain"), pup));
- PopupMenu* subp = new PopupMenu(pup, true);
- subp->setTitle(tr("Audio returns"));
- pup->addMenu(subp);
-
- InputList* al = song->inputs();
- for (iAudioInput i = al->begin(); i != al->end(); ++i)
- {
- Track* t = *i;
- QString s(t->name());
-
- act = subp->addAction(s);
- act->setData(gid);
- act->setCheckable(true);
-
- Route r(t, chbits);
-
- gRoutingMenuMap.insert( pRouteMenuMap(gid, r) );
-
- for(iRoute ir = mprl->begin(); ir != mprl->end(); ++ir)
- {
- if(ir->type == Route::TRACK_ROUTE && ir->track == t && (ir->channel & chbits))
- {
- act->setChecked(true);
- break;
- }
- }
- ++gid;
- }
- }
- }
- }
- else
- {
- // Warn if no devices available. Add an item to open midi config. p4.0.17
- int pi = 0;
- for( ; pi < MIDI_PORTS; ++pi)
- {
- MidiDevice* md = midiPorts[pi].device();
- if(md && !md->isSynti() && (md->rwFlags() & 2))
- break;
- }
- if(pi == MIDI_PORTS)
- {
- act = pup->addAction(tr("Warning: No midi input devices!"));
- act->setCheckable(false);
- act->setData(-1);
- pup->addSeparator();
- }
- act = pup->addAction(QIcon(*settings_midiport_softsynthsIcon), tr("Open midi config..."));
- act->setCheckable(false);
- act->setData(gid);
- pup->addSeparator();
- ++gid;
-
- pup->addAction(new MenuTitleItem("Midi input ports", pup));
-
- for(int i = 0; i < MIDI_PORTS; ++i)
- {
- // NOTE: Could possibly list all devices, bypassing ports, but no, let's stick with ports.
- MidiPort* mp = &midiPorts[i];
- MidiDevice* md = mp->device();
- //if(!md)
- // continue;
-
- // p4.0.17 Do not list synth devices!
- if(md && md->isSynti())
- continue;
-
- if(md && !(md->rwFlags() & 2))
- continue;
-
- //printf("MusE::prepareRoutingPopupMenu adding submenu portnum:%d\n", i);
-
- // MusE-2: Check this - needed with QMenu? Help says no. No - verified, it actually causes double triggers!
- //connect(subp, SIGNAL(triggered(QAction*)), pup, SIGNAL(triggered(QAction*)));
- //connect(subp, SIGNAL(aboutToHide()), pup, SIGNAL(aboutToHide()));
-
- int chanmask = 0;
- // p3.3.50 To reduce number of routes required, from one per channel to just one containing a channel mask.
- // Look for the first route to this midi port. There should always be only a single route for each midi port, now.
- iRoute ir = rl->begin();
- for( ; ir != rl->end(); ++ir)
- {
- if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i)
- {
- // We have a route to the midi port. Grab the channel mask.
- chanmask = ir->channel;
- break;
- }
- }
- // p4.0.17 List ports with no device, but with routes to this track, in the main popup.
- if(!md && ir == rl->end())
- continue;
-
- PopupMenu* subp = new PopupMenu(pup, true);
- subp->setTitle(QString("%1:").arg(i+1) + (md ? md->name() : tr("<none>")));
-
- for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
- {
- act = subp->addAction(QString("Channel %1").arg(ch+1));
- act->setCheckable(true);
- act->setData(gid);
-
- int chbit = 1 << ch;
- Route srcRoute(i, chbit); // p3.3.50 In accordance with new channel mask, use the bit position.
-
- gRoutingMenuMap.insert( pRouteMenuMap(gid, srcRoute) );
-
- if(chanmask & chbit) // p3.3.50 Is the channel already set? Show item check mark.
- act->setChecked(true);
-
- ++gid;
- }
- //gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id.
- act = subp->addAction(tr("Toggle all"));
- //act->setCheckable(true);
- act->setData(gid);
- Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits.
- gRoutingMenuMap.insert( pRouteMenuMap(gid, togRoute) );
- ++gid;
- pup->addMenu(subp);
- }
-
- #if 0
- // p4.0.17 List ports with no device and no in routes, in a separate popup.
- PopupMenu* morep = new PopupMenu(pup, true);
- morep->setTitle(tr("More..."));
- for(int i = 0; i < MIDI_PORTS; ++i)
- {
- MidiPort* mp = &midiPorts[i];
- if(mp->device())
- continue;
-
- PopupMenu* subp = new PopupMenu(morep, true);
- subp->setTitle(QString("%1:").arg(i) + tr("<none>"));
-
- // MusE-2: Check this - needed with QMenu? Help says no. No - verified, it actually causes double triggers!
- //connect(subp, SIGNAL(triggered(QAction*)), pup, SIGNAL(triggered(QAction*)));
- //connect(subp, SIGNAL(aboutToHide()), pup, SIGNAL(aboutToHide()));
-
- iRoute ir = rl->begin();
- for( ; ir != rl->end(); ++ir)
- {
- if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i)
- break;
- }
- if(ir != rl->end())
- continue;
-
- for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
- {
- act = subp->addAction(QString("Channel %1").arg(ch+1));
- act->setCheckable(true);
- act->setData(gid);
-
- int chbit = 1 << ch;
- Route srcRoute(i, chbit); // In accordance with new channel mask, use the bit position.
-
- gRoutingMenuMap.insert( pRouteMenuMap(gid, srcRoute) );
-
- //if(chanmask & chbit) // Is the channel already set? Show item check mark.
- // act->setChecked(true);
-
- ++gid;
- }
- //gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id.
- act = subp->addAction(QString("Toggle all"));
- //act->setCheckable(true);
- act->setData(gid);
- Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits.
- gRoutingMenuMap.insert( pRouteMenuMap(gid, togRoute) );
- ++gid;
- morep->addMenu(subp);
- }
- pup->addMenu(morep);
- #endif
-
- }
-
- if(pup->actions().isEmpty())
- {
- gRoutingPopupMenuMaster = 0;
- //pup->clear();
- //pup->disconnect();
- gRoutingMenuMap.clear();
- //oR->setDown(false);
- return 0;
- }
-
- gIsOutRoutingPopupMenu = dst;
- return pup;
- }
-
- return 0;
-}
-
-//---------------------------------------------------------
// saveAs
//---------------------------------------------------------