kuiserver becomes smarter

23 Jan 2007

Hi all,

Well yes… despite I haven’t got free time (exams !!) I’ve done an attempt to make kuiserver smarter. All the improvement comes when you have an own job that inherits KJob, for example, MyFancyKJob, and that we have MyFancyKJob *myFancyKJob somewhere on your code.

You know on some part of your application you can do something like

Observer::self()->newJob(myFancyKJob, true /* make it visible */);<br /> Observer::self()->addAction(myFancyKJob, i18n("Start computing"), this, SLOT(computeMySelf(KJob*)));<br /> Observer::self()->addAction(myFancyKJob, i18n("Take me a drink"), this, SLOT(takeMyDrink(KJob*,int)));

If you take a look to the observer header, you will notice the signal emitted have 1 KJob* and 2 int parameters. First one is the job that contains the action that was performed, second is the actionId of the action performed, and third the jobId. So you know at every moment which action was performed.

So on your program you can go:

void MyFancyApplication::computeMySelf(KJob *job)<br /> {<br /> MyFancyKJob *thisJob = static_cast<MyFancyKJob*>(job);<br /> thisJob->somethingSpecial();<br /> }<br /> void MyFancyApplication::takeMyDrink(KJob *job, int actionId)<br /> {<br /> MyFancyKJob *thisJob = static_cast<MyFancyKJob*>(job);<br /> if (actionId == myStoredAction)<br /> thisJob->anotherSpecialThing();<br /> else<br /> thisJob->anotherSpecialThing2();<br /> }

I’m committing this stuff next monday, tuesday or whenever the bic day is 🙂

comments powered by Disqus