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

« back to all changes in this revision

Viewing changes to lib/document/documentjob.h

  • 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>
31
31
// Local
32
32
#include <lib/document/document.h>
33
33
 
34
 
namespace Gwenview {
35
 
 
 
34
namespace Gwenview
 
35
{
36
36
 
37
37
class DocumentJobPrivate;
38
38
 
47
47
 * You can of course use threading inside your task implementation to speed it
48
48
 * up.
49
49
 */
50
 
class GWENVIEWLIB_EXPORT DocumentJob : public KCompositeJob {
51
 
        Q_OBJECT
 
50
class GWENVIEWLIB_EXPORT DocumentJob : public KCompositeJob
 
51
{
 
52
    Q_OBJECT
52
53
public:
53
 
        enum {
54
 
                NoDocumentEditorError = UserDefinedError + 1
55
 
        };
56
 
        DocumentJob();
57
 
        ~DocumentJob();
58
 
 
59
 
        Document::Ptr document() const;
60
 
 
61
 
        virtual void start();
 
54
    enum {
 
55
        NoDocumentEditorError = UserDefinedError + 1
 
56
    };
 
57
    DocumentJob();
 
58
    ~DocumentJob();
 
59
 
 
60
    Document::Ptr document() const;
 
61
 
 
62
    virtual void start();
62
63
 
63
64
protected Q_SLOTS:
64
 
        /**
65
 
         * Implement this method to provide the task behavior.
66
 
         * You *must* emit the done() signal when your work is finished, but it
67
 
         * does not have to be finished when run() returns.
68
 
         * If you are not emitting it from the GUI thread, then use a queued
69
 
         * connection to emit it.
70
 
         */
71
 
        virtual void doStart() = 0;
 
65
    /**
 
66
     * Implement this method to provide the task behavior.
 
67
     * You *must* emit the done() signal when your work is finished, but it
 
68
     * does not have to be finished when run() returns.
 
69
     * If you are not emitting it from the GUI thread, then use a queued
 
70
     * connection to emit it.
 
71
     */
 
72
    virtual void doStart() = 0;
72
73
 
73
 
        /**
74
 
         * slot-ification of emitResult()
75
 
         */
76
 
        void emitResult() {
77
 
                KJob::emitResult();
78
 
        }
 
74
    /**
 
75
     * slot-ification of emitResult()
 
76
     */
 
77
    void emitResult() {
 
78
        KJob::emitResult();
 
79
    }
79
80
 
80
81
protected:
81
 
        /**
82
 
         * Convenience method which checks document()->editor() is valid
83
 
         * and set the job error properties if it's not.
84
 
         * @return true if the editor is valid.
85
 
         */
86
 
        bool checkDocumentEditor();
 
82
    /**
 
83
     * Convenience method which checks document()->editor() is valid
 
84
     * and set the job error properties if it's not.
 
85
     * @return true if the editor is valid.
 
86
     */
 
87
    bool checkDocumentEditor();
87
88
 
88
89
private:
89
 
        void setDocument(const Document::Ptr&);
90
 
 
91
 
        DocumentJobPrivate* const d;
92
 
 
93
 
        friend class Document;
 
90
    void setDocument(const Document::Ptr&);
 
91
 
 
92
    DocumentJobPrivate* const d;
 
93
 
 
94
    friend class Document;
94
95
};
95
96
 
96
 
 
97
97
/**
98
98
 * A document job whose action is started in a separate thread
99
99
 */
100
 
class ThreadedDocumentJob : public DocumentJob {
 
100
class ThreadedDocumentJob : public DocumentJob
 
101
{
101
102
public:
102
 
        /**
103
 
         * Must be reimplemented to apply the action to the document.
104
 
         * This method is never called from the GUI thread.
105
 
         */
106
 
        virtual void threadedStart() = 0;
 
103
    /**
 
104
     * Must be reimplemented to apply the action to the document.
 
105
     * This method is never called from the GUI thread.
 
106
     */
 
107
    virtual void threadedStart() = 0;
107
108
 
108
109
protected:
109
 
        virtual void doStart();
 
110
    virtual void doStart();
110
111
};
111
112
 
112
 
 
113
 
 
114
113
} // namespace
115
114
 
116
115
#endif /* DOCUMENTJOB_H */