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

List:       kde-core-devel
Subject:    Re: an example for kio
From:       Stephan Kulow <coolo () kde ! org>
Date:       2000-01-21 7:57:35
[Download RAW message or body]

Waldo Bastian wrote:
> 
> On Thu, 20 Jan 2000, Stephan Kulow wrote:
> > David Faure wrote:
> > > > Yeah, this _could_ work. The problem is that you need the object
> > > > for almost anything else that has in between results (get,
> > > > listDir, perhaps more).
> > >
> > > I thought you wanted one-shot jobs, i.e. not reuse them ?
> >
> > OK, I wasn't clear enough. You need the object to connect to signals
> > that emit for in between results. Nicolas's solution would allow only
> > one anonymous callback, but it would have the advantage that the one
> > shot approach is more clear :)
> 
> Well.. you can make it like:
> 
> jobId = KIO::list(m_URL, this, SLOT( listResult( KIO::ResultList*)));
> 
> myClass::listResult(KIO::ResultList *r)
> {
>     if (r->id() == jobId)
>     {
>       switch( r->status())
>       {
>        case ERROR:  // Job finished with error
>          ...
>          break;
>        case WARNING: // Job has a problem but continues
>          ...
>          break;
>        case DATA: // This is what we are looking for...
>          ...
>          break;
>        case FINISHED: // Job is finished.
>          ....
>          break;
>       }
>     }
> }
> 
> You can even add a 'sync' boolean to KIO::list(...). It would then call
> kapp->processEvents() itself and return after sending either a "ERROR"
> or a "FINISHED" signal to listResult. (It shouldn't return a jobId in
> that case)
> 
> To block unwanted reentrancy we would need to make this act like a
> 'modal dialog', e.g. mouse clicks on the UI should not be processed and
> pressing ESC should cancel the operation. (Does Qt support something
> like that without actually popping up a modal dialog?)
Don't know - don't think so.
> 
> This would come in very handy for applications which can load remote
> URLs. (After a few seconds you probably want to show a modal progress
> dialog with a cancel option.)
> 
> The KIO::ResultList class could inherit from a common KIO::Result class.
> 
> KIO::Result can define stuff like:
> 
> id() // Job Id as returned by the function which started it.
> status() // ERROR / WARNING / DATA / FINISHED
> error() // Error description (number?)
> errorStr() // Textual error description: "Could not load file." :-)
> 
> The other classes can define stuff specific for the job at hand.
> 
> You could even use the same slot for different kind of jobs I guess.
> You can send a someSignal(KIO::ResultList) to a someSlot(KIO::Result)
> isn'it?
I think you can't. I like to see progress in the discussion though :)

Greetings, Stephan

-- 
As long as Linux remains a religion of freeware fanatics,
Microsoft have nothing to worry about.  
                       By Michael Surkan, PC Week Online

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

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