File: archivetemplateloader.h

package info (click to toggle)
kdevelop 4%3A24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 71,888 kB
  • sloc: cpp: 290,869; python: 3,626; javascript: 3,518; sh: 1,316; ansic: 703; xml: 401; php: 95; lisp: 66; makefile: 31; sed: 12
file content (62 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
    SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef KDEVPLATFORM_ARCHIVETEMPLATELOADER_H
#define KDEVPLATFORM_ARCHIVETEMPLATELOADER_H

#include <KTextTemplate/TemplateLoader>

class KArchiveDirectory;
namespace KDevelop {
class ArchiveTemplateLocation;
class ArchiveTemplateLoaderPrivate;

class ArchiveTemplateLoader : public KTextTemplate::AbstractTemplateLoader
{
public:
    static ArchiveTemplateLoader* self();
    ~ArchiveTemplateLoader() override;
    bool canLoadTemplate(const QString& name) const override;
    KTextTemplate::Template loadByName(const QString& name, const KTextTemplate::Engine* engine) const override;

    QPair<QString, QString> getMediaUri(const QString& fileName) const override;

protected:
    friend class ArchiveTemplateLocation;
    void addLocation(ArchiveTemplateLocation* location);
    void removeLocation(ArchiveTemplateLocation* location);

private:
    Q_DISABLE_COPY(ArchiveTemplateLoader)
    ArchiveTemplateLoader();

    const QScopedPointer<class ArchiveTemplateLoaderPrivate> d_ptr;
    Q_DECLARE_PRIVATE(ArchiveTemplateLoader)
};

/**
 * RAII class that should be used to add KArchiveDirectory locations to the engine.
 *
 * Adds the archive @p directory to the list of places searched for templates
 * during the lifetime of the created ArchiveTemplateLocation class.
 */
class ArchiveTemplateLocation
{
public:
    explicit ArchiveTemplateLocation(const KArchiveDirectory* directory);
    ~ArchiveTemplateLocation();

    bool hasTemplate(const QString& name) const;
    QString templateContents(const QString& name) const;

private:
    Q_DISABLE_COPY(ArchiveTemplateLocation)

    const KArchiveDirectory* m_directory;
};
}

#endif // KDEVPLATFORM_ARCHIVETEMPLATELOADER_H