~ubuntu-branches/debian/sid/libmediawiki/sid

« back to all changes in this revision

Viewing changes to src/job.cpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2017-11-05 21:15:29 UTC
  • Revision ID: package-import@ubuntu.com-20171105211529-bgfi385yv79030cf
Tags: upstream-5.37.0
ImportĀ upstreamĀ versionĀ 5.37.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** ===========================================================
 
2
 * @file
 
3
 *
 
4
 * This file is a part of KDE project
 
5
 * <a href="https://projects.kde.org/projects/extragear/libs/libmediawiki">libmediawiki</a>
 
6
 *
 
7
 * @date   2011-03-22
 
8
 * @brief  a MediaWiki C++ interface for KDE
 
9
 *
 
10
 * @author Copyright (C) 2011-2012 by Gilles Caulier
 
11
 *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
 
12
 * @author Copyright (C) 2009 by Paolo de Vathaire
 
13
 *         <a href="mailto:paolo dot devathaire at gmail dot com">paolo dot devathaire at gmail dot com</a>
 
14
 *
 
15
 * This program is free software; you can redistribute it
 
16
 * and/or modify it under the terms of the GNU General
 
17
 * Public License as published by the Free Software Foundation;
 
18
 * either version 2, or (at your option)
 
19
 * any later version.
 
20
 *
 
21
 * This program is distributed in the hope that it will be useful,
 
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
24
 * GNU General Public License for more details.
 
25
 *
 
26
 * ============================================================ */
 
27
 
 
28
#include "job.h"
 
29
 
 
30
// Qt includes
 
31
 
 
32
#include <QtNetwork/QNetworkReply>
 
33
 
 
34
// Local include
 
35
 
 
36
#include "mediawiki.h"
 
37
#include "job_p.h"
 
38
 
 
39
namespace mediawiki
 
40
{
 
41
 
 
42
Job::Job(JobPrivate& dd, QObject* const parent)
 
43
    : KJob(parent),
 
44
      d_ptr(&dd)
 
45
{
 
46
    setCapabilities(Job::Killable);
 
47
}
 
48
 
 
49
Job::~Job()
 
50
{
 
51
    delete d_ptr;
 
52
}
 
53
 
 
54
bool Job::doKill()
 
55
{
 
56
    Q_D(Job);
 
57
    if (d->reply != 0)
 
58
    {
 
59
        d->reply->abort();
 
60
    }
 
61
    return true;
 
62
}
 
63
 
 
64
void Job::connectReply()
 
65
{
 
66
    Q_D(Job);
 
67
    connect(d->reply, SIGNAL(uploadProgress(qint64,qint64)),
 
68
            this, SLOT(processUploadProgress(qint64,qint64)));
 
69
}
 
70
 
 
71
void Job::processUploadProgress(qint64 bytesReceived, qint64 bytesTotal)
 
72
{
 
73
    setTotalAmount(Job::Bytes, bytesTotal);
 
74
    setProcessedAmount(Job::Bytes, bytesReceived);
 
75
}
 
76
 
 
77
} // namespace mediawiki