36
36
#include <kurlcombobox.h>
39
#include "deletedialog.h"
39
40
#include "fileoperation.h"
40
41
#include "fileopobject.moc"
41
42
#include "fileoperationconfig.h"
91
void FileOpObject::polishJob(KIO::Job* job) {
92
job->setWindow(mParent->topLevelWidget());
93
connect( job, SIGNAL( result(KIO::Job*) ),
94
this, SLOT( slotResult(KIO::Job*) ) );
90
98
//-FileOpCopyToObject--------------------------------------------------------------
113
121
if (destURL.isEmpty()) return;
116
KIO::Job* copyJob=KIO::copy(mURLList,destURL,true);
117
copyJob->setWindow(mParent->topLevelWidget());
118
connect( copyJob, SIGNAL( result(KIO::Job*) ),
119
this, SLOT( slotResult(KIO::Job*) ) );
124
KIO::Job* job=KIO::copy(mURLList,destURL,true);
147
153
if (destURL.isEmpty()) return;
150
KIO::Job* copyJob=KIO::link(mURLList,destURL,true);
151
copyJob->setWindow(mParent->topLevelWidget());
152
connect( copyJob, SIGNAL( result(KIO::Job*) ),
153
this, SLOT( slotResult(KIO::Job*) ) );
156
KIO::Job* job=KIO::link(mURLList,destURL,true);
178
182
if (destURL.isEmpty()) return;
181
KIO::Job* moveJob=KIO::move(mURLList,destURL,true);
182
moveJob->setWindow(mParent->topLevelWidget());
183
connect( moveJob, SIGNAL( result(KIO::Job*) ),
184
this, SLOT( slotResult(KIO::Job*) ) );
185
KIO::Job* job=KIO::move(mURLList,destURL,true);
199
200
KURL newURL(mURLList.first());
200
201
newURL.addPath(newDir);
201
202
KIO::Job* job=KIO::mkdir(newURL);
202
job->setWindow(mParent->topLevelWidget());
204
connect( job, SIGNAL(result(KIO::Job*)),
205
this, SLOT( slotResult(KIO::Job*)) );
207
static KIO::Job* createTrashJob(KURL::List lst) {
208
KURL trashURL("trash:/");
210
if (lst.count()==1) {
211
// If there's only one file, KIO::move will think we want to overwrite
212
// the trash dir with the file to trash, so we add the file name
213
trashURL.addPath(lst.first().fileName());
215
return KIO::move(lst, trashURL);
218
static KIO::Job* createDeleteJob(KURL::List lst) {
219
return KIO::del(lst, false, true);
223
//-FileOpDelObject-----------------------------------------------------------------
224
void FileOpDelObject::operator()() {
226
if (FileOperationConfig::confirmDelete()) {
227
DeleteDialog dlg(mParent);
228
dlg.setURLList(mURLList);
229
if (!dlg.exec()) return;
230
shouldDelete = dlg.shouldDelete();
232
shouldDelete = not FileOperationConfig::deleteToTrash();
238
job = createDeleteJob(mURLList);
240
job = createTrashJob(mURLList);
209
246
//-FileOpTrashObject---------------------------------------------------------------
210
247
void FileOpTrashObject::operator()() {
211
KURL trashURL("trash:/");
213
248
// Confirm operation
214
249
if (FileOperationConfig::confirmDelete()) {
229
264
if (response!=KMessageBox::Continue) return;
233
if (mURLList.count()==1) {
234
// If there's only one file, KIO::move will think we want to overwrite
235
// the trash dir with the file to trash, so we add the file name
236
trashURL.addPath(mURLList.first().fileName());
238
KIO::Job* job=KIO::move(mURLList,trashURL);
239
job->setWindow(mParent->topLevelWidget());
240
connect( job, SIGNAL( result(KIO::Job*) ),
241
this, SLOT( slotResult(KIO::Job*) ) );
267
KIO::Job* job = createTrashJob(mURLList);
244
271
//-FileOpRealDeleteObject----------------------------------------------------------
271
298
// Delete the file
272
KIO::Job* removeJob=KIO::del(mURLList,false,true);
273
removeJob->setWindow(mParent->topLevelWidget());
274
connect( removeJob, SIGNAL( result(KIO::Job*) ),
275
this, SLOT( slotResult(KIO::Job*) ) );
299
KIO::Job* job = createDeleteJob(mURLList);
303
328
KURL destURL=srcURL;
304
329
destURL.setFileName(mNewFilename);
305
330
KIO::Job* job=KIO::move(srcURL,destURL);
306
job->setWindow(mParent->topLevelWidget());
307
connect( job, SIGNAL( result(KIO::Job*) ),
308
this, SLOT( slotResult(KIO::Job*) ) );