1
/***************************************************************************
2
* Copyright 2013-2014 Maciej Poleski *
4
* This program is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public License as *
6
* published by the Free Software Foundation; either version 2 of *
7
* the License or (at your option) version 3 or any later version *
8
* accepted by the membership of KDE e.V. (or its successor approved *
9
* by the membership of KDE e.V.), which shall act as a proxy *
10
* defined in Section 14 of version 3 of the license. *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
19
***************************************************************************/
23
#include <QtCore/QVariant>
25
#include <KIO/CopyJob>
27
#include <interfaces/iplugin.h>
28
#include <vcs/dvcs/dvcsjob.h>
30
#include "bazaarplugin.h"
32
CopyJob::CopyJob(const KUrl& localLocationSrc, const KUrl& localLocationDstn, BazaarPlugin* parent, KDevelop::OutputJob::OutputJobVerbosity verbosity)
33
: VcsJob(parent, verbosity), m_plugin(parent), m_source(localLocationSrc),
34
m_destination(localLocationDstn), m_status(KDevelop::VcsJob::JobNotStarted)
36
setType(JobType::Copy);
37
setCapabilities(Killable);
41
KDevelop::IPlugin* CopyJob::vcsPlugin() const
46
KDevelop::VcsJob::JobStatus CopyJob::status() const
51
QVariant CopyJob::fetchResults()
58
if (m_status != KDevelop::VcsJob::JobNotStarted)
60
KIO::CopyJob* job = KIO::copy(m_source, m_destination, KIO::HideProgressInfo);
61
connect(job, SIGNAL(copyingDone(KIO::Job*, KUrl, KUrl, time_t, bool, bool)), this, SLOT(addToVcs(KIO::Job*, KUrl, KUrl, time_t, bool, bool)));
62
m_status = KDevelop::VcsJob::JobRunning;
67
bool CopyJob::doKill()
69
m_status = KDevelop::VcsJob::JobCanceled;
71
return m_job->kill(KJob::Quietly);
76
void CopyJob::addToVcs(KIO::Job* job, const KUrl& from, const KUrl& to, time_t mtime, bool directory, bool renamed)
83
if (m_status != KDevelop::VcsJob::JobRunning)
85
KDevelop::VcsJob* job2 = m_plugin->add(to, KDevelop::IBasicVersionControl::Recursive);
86
connect(job2, SIGNAL(result(KJob*)), this, SLOT(finish(KJob*)));
91
void CopyJob::finish(KJob*)
93
m_status = KDevelop::VcsJob::JobSucceeded;
95
emit resultsReady(this);
99
#include "copyjob.moc"