KDE 4.7 PyKDE API Reference

- KDE's Python API

# CopyJob Class Reference

`from PyKDE4.kio import *`

Inherits: KIO.Job → KCompositeJob → KJob → QObject
Namespace: KIO

## Detailed Description

CopyJob is used to move, copy or symlink files and directories. Don't create the job directly, but use KIO.copy(), KIO.move(), KIO.link() and friends.

See also:
  KIO.copy()

See also:
  KIO.copyAs()

See also:
  KIO.move()

See also:
  KIO.moveAs()

See also:
  KIO.link()

See also:
  KIO.linkAs()

## Enumerations
CopyMode | { Copy, Move, Link }
## Signals
| aboutToCreate (KIO.Job job, [KIO.CopyInfo] files)
| copying (KIO.Job job, KUrl src, KUrl dest)
| copyingDone (KIO.Job job, KUrl from, KUrl to, long mtime, bool directory, bool renamed)
| copyingLinkDone (KIO.Job job, KUrl from, QString target, KUrl to)
| creatingDir (KIO.Job job, KUrl dir)
| linking (KIO.Job job, QString target, KUrl to)
| moving (KIO.Job job, KUrl from, KUrl to)
| processedDirs (KIO.Job job, long dirs)
| processedFiles (KIO.Job job, long files)
| renamed (KIO.Job job, KUrl from, KUrl to)
| totalDirs (KJob job, long dirs)
| totalFiles (KJob job, long files)
## Methods
| __init__ (self)
KUrl | destUrl (self)
bool | doSuspend (self)
| emitResult (self)
KIO.CopyJob.CopyMode | operationMode (self)
| setAutoRename (self, bool autoRename)
| setAutoSkip (self, bool autoSkip)
| setDefaultPermissions (self, bool b)
| setWriteIntoExistingDirectories (self, bool overwriteAllDirs)
| slotResult (self, KJob job)
KUrl.List | srcUrls (self)

## Signal Documentation

aboutToCreate | ( | KIO.Job | job,
|  | [KIO.CopyInfo] | files
| ) |  |  |

Emitted when it is known which files / directories are going to be created. Note that this may still change e.g. when existing files with the same name are discovered.

Parameters:

  | job | the job that emitted this signal
  | files | a list of items that are about to be created.

Signal syntax:
  `QObject.connect(source, SIGNAL("aboutToCreate(KIO::Job*, const QList&)"), target_slot)`

copying | ( | KIO.Job | job,
|  | KUrl | src,
|  | KUrl | dest
| ) |  |  |

The job is copying a file or directory.

Note: This signal is used for progress dialogs, it's not emitted for every file or directory (this would be too slow), but every 200ms.

Parameters:

  | job | the job that emitted this signal
  | src | the URL of the file or directory that is currently being copied
  | dest | the destination of the current operation

Signal syntax:
  `QObject.connect(source, SIGNAL("copying(KIO::Job*, const KUrl&, const KUrl&)"), target_slot)`

copyingDone | ( | KIO.Job | job,
|  | KUrl | from,
|  | KUrl | to,
|  | long | mtime,
|  | bool | directory,
|  | bool | renamed
| ) |  |  |

The job emits this signal when copying or moving a file or directory successfully finished. This signal is mainly for the Undo feature. If you simply want to know when a copy job is done, use result().

Parameters:

  | job | the job that emitted this signal
  | from | the source URL
  | to | the destination URL
  | mtime | the modification time of the source file, hopefully set on the destination file too (when the kioslave supports it).
  | directory | indicates whether a file or directory was successfully copied/moved. true for a directory, false for file
  | renamed | indicates that the destination URL was created using a rename operation (i.e. fast directory moving). true if is has been renamed

Signal syntax:
  `QObject.connect(source, SIGNAL("copyingDone(KIO::Job*, const KUrl&, const KUrl&, time_t, bool, bool)"), target_slot)`

copyingLinkDone | ( | KIO.Job | job,
|  | KUrl | from,
|  | QString | target,
|  | KUrl | to
| ) |  |  |

The job is copying or moving a symbolic link, that points to target. The new link is created in to. The existing one is/was in from. This signal is mainly for the Undo feature.

Parameters:

  | job | the job that emitted this signal
  | from | the source URL
  | target | the target
  | to | the destination URL

Signal syntax:
  `QObject.connect(source, SIGNAL("copyingLinkDone(KIO::Job*, const KUrl&, const QString&, const KUrl&)"), target_slot)`

creatingDir | ( | KIO.Job | job,
|  | KUrl | dir
| ) |  |  |

The job is creating the directory dir.

This signal is emitted for every directory being created.

Parameters:

  | job | the job that emitted this signal
  | dir | the directory that is currently being created

Signal syntax:
  `QObject.connect(source, SIGNAL("creatingDir(KIO::Job*, const KUrl&)"), target_slot)`

linking | ( | KIO.Job | job,
|  | QString | target,
|  | KUrl | to
| ) |  |  |

The job is creating a symbolic link.

Note: This signal is used for progress dialogs, it's not emitted for every file or directory (this would be too slow), but every 200ms.

Parameters:

  | job | the job that emitted this signal
  | target | the URL of the file or directory that is currently being linked
  | to | the destination of the current operation

Signal syntax:
  `QObject.connect(source, SIGNAL("linking(KIO::Job*, const QString&, const KUrl&)"), target_slot)`

moving | ( | KIO.Job | job,
|  | KUrl | from,
|  | KUrl | to
| ) |  |  |

The job is moving a file or directory.

Note: This signal is used for progress dialogs, it's not emitted for every file or directory (this would be too slow), but every 200ms.

Parameters:

  | job | the job that emitted this signal
  | from | the URL of the file or directory that is currently being moved
  | to | the destination of the current operation

Signal syntax:
  `QObject.connect(source, SIGNAL("moving(KIO::Job*, const KUrl&, const KUrl&)"), target_slot)`

processedDirs | ( | KIO.Job | job,
|  | long | dirs
| ) |  |  |

Sends the number of processed directories.

Parameters:

  | job | the job that emitted this signal
  | dirs | the number of processed dirs

Signal syntax:
  `QObject.connect(source, SIGNAL("processedDirs(KIO::Job*, unsigned long)"), target_slot)`

processedFiles | ( | KIO.Job | job,
|  | long | files
| ) |  |  |

Sends the number of processed files.

Parameters:

  | job | the job that emitted this signal
  | files | the number of processed files

Signal syntax:
  `QObject.connect(source, SIGNAL("processedFiles(KIO::Job*, unsigned long)"), target_slot)`

renamed | ( | KIO.Job | job,
|  | KUrl | from,
|  | KUrl | to
| ) |  |  |

The user chose to rename from to to.

Parameters:

  | job | the job that emitted this signal
  | from | the original name
  | to | the new name

Signal syntax:
  `QObject.connect(source, SIGNAL("renamed(KIO::Job*, const KUrl&, const KUrl&)"), target_slot)`

totalDirs | ( | KJob | job,
|  | long | dirs
| ) |  |  |

Emitted when the toal number of direcotries is known.

Parameters:

  | job | the job that emitted this signal
  | dirs | the total number of directories

Signal syntax:
  `QObject.connect(source, SIGNAL("totalDirs(KJob*, unsigned long)"), target_slot)`

totalFiles | ( | KJob | job,
|  | long | files
| ) |  |  |

Emitted when the total number of files is known.

Parameters:

  | job | the job that emitted this signal
  | files | the total number of files

Signal syntax:
  `QObject.connect(source, SIGNAL("totalFiles(KJob*, unsigned long)"), target_slot)`

## Method Documentation

__init__ | ( |  | self ) |

KUrl destUrl | ( |  | self ) |

Returns the destination URL.

Returns:
  the destination URL

bool doSuspend | ( |  | self ) |

Reimplemented for internal reasons

emitResult | ( |  | self ) |

KIO.CopyJob.CopyMode operationMode | ( |  | self ) |

Returns the mode of the operation (copy, move, or link), depending on whether KIO.copy(), KIO.move() or KIO.link() was called.

setAutoRename | ( | self, |
|  | bool | autoRename
| ) |  |  |

Rename files automatically when the destination already exists, instead of the default behavior (interactive mode: showing a dialog to the user, non-interactive mode: aborting with an error). Initially added for a unit test.

Since:
  4.7

setAutoSkip | ( | self, |
|  | bool | autoSkip
| ) |  |  |

Skip copying or moving any file when the destination already exists, instead of the default behavior (interactive mode: showing a dialog to the user, non-interactive mode: aborting with an error). Initially added for a unit test.

Since:
  4.2

setDefaultPermissions | ( | self, |
|  | bool | b
| ) |  |  |

By default the permissions of the copied files will be those of the source files.

But when copying "template" files to "new" files, people prefer the umask to apply, rather than the template's permissions. For that case, call setDefaultPermissions(true)

setWriteIntoExistingDirectories | ( | self, |
|  | bool | overwriteAllDirs
| ) |  |  |

Reuse any directory that already exists, instead of the default behavior (interactive mode: showing a dialog to the user, non-interactive mode: aborting with an error).

Since:
  4.2

slotResult | ( | self, |
|  | KJob | job
| ) |  |  |

KUrl.List srcUrls | ( |  | self ) |

Returns the list of source URLs.

Returns:
  the list of source URLs.

## Enumeration Documentation

CopyMode

Defines the mode of the operation

Enumerator:

  Copy |
  Move |
  Link |