This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] used filenames of KJob?

Tags: None
(comma "," separated)
K4m1K4tz3
Registered Member
Posts
35
Karma
0

[SOLVED] used filenames of KJob?

Wed Mar 18, 2009 3:36 pm
Hi,

once again I need your help. :-P

My programm starts a little KJob, copying some files. If KJob is finished, I want to generate some Links. But for this I need the filenames. But KJob can't give me these names. So I have to save them manualy. The Problem is, that there can be more than one KJob at the same time. So I have to figure out which KJob did which job. How would you do this?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] used filenames of KJob?

Thu Mar 19, 2009 5:45 am
Maybe use a QMap, which the Job is added to ( along with file name ) at the start, then when finished(KJob*) is emitted by your KJob, use QMap::value(KJob*) to retrieve the file name.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

[SOLVED] used filenames of KJob?

Thu Mar 19, 2009 2:09 pm
Hmm, the CopyJob has accessors for source and destination URLs, doesn't it?

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
K4m1K4tz3
Registered Member
Posts
35
Karma
0

[SOLVED] used filenames of KJob?

Thu Mar 19, 2009 6:14 pm
bcooksley wrote:Maybe use a QMap, which the Job is added to ( along with file name ) at the start, then when finished(KJob*) is emitted by your KJob, use QMap::value(KJob*) to retrieve the file name.


This sounds interesting, I will take a look.

anda_skoa wrote:Hmm, the CopyJob has accessors for source and destination URLs, doesn't it?


Shure your right, but how do I use it? I'm starting this job like this:

Code: Select all
const KJob *cJob = KIO::copy(src, dest);


But if I write something with this

Code: Select all
cJob->srcUrls();


this error will be shown:

‘class KJob’ has no member named ‘srcUrls’
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

[SOLVED] used filenames of KJob?

Sun Mar 22, 2009 2:27 pm
KIO::copy() returns a CopyJob pointer.

You either have to assign to a variable of this type or cast to this type if you assign to a base class pointer.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
K4m1K4tz3
Registered Member
Posts
35
Karma
0

[SOLVED] used filenames of KJob?

Tue Mar 24, 2009 8:56 am
anda_skoa wrote:KIO::copy() returns a CopyJob pointer.

You either have to assign to a variable of this type or cast to this type if you assign to a base class pointer.

Cheers,
_


Thanks, I casted it like this:

Code: Select all
KIO::CopyJob* cJob = (KIO::CopyJob*)job;
pinotree
KDE Developer
Posts
222
Karma
7
OS
K4m1K4tz3 wrote:I casted it like this:

Code: Select all
KIO::CopyJob* cJob = (KIO::CopyJob*)job;



Ugh. You're doing C++, not C, so please use:
Code: Select all
KIO::CopyJob* cJob = qobject_cast(job);


Pino Toscano
K4m1K4tz3
Registered Member
Posts
35
Karma
0
You're right. I'm learning so much here, thanks ;-)


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell