~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/document/documentjob.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2010 Aurélien Gâteau <agateau@kde.org>
34
34
 
35
35
// Local
36
36
 
37
 
namespace Gwenview {
38
 
 
 
37
namespace Gwenview
 
38
{
39
39
 
40
40
struct DocumentJobPrivate {
41
 
        Document::Ptr mDoc;
 
41
    Document::Ptr mDoc;
42
42
};
43
43
 
44
 
 
45
44
DocumentJob::DocumentJob()
46
45
: KCompositeJob(0)
47
 
, d(new DocumentJobPrivate) {
48
 
        KDialogJobUiDelegate* delegate = new KDialogJobUiDelegate;
49
 
        delegate->setWindow(KApplication::kApplication()->activeWindow());
50
 
        delegate->setAutoErrorHandlingEnabled(true);
51
 
        setUiDelegate(delegate);
52
 
}
53
 
 
54
 
 
55
 
DocumentJob::~DocumentJob() {
56
 
        delete d;
57
 
}
58
 
 
59
 
 
60
 
Document::Ptr DocumentJob::document() const {
61
 
        return d->mDoc;
62
 
}
63
 
 
64
 
 
65
 
void DocumentJob::setDocument(const Document::Ptr& doc) {
66
 
        d->mDoc = doc;
67
 
}
68
 
 
69
 
 
70
 
void DocumentJob::start() {
71
 
        QMetaObject::invokeMethod(this, "doStart", Qt::QueuedConnection);
72
 
}
73
 
 
74
 
 
75
 
bool DocumentJob::checkDocumentEditor() {
76
 
        if (!document()->editor()) {
77
 
                setError(NoDocumentEditorError);
78
 
                setErrorText(i18nc("@info", "Gwenview cannot edit this kind of image."));
79
 
                return false;
80
 
        }
81
 
        return true;
82
 
}
83
 
 
84
 
 
85
 
void ThreadedDocumentJob::doStart() {
86
 
        QFuture<void> future = QtConcurrent::run(this, &ThreadedDocumentJob::threadedStart);
87
 
        QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this);
88
 
        watcher->setFuture(future);
89
 
        connect(watcher, SIGNAL(finished()), SLOT(emitResult()));
 
46
, d(new DocumentJobPrivate)
 
47
{
 
48
    KDialogJobUiDelegate* delegate = new KDialogJobUiDelegate;
 
49
    delegate->setWindow(KApplication::kApplication()->activeWindow());
 
50
    delegate->setAutoErrorHandlingEnabled(true);
 
51
    setUiDelegate(delegate);
 
52
}
 
53
 
 
54
DocumentJob::~DocumentJob()
 
55
{
 
56
    delete d;
 
57
}
 
58
 
 
59
Document::Ptr DocumentJob::document() const
 
60
{
 
61
    return d->mDoc;
 
62
}
 
63
 
 
64
void DocumentJob::setDocument(const Document::Ptr& doc)
 
65
{
 
66
    d->mDoc = doc;
 
67
}
 
68
 
 
69
void DocumentJob::start()
 
70
{
 
71
    QMetaObject::invokeMethod(this, "doStart", Qt::QueuedConnection);
 
72
}
 
73
 
 
74
bool DocumentJob::checkDocumentEditor()
 
75
{
 
76
    if (!document()->editor()) {
 
77
        setError(NoDocumentEditorError);
 
78
        setErrorText(i18nc("@info", "Gwenview cannot edit this kind of image."));
 
79
        return false;
 
80
    }
 
81
    return true;
 
82
}
 
83
 
 
84
void ThreadedDocumentJob::doStart()
 
85
{
 
86
    QFuture<void> future = QtConcurrent::run(this, &ThreadedDocumentJob::threadedStart);
 
87
    QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this);
 
88
    watcher->setFuture(future);
 
89
    connect(watcher, SIGNAL(finished()), SLOT(emitResult()));
90
90
}
91
91
 
92
92
} // namespace