[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: direct slot invocation (Re: kdelibs/kdecore)
From:       Antonio Larrosa =?iso-8859-1?q?Jim=E9nez?= <larrosa () kde ! org>
Date:       2003-02-16 22:40:59
[Download RAW message or body]

El Domingo, 16 de Febrero de 2003 20:23, Oswald Buddenhagen escribió:
> void KApplication::invokeEditSlot( const char *slot )
>
> > +{
> > +  QObject *object = focusWidget();
> > +
> >
> > +  if( !object || !slotName || !slot )
>
> if( !object )
>
> > +    return;
> > +
> > +  QMetaObject *meta = object->metaObject();
> >
> > +  QStrList l = meta->slotNames(true);
> > +
> > +  if( l.find( slotName ) == -1 )
> > +    return;
> > +
> > +  connect( this, SIGNAL( editSignal() ), object, slot );
> > +  emit editSignal();
> > +  disconnect( this, SIGNAL( editSignal() ), object, slot );
>
> int idx = meta->findSlot(slot, true);
> if (idx < 0)
>   return;
> object->qt_invoke(idx, 0);
>
> > +}
> > +
> >  void KApplication::addKipcEventMask(int id)
> >  {
> > @@ -1983,4 +2002,29 @@ void KApplication::invokeBrowser( const
> >        return;
> >     }
> > +}
> > +
> > +void KApplication::cut()
> > +{
> >
> > +  invokeEditSlot( "cut()", SLOT( cut() ) );
>
> invokeEditSlot( SLOT( cut() ) );

Sorry, I've not been following the thread, but isn't it better to use 
something along the lines of
KXMLGUIClient::action("edit_cut")->activate();  in the application code 
than hardwiring a slot name ( "cut()" ) in KApplication given that some 
applications may name it different ?

Of course, this doesn't work to invocate a "named slot" in a variable, but 
at least IMHO it's better than hardwiring slot names in KApplication for 
the above case.

Sorry if I'm out of topic. I'm really short of time lately to read all the 
threads.

Greetings,

--
Antonio Larrosa Jimenez
KDE developer - larrosa@kde.org
http://developer.kde.org/~larrosa/
Even a hawk is an eagle among crows.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic