Changeset View
Changeset View
Standalone View
Standalone View
dataengines/applicationjobs/jobaction.cpp
Show All 21 Lines | |||||
22 | #include <kio/global.h> | 22 | #include <kio/global.h> | ||
23 | #include <klocalizedstring.h> | 23 | #include <klocalizedstring.h> | ||
24 | #include <QDebug> | 24 | #include <QDebug> | ||
25 | 25 | | |||
26 | void JobAction::start() | 26 | void JobAction::start() | ||
27 | { | 27 | { | ||
28 | qDebug() << "Trying to perform the action" << operationName(); | 28 | qDebug() << "Trying to perform the action" << operationName(); | ||
29 | 29 | | |||
30 | if (!m_jobView) { | 30 | if (!m_job) { | ||
31 | setErrorText(i18nc("%1 is the subject (can be anything) upon which the job is performed", | 31 | setErrorText(i18nc("%1 is the subject (can be anything) upon which the job is performed", | ||
32 | "The JobView for %1 cannot be found", destination())); | 32 | "The JobView for %1 cannot be found", destination())); | ||
33 | setError(-1); | 33 | setError(-1); | ||
34 | emitResult(); | 34 | emitResult(); | ||
35 | return; | 35 | return; | ||
36 | } | 36 | } | ||
37 | 37 | | |||
38 | //TODO: check with capabilities before performing actions. | 38 | //TODO: check with capabilities before performing actions. | ||
39 | if (operationName() == QLatin1String("resume")) { | 39 | if (operationName() == QLatin1String("resume")) { | ||
40 | m_jobView->requestStateChange(JobView::Running); | 40 | m_job->resume(); | ||
41 | } else if (operationName() == QLatin1String("suspend")) { | 41 | } else if (operationName() == QLatin1String("suspend")) { | ||
42 | m_jobView->requestStateChange(JobView::Suspended); | 42 | m_job->suspend(); | ||
43 | } else if (operationName() == QLatin1String("stop")) { | 43 | } else if (operationName() == QLatin1String("stop")) { | ||
44 | m_jobView->requestStateChange(JobView::Stopped); | 44 | m_job->kill(); | ||
45 | //in case the app crashed and won't call terminate on the jobview. | | |||
46 | m_jobView->setError(KIO::ERR_USER_CANCELED); | | |||
47 | m_jobView->terminate(i18n("Job canceled by user.")); | | |||
48 | } | 45 | } | ||
49 | 46 | | |||
50 | emitResult(); | 47 | emitResult(); | ||
51 | } | 48 | } | ||
52 | | ||||
53 | | ||||
54 | |