1
/****************************************************************************************
2
 * Copyright (c) 2010 Bart Cerneels <bart.cerneels@kde.org>                             *
3
 *                                                                                      *
4
 * This program is free software; you can redistribute it and/or modify it under        *
5
 * the terms of the GNU General Public License as published by the Free Software        *
6
 * Foundation; either version 2 of the License, or (at your option) any later           *
7
 * version.                                                                             *
8
 *                                                                                      *
9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12
 *                                                                                      *
13
 * You should have received a copy of the GNU General Public License along with         *
14
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15
 ****************************************************************************************/
16
17
#ifndef OPMLWRITER_H
18
#define OPMLWRITER_H
19
20
#include "OpmlOutline.h"
21
22
#include <threadweaver/Job.h>
23
#include <KUrl>
24
25
#include <QXmlStreamWriter>
26
27
class OpmlWriter : public ThreadWeaver::Job
28
{
29
    Q_OBJECT
30
    public:
31
        OpmlWriter( const OpmlOutline *rootOutline, QIODevice *device );
32
33
        /**
34
         * The function that starts the actual work. Inherited from ThreadWeaver::Job
35
         * Note the work is performed in a separate thread
36
         * @return Returns true on success and false on failure
37
         */
38
        void run();
39
40
        QIODevice *device() { return m_xmlWriter->device(); }
41
42
    signals:
43
        /**
44
         * Signal emmited when writing is complete.
45
         */
46
        void result( int error );
47
48
    private:
49
        void writeOutline( const OpmlOutline *outline );
50
        const OpmlOutline *m_rootOutline;
51
        KUrl m_fileUrl;
52
        QXmlStreamWriter *m_xmlWriter;
53
};
54
55
#endif // OPMLWRITER_H