• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • core
filedeleter.cpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2011 Matthias Fuchs <mat69@gmx.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #include "filedeleter.h"
21 #include "filedeleter_p.h"
22 
23 K_GLOBAL_STATIC(FileDeleter, fileDeleter)
24 
25 FileDeleter::Private::Private()
26  : QObject(0)
27 {
28 }
29 
30 FileDeleter::Private::~Private()
31 {
32 }
33 
34 bool FileDeleter::Private::isFileBeingDeleted(const KUrl &dest) const
35 {
36  return m_jobs.contains(dest);
37 }
38 
39 KJob *FileDeleter::Private::deleteFile(const KUrl &dest, QObject *receiver, const char *method)
40 {
41  QHash<KUrl, KJob*>::iterator it = m_jobs.find(dest);
42  if (it == m_jobs.end()) {
43  KJob *job = KIO::del(dest, KIO::HideProgressInfo);
44  it = m_jobs.insert(dest, job);
45  connect(*it, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*)));
46  }
47 
48  if (receiver && method) {
49  //make sure that there is just one connection
50  disconnect(*it, SIGNAL(result(KJob*)), receiver, method);
51  connect(*it, SIGNAL(result(KJob*)), receiver, method);
52  }
53 
54  return *it;
55 }
56 
57 void FileDeleter::Private::slotResult(KJob *job)
58 {
59  KIO::DeleteJob *deleteJob = static_cast<KIO::DeleteJob*>(job);
60  m_jobs.remove(deleteJob->urls().first());
61 }
62 
63 FileDeleter::FileDeleter()
64  : d(new Private)
65 {
66 }
67 
68 FileDeleter::~FileDeleter()
69 {
70  delete d;
71 }
72 
73 KJob *FileDeleter::deleteFile(const KUrl &dest, QObject *receiver, const char *method)
74 {
75  return fileDeleter->d->deleteFile(dest, receiver, method);
76 }
77 
78 bool FileDeleter::isFileBeingDeleted(const KUrl &dest)
79 {
80  return fileDeleter->d->isFileBeingDeleted(dest);
81 }
82 
83 #include "filedeleter.moc"
84 #include "filedeleter_p.moc"
FileDeleter::FileDeleter
FileDeleter()
Definition: filedeleter.cpp:63
FileDeleter::Private::isFileBeingDeleted
bool isFileBeingDeleted(const KUrl &dest) const
Definition: filedeleter.cpp:34
filedeleter_p.h
QObject
FileDeleter::deleteFile
static KJob * deleteFile(const KUrl &dest, QObject *receiver=0, const char *method=0)
Starts the deletion of dest and emits KJob::finished once done.
Definition: filedeleter.cpp:73
FileDeleter::Private::~Private
~Private()
Definition: filedeleter.cpp:30
FileDeleter::Private
Definition: filedeleter_p.h:29
FileDeleter::Private::deleteFile
KJob * deleteFile(const KUrl &dest, QObject *receiver, const char *method)
Definition: filedeleter.cpp:39
filedeleter.h
FileDeleter
The FileDeleter is a wrapper around KIO ensuring that always just one job is started for deleting a f...
Definition: filedeleter.h:35
FileDeleter::~FileDeleter
~FileDeleter()
Definition: filedeleter.cpp:68
FileDeleter::isFileBeingDeleted
static bool isFileBeingDeleted(const KUrl &dest)
Definition: filedeleter.cpp:78
KJob
FileDeleter::Private::slotResult
void slotResult(KJob *job)
Definition: filedeleter.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal