From: Mathias L. <lun...@us...> - 2005-10-19 21:33:02
|
Update of /cvsroot/lmuse/muse/muse/mixer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30689/muse/mixer Modified Files: astrip.cpp Log Message: Fixed checked menu items by updating to qt4 QMenu and QAction (Q3PopupMenu doesn't seem to be complete) Index: astrip.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/mixer/astrip.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** astrip.cpp 10 Oct 2005 19:34:09 -0000 1.59 --- astrip.cpp 19 Oct 2005 21:32:54 -0000 1.60 *************** *** 37,41 **** #include <QHBoxLayout> #include <QGridLayout> ! #include <Q3PopupMenu> //--------------------------------------------------------- --- 37,41 ---- #include <QHBoxLayout> #include <QGridLayout> ! //#include <Q3PopupMenu> //--------------------------------------------------------- *************** *** 600,604 **** //--------------------------------------------------------- ! static void addAuxPorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { AuxList* al = song->auxs(); --- 600,604 ---- //--------------------------------------------------------- ! static void addAuxPorts(AudioTrack* t, QMenu* lb, RouteList* r) { AuxList* al = song->auxs(); *************** *** 608,615 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! lb->setItemChecked(it, true); break; } --- 608,616 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 622,626 **** //--------------------------------------------------------- ! static void addInPorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { InputList* al = song->inputs(); --- 623,627 ---- //--------------------------------------------------------- ! static void addInPorts(AudioTrack* t, QMenu* lb, RouteList* r) { InputList* al = song->inputs(); *************** *** 630,637 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! lb->setItemChecked(it, true); break; } --- 631,639 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 644,648 **** //--------------------------------------------------------- ! static void addOutPorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { OutputList* al = song->outputs(); --- 646,650 ---- //--------------------------------------------------------- ! static void addOutPorts(AudioTrack* t, QMenu* lb, RouteList* r) { OutputList* al = song->outputs(); *************** *** 652,659 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! lb->setItemChecked(it, true); break; } --- 654,662 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 666,670 **** //--------------------------------------------------------- ! static void addGroupPorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { GroupList* al = song->groups(); --- 669,673 ---- //--------------------------------------------------------- ! static void addGroupPorts(AudioTrack* t, QMenu* lb, RouteList* r) { GroupList* al = song->groups(); *************** *** 674,681 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! lb->setItemChecked(it, true); break; } --- 677,685 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 688,692 **** //--------------------------------------------------------- ! static void addWavePorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { WaveTrackList* al = song->waves(); --- 692,696 ---- //--------------------------------------------------------- ! static void addWavePorts(AudioTrack* t, QMenu* lb, RouteList* r) { WaveTrackList* al = song->waves(); *************** *** 696,703 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! lb->setItemChecked(it, true); break; } --- 700,708 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (ir->type == 0 && ir->track == track) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 710,714 **** //--------------------------------------------------------- ! static void addMidiOutPorts(Track* t, Q3PopupMenu* lb, RouteList* r) { MidiOutPortList* al = song->midiOutPorts(); --- 715,719 ---- //--------------------------------------------------------- ! static void addMidiOutPorts(Track* t, QMenu* lb, RouteList* r) { MidiOutPortList* al = song->midiOutPorts(); *************** *** 718,726 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); Route route(track, -1, Route::TRACK); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! lb->setItemChecked(it, true); break; } --- 723,732 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s);//int it = lb->insertItem(s); Route route(track, -1, Route::TRACK); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! it->setCheckable(true);//lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 733,737 **** //--------------------------------------------------------- ! static void addMidiInPorts(Track* t, Q3PopupMenu* lb, RouteList* r) { MidiInPortList* al = song->midiInPorts(); --- 739,743 ---- //--------------------------------------------------------- ! static void addMidiInPorts(Track* t, QMenu* lb, RouteList* r) { MidiInPortList* al = song->midiInPorts(); *************** *** 741,749 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); Route route(track, -1, Route::TRACK); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! lb->setItemChecked(it, true); break; } --- 747,756 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); Route route(track, -1, Route::TRACK); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! it->setCheckable(true); //lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 756,760 **** //--------------------------------------------------------- ! static void addSyntiPorts(AudioTrack* t, Q3PopupMenu* lb, RouteList* r) { SynthIList* al = song->syntis(); --- 763,767 ---- //--------------------------------------------------------- ! static void addSyntiPorts(AudioTrack* t, QMenu* lb, RouteList* r) { SynthIList* al = song->syntis(); *************** *** 764,773 **** continue; QString s(track->name()); ! int it = lb->insertItem(s); Route route(track, -1, Route::SYNTIPORT); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! lb->setItemChecked(it, true); break; } --- 771,781 ---- continue; QString s(track->name()); ! QAction* it = lb->addAction(s); //int it = lb->insertItem(s); Route route(track, -1, Route::SYNTIPORT); for (iRoute ir = r->begin(); ir != r->end(); ++ir) { if (*ir == route) { ! it->setCheckable(true);//lb->setItemChecked(it, true); ! it->setChecked(true); break; } *************** *** 782,789 **** void AudioStrip::iRoutePressed() { ! Q3PopupMenu* pup = new Q3PopupMenu(iR); AudioTrack* t = (AudioTrack*)track; RouteList* irl = t->inRoutes(); ! pup->setCheckable(true); switch(track->type()) { --- 790,797 ---- void AudioStrip::iRoutePressed() { ! QMenu* pup = new QMenu(iR);//Q3PopupMenu* pup = new Q3PopupMenu(iR); AudioTrack* t = (AudioTrack*)track; RouteList* irl = t->inRoutes(); ! //pup->setCheckable(true); switch(track->type()) { *************** *** 802,811 **** std::list<PortName>* ol = audioDriver->outputPorts(); for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) { ! int id = pup->insertItem(ip->name, (gid * 16) + i); Route src(ip->name, i, Route::AUDIOPORT); ++gid; for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) { if (*ir == src) { ! pup->setItemChecked(id, true); break; } --- 810,822 ---- std::list<PortName>* ol = audioDriver->outputPorts(); for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) { ! QAction* id = pup->addAction(ip->name); ! id->setData(QVariant(gid * 16 + i)); ! //int id = pup->insertItem(ip->name, (gid * 16) + i); Route src(ip->name, i, Route::AUDIOPORT); ++gid; for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) { if (*ir == src) { ! id->setCheckable(true); //pup->setItemChecked(id, true); ! id->setChecked(true); break; } *************** *** 839,850 **** break; } ! int n = pup->exec(QCursor::pos()); ! if (n != -1) { ! QString s(pup->text(n)); Route srcRoute, dstRoute; if (track->type() == Track::AUDIO_INPUT) { ! srcRoute = Route(s, n & 0xf, Route::AUDIOPORT); ! dstRoute = Route(t, n & 0xf, Route::TRACK); } else if (track->type() == Track::AUDIO_SOFTSYNTH) { --- 850,862 ---- break; } ! QAction* n = pup->exec(QCursor::pos()); ! if (n != 0) { ! int id = n->data().toInt(); ! QString s(n->text()); //QString s(pup->text(n)); Route srcRoute, dstRoute; if (track->type() == Track::AUDIO_INPUT) { ! srcRoute = Route(s, id & 0xf, Route::AUDIOPORT);//srcRoute = Route(s, n & 0xf, Route::AUDIOPORT); ! dstRoute = Route(t, id & 0xf, Route::TRACK);//dstRoute = Route(t, n & 0xf, Route::TRACK); } else if (track->type() == Track::AUDIO_SOFTSYNTH) { *************** *** 881,884 **** --- 893,984 ---- void AudioStrip::oRoutePressed() { + QMenu* pup = new QMenu(oR); + pup->setCheckable(true); + AudioTrack* t = (AudioTrack*)track; + RouteList* orl = t->outRoutes(); + + switch(track->type()) { + default: + delete pup; + return; + case Track::AUDIO_OUTPUT: + { + int gid = 0; + for (int i = 0; i < channel; ++i) { + char buffer[128]; + snprintf(buffer, 128, "%s %d", tr("Channel").latin1(), i+1); + //TD MenuTitleItem* titel = new MenuTitleItem(QString(buffer)); + // pup->insertItem(titel); + + std::list<PortName>* ol = audioDriver->inputPorts(); + for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) { + QAction* action = pup->addAction(ip->name); + action->setData(QVariant(gid * 16 + i)); + Route dst(ip->name, i, Route::AUDIOPORT); + ++gid; + for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) { + if (*ir == dst) { + action->setCheckable(true); + action->setChecked(true); + break; + } + } + } + delete ol; + if (i+1 != channel) + pup->insertSeparator(); + } + } + break; + case Track::AUDIO_INPUT: + addWavePorts(t, pup, orl); + case Track::WAVE: + case Track::AUDIO_GROUP: + case Track::AUDIO_SOFTSYNTH: + addOutPorts(t, pup, orl); + addGroupPorts(t, pup, orl); + break; + case Track::AUDIO_AUX: + addOutPorts(t, pup, orl); + break; + } + QAction* n = pup->exec(QCursor::pos()); //int n = pup->exec(QCursor::pos()); + if (n != 0) { + //QString s(pup->text(n)); + QString s(n->text()); + Route srcRoute(t, -1, track->type() == Track::AUDIO_SOFTSYNTH + ? Route::SYNTIPORT : Route::TRACK); + Route dstRoute(s, -1, track->type() == Track::AUDIO_OUTPUT + ? Route::AUDIOPORT : Route::TRACK); + + if (track->type() == Track::AUDIO_OUTPUT) { + QVariant data = n->data(); + srcRoute.channel = dstRoute.channel = data.toInt() & 0xf; //n & 0xf; + } + + + // check if route src->dst exists: + iRoute iorl = orl->begin(); + for (; iorl != orl->end(); ++iorl) { + if (*iorl == dstRoute) + break; + } + if (iorl != orl->end()) { + // disconnect if route exists + audio->msgRemoveRoute(srcRoute, dstRoute); + } + else { + // connect if route does not exist + audio->msgAddRoute(srcRoute, dstRoute); + } + song->update(SC_ROUTE); + } + delete pup; + oR->setDown(false); // pup->exec() catches mouse release event + } + + #if 0 + void AudioStrip::oRoutePressed() + { Q3PopupMenu* pup = new Q3PopupMenu(oR); pup->setCheckable(true); *************** *** 906,909 **** --- 1006,1010 ---- for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) { if (*ir == dst) { + printf("Setting item %d checked: %s channel: %d\n", id, ip->name.latin1(), i); pup->setItemChecked(id, true); break; *************** *** 959,962 **** --- 1060,1064 ---- oR->setDown(false); // pup->exec() catches mouse release event } + #endif //--------------------------------------------------------- |