• 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
kgetglobaljob.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2007 by Javier Goday <jgoday@gmail.com>
4  Copyright (C) 2009 by Dario Massarin <nekkar@libero.it>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 */
11 #include "kgetglobaljob.h"
12 #include "transferhandler.h"
13 #include "kget.h"
14 
15 #include <klocale.h>
16 #include <kuiserverjobtracker.h>
17 
18 #include <QTimer>
19 
20 KGetGlobalJob::KGetGlobalJob(QObject *parent)
21  : KJob(parent)
22 {
23  setCapabilities(Killable);
24 }
25 
26 KGetGlobalJob::~KGetGlobalJob()
27 {
28 }
29 
30 
31 void KGetGlobalJob::update()
32 {
33  int runningTransfers = 0;
34  qulonglong processedAmount = 0;
35  qulonglong totalAmount = 0;
36  unsigned long speed = 0;
37  unsigned long percent = 0;
38 
39  foreach(TransferHandler * transfer, KGet::allTransfers()) {
40  if(transfer->status() == Job::Running) {
41  runningTransfers++;
42  processedAmount += transfer->downloadedSize();
43  speed += transfer->downloadSpeed();
44  totalAmount += transfer->totalSize();
45  }
46  }
47 
48 // kDebug(5001) << totalAmount;
49 
50  if (totalAmount > 0)
51  percent = 100 * processedAmount / totalAmount;
52  else
53  percent = 0;
54 
55  emit description(this, "KGet global information",
56  qMakePair(QString("source"), i18np("KGet is downloading %1 file", "KGet is downloading %1 files", runningTransfers)));
57 
58  emitSpeed(speed);
59  setTotalAmount(KJob::Bytes, totalAmount);
60  setProcessedAmount(KJob::Bytes, processedAmount);
61 
62  setPercent(percent);
63 }
64 
65 bool KGetGlobalJob::doKill()
66 {
67  kDebug(5001) << "Kill of global job called:" << this;
68  emit requestStop(this, 0);
69  return KJob::doKill();
70 }
71 
TransferHandler::status
Job::Status status() const
Definition: transferhandler.h:64
TransferHandler
Class TransferHandler:
Definition: transferhandler.h:48
KGetGlobalJob::update
void update()
Definition: kgetglobaljob.cpp:31
TransferHandler::totalSize
KIO::filesize_t totalSize() const
Definition: transferhandler.cpp:86
KGetGlobalJob::KGetGlobalJob
KGetGlobalJob(QObject *parent=0)
Definition: kgetglobaljob.cpp:20
QObject
KGet::allTransfers
static QList< TransferHandler * > allTransfers()
Gets all transfers.
Definition: kget.cpp:657
KGetGlobalJob::doKill
virtual bool doKill()
Definition: kgetglobaljob.cpp:65
Job::Running
Definition: job.h:43
KGetGlobalJob::requestStop
void requestStop(KJob *job, TransferHandler *handler)
Emitted when doKill is called, e.g.
TransferHandler::downloadSpeed
int downloadSpeed() const
Definition: transferhandler.cpp:106
transferhandler.h
TransferHandler::downloadedSize
KIO::filesize_t downloadedSize() const
Definition: transferhandler.cpp:91
KGetGlobalJob::~KGetGlobalJob
~KGetGlobalJob()
Definition: kgetglobaljob.cpp:26
kget.h
kgetglobaljob.h
KJob
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