From: Guillaume L. <gla...@te...> - 2002-02-18 01:18:41
|
It seems we have a lot of slots re-emitting signals or signals connected to signals, etc... which are almost always unnecessary. You can connect signals even if you don't have a pointer of the right type to the source and destination, and even if the signal or slot name isn't in the current scope, e.g.: QObject *source, *destination connect(source, SIGNAL(mysignal(int)), destination, SLOT(myslot(int))); will work. -- Guillaume. http://www.telegraph-road.org |
From: Richard B. <bo...@bo...> - 2002-02-18 07:50:38
|
Guillaume Laurent wrote: > It seems we have a lot of slots re-emitting signals or signals connected to > signals, etc... which are almost always unnecessary. Yeah, this was my question/half-statement the other day - I think I got a bit confused somewhere in the middle of using them. Good stuff. R |
From: Chris C. <ca...@al...> - 2002-02-18 10:32:55
|
Guillaume Laurent wrote: > You can connect signals > even if you don't have a pointer of the right type to the source and > destination, and even if the signal or slot name isn't in the current scope, > e.g.: > > QObject *source, *destination > > connect(source, SIGNAL(mysignal(int)), destination, SLOT(myslot(int))); > > will work. I don't quite see the significance of what you're saying here. Surely the problem is more often that you don't have the right object to hand at all, not that you don't know its type or that you haven't got the right name in scope. (F'rinstance, the track editor and segment tools can't communicate directly with one another because they don't know anything about each other.) Is this not true? Can you give an example from the RG code of somewhere where signals have been connected in a way that could be simplified with the above knowledge? (I guess I'm confused because what you're saying appears to be exactly how I thought signals worked, and although I hardly ever use signals myself, I can't recall having seen anything that could be improved upon just by a better understanding of the lexical situation rather than by making object pointers more available. Or are you saying you don't even need to have the address of an object in order to connect a signal to it? That seems unlikely.) Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 10:46:40
|
On Monday 18 February 2002 11:29, Chris Cannam wrote: > you haven't got the right name in scope. (F'rinstance, the > track editor and segment tools can't communicate directly with > one another because they don't know anything about each other.) That's not a problem. All it takes is a "3rd party" which knows about both and therefore can establish the connection. > Is this not true? Can you give an example from the RG code of > somewhere where signals have been connected in a way that could > be simplified with the above knowledge? RosegardenGUIView has the following signals : void setGUIPositionPointer(Rosegarden::timeT); void setGUIPlayPosition(Rosegarden::timeT); void setGUILoop(Rosegarden::timeT, Rosegarden::timeT); which were used only to re-emit signals from BarButtons : connect(m_barButtons, SIGNAL(setPointerPosition(Rosegarden::timeT)), this, SIGNAL(setGUIPositionPointer(Rosegarden::timeT))); connect(m_barButtons, SIGNAL(setPlayPosition(Rosegarden::timeT)), this, SIGNAL(setGUIPlayPosition(Rosegarden::timeT))); connect(m_barButtons, SIGNAL(setLoop(Rosegarden::timeT, Rosegarden::timeT)), this, SIGNAL(setGUILoop(Rosegarden::timeT, Rosegarden::timeT))); I replaced these by connect(m_trackEditor->getBarButtons(), SIGNAL(setPointerPosition(Rosegarden::timeT)), parent, SLOT(setPointerPosition(Rosegarden::timeT))); connect(m_trackEditor->getBarButtons(), SIGNAL(setPlayPosition(Rosegarden::timeT)), parent, SLOT(setPlayPosition(Rosegarden::timeT))); connect(m_trackEditor->getBarButtons(), SIGNAL(setLoop(Rosegarden::timeT, Rosegarden::timeT)), parent, SLOT(setLoop(Rosegarden::timeT, Rosegarden::timeT))); 'parent' being the QWidget passed to the RosegardenGUIView ctor. I believe there are other similar cases. -- Guillaume http://www.telegraph-road.org |
From: Chris C. <ca...@al...> - 2002-02-18 11:09:39
|
Guillaume Laurent wrote: > RosegardenGUIView has the following signals : > > void setGUIPositionPointer(Rosegarden::timeT); > void setGUIPlayPosition(Rosegarden::timeT); > void setGUILoop(Rosegarden::timeT, Rosegarden::timeT); > > which were used only to re-emit signals from BarButtons : > [...] I replaced these by > > connect(m_trackEditor->getBarButtons(), > SIGNAL(setPointerPosition(Rosegarden::timeT)), > parent, > SLOT(setPointerPosition(Rosegarden::timeT))); Only a good idea if you're confident that nobody else needs the signal that was originally being re-emitted. In this case, NotationView catches RosegardenGUIView::setGUIPointerPosition, in order to set the playback pointer. That's currently not active because it needed updating for the RulerScale etc, and of course we'd need to be a bit more general in order to catch pointer-position requests originating from EditViews as well as those originating from the RosegardenGUIView, but as a general principle... (IOW, it seems to me you've replaced three connects with three connects, added an assumption about the usage and removed a useful signal. I don't think it's a net gain. Still, I see your point that you don't need to know for sure what the parent is, nor for sure that it has a setPointerPosition slot.) Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 11:15:47
|
On Monday 18 February 2002 12:07, Chris Cannam wrote: > > Only a good idea if you're confident that nobody else needs > the signal that was originally being re-emitted. You're right, but then I believe the connection should be direct, there isn't much point in re-emitting. > (IOW, it seems to me you've replaced three connects with three > connects, added an assumption about the usage and removed a > useful signal. Precisely, I don't think these re-emitting signals were useful. -- Guillaume http://www.telegraph-road.org |
From: Chris C. <ca...@al...> - 2002-02-18 11:20:25
|
Guillaume Laurent wrote: > I believe the connection should be direct So how do you propose to connect BarButtons::setPointerPosition in the main view to NotationView::setGUIPointerPosition? Do it explicitly each time you construct a NotationView in rosegardenguiview.cpp? Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 13:11:37
|
On Monday 18 February 2002 12:17, Chris Cannam wrote: > > So how do you propose to connect BarButtons::setPointerPosition > in the main view to NotationView::setGUIPointerPosition? Do it > explicitly each time you construct a NotationView in > rosegardenguiview.cpp? Yes. Previously you also had to redo the connection at each NotationView creation anyway. -- Guillaume http://www.telegraph-road.org |
From: Chris C. <ca...@al...> - 2002-02-18 13:19:18
|
Guillaume Laurent wrote: > Previously you also had to redo the connection at each NotationView > creation anyway. But that only appears physically once in the code; this way you have to do it several times, whenever a NotationView is created (which happens in more than one place). Okay, it's not the end of the world, I just don't see how it's an improvement. Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 13:23:23
|
On Monday 18 February 2002 14:16, Chris Cannam wrote: > > But that only appears physically once in the code; this way you > have to do it several times, whenever a NotationView is created > (which happens in more than one place). There's certainly a way to factor this out somewhere. We'll see. -- Guillaume http://www.telegraph-road.org |
From: Chris C. <ca...@al...> - 2002-02-18 13:25:44
|
Guillaume Laurent wrote: > There's certainly a way to factor this out somewhere. How about emitting a signal from RosegardenGUIView, and catching it in the NotationView constructor? Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 13:38:10
|
On Monday 18 February 2002 14:23, Chris Cannam wrote: > > How about emitting a signal from RosegardenGUIView, and catching > it in the NotationView constructor? I suppose you mean establishing the connection in the NotationView ctor ? Yes, that would work. -- Guillaume http://www.telegraph-road.org |
From: Chris C. <ca...@al...> - 2002-02-18 14:38:49
|
Guillaume Laurent wrote: > I suppose you mean establishing the connection in the NotationView ctor ? Yes. > Yes, that would work. I thought so. And that's what we were doing, right? Chris Are you bluffing, or am I? |
From: Guillaume L. <gla...@te...> - 2002-02-18 14:53:01
|
On Monday 18 February 2002 15:36, Chris Cannam wrote: > > Yes, that would work. > > I thought so. And that's what we were doing, right? After checking it seems that yes, we are : QObject::connect (rgView, SIGNAL(setGUIPositionPointer(timeT)), this, SLOT (setGUIPositionPointer(timeT))); so I guess simply providing an accessor to the TrackEditor from RosegardenGUIView should be enough. > Are you bluffing, or am I? Don't know about you but I'm not. I'm at the office at the moment and switching back and forth to RG code isn't too easy, so don't pay attention if I say stupid things. -- Guillaume http://www.telegraph-road.org |
From: Guillaume L. <gla...@te...> - 2002-02-18 15:15:32
|
On Monday 18 February 2002 15:52, I wrote: > so I guess simply providing an accessor to the TrackEditor from > RosegardenGUIView should be enough. Done. -- Guillaume http://www.telegraph-road.org |
From: Richard B. <bo...@bo...> - 2002-02-18 15:15:47
|
Guillaume Laurent wrote: > I'm at the office at the moment and switching back and forth to RG code isn't too easy, Well if you're going around Working for The Man then you're going to have to expect some freakiness. > so don't pay attention if I say stupid things. Hey, that's _my_ day-to-day excuse - what's your excuse? R |
From: Guillaume L. <gla...@te...> - 2002-02-18 15:23:06
|
On Monday 18 February 2002 16:14, Richard Bown wrote: > > > so don't pay attention if I say stupid things. > > Hey, that's _my_ day-to-day excuse - what's your excuse? "don't pay attention if I say des stupidit=E9s". --=20 Guillaume http://www.telegraph-road.org |
From: Richard B. <bo...@bo...> - 2002-02-18 17:33:39
|
> "don't pay attention if I say des stupidités". Stupidité, Redundencé et Paternité seem to be our cornerstones at the moment. R |
From: Chris C. <ca...@al...> - 2002-02-18 18:06:05
|
Richard Bown wrote: > Stupidit, Redundenc et Paternit seem to be our cornerstones at the moment. For some reason Mozilla isn't showing the e-acute at all, which leaves me with the rather Latin-looking formulation above. HIC STVPIDIT REDUNDENC ET PATERNIT Shame I never learned any Latin. What did "hic" mean anyway? Chris |
From: Guillaume L. <gla...@te...> - 2002-02-18 18:12:42
|
On Monday 18 February 2002 19:03, Chris Cannam wrote: > > HIC STVPIDIT REDUNDENC ET PATERNIT > > Shame I never learned any Latin. What did "hic" mean anyway? Google says it means "here", which does give a meaning to the overall quote. Not sure we want to make it our official motto, though :-). -- Guillaume http://www.telegraph-road.org |
From: Richard B. <bo...@bo...> - 2002-02-18 19:03:56
|
Guillaume Laurent wrote: > Google says it means "here", which does give a meaning to the overall quote. > Not sure we want to make it our official motto, though :-). I think it's perfect. We should turn it into an easter egg - the motto at the end of the trail emblazoned across the team-rg photo. In mauve. R and then shove it up yer ass |