KoResourceServerProvider.h 2.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*  This file is part of the KDE project

    Copyright (c) 1999 Matthias Elter <elter@kde.org>
    Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
    Copyright (c) 2005 Sven Langkamp <sven.langkamp@gmail.com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

22 23
#ifndef KORESOURCESERVERPROVIDER_H
#define KORESOURCESERVERPROVIDER_H
24

25
#include <kowidgets_export.h>
26

27
#include <QThread>
28

29 30
#include <kdebug.h>

31
#include "KoResourceServer.h"
32 33 34
#include "KoPattern.h"
#include "KoAbstractGradient.h"
#include "KoColorSet.h"
35

Sven Langkamp's avatar
Sven Langkamp committed
36 37 38
/**
 * KoResourceLoaderThread allows threaded loading of the resources of a resource server
 */
39
class KOWIDGETS_EXPORT KoResourceLoaderThread : public QThread {
40

41
    Q_OBJECT
42 43
public:

Sven Langkamp's avatar
Sven Langkamp committed
44
    /**
45 46 47
     * Constructs a KoResourceLoaderThread for a server
     * @param server the server the resources will be loaded for
     */
48
    explicit KoResourceLoaderThread(KoResourceServerBase *server);
49
    ~KoResourceLoaderThread();
50
public slots:
51 52
    /**
     * Checks whether the thread has finished loading and waits
53
     * until it is finished if necessary
54 55 56 57 58 59 60
     */
    void barrier();

protected:
    /**
     * Overridden from QThread
     */
61
    void run();
62

63
private:
64

65
    KoResourceServerBase * m_server;
66
    QStringList m_fileNames;
67 68 69
};


Sven Langkamp's avatar
Sven Langkamp committed
70 71 72
/**
 * Provides default resource servers for gradients, patterns and palettes
 */
73
class KOWIDGETS_EXPORT KoResourceServerProvider : public QObject
74
{
75 76
    Q_OBJECT

77
public:
78
    virtual ~KoResourceServerProvider();
79

80
    static KoResourceServerProvider* instance();
81

82 83 84
    KoResourceServer<KoPattern>* patternServer();
    KoResourceServer<KoAbstractGradient>* gradientServer();
    KoResourceServer<KoColorSet>* paletteServer();
85

86
private:
87 88 89
    KoResourceServerProvider();
    KoResourceServerProvider(const KoResourceServerProvider&);
    KoResourceServerProvider operator=(const KoResourceServerProvider&);
90

91
private:
92 93
    struct Private;
    Private* const d;
94 95
};

96
#endif // KORESOURCESERVERPROVIDER_H