KSyntaxHighlighting

definitiondownloader.h
1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
8#define KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
9
10#include "ksyntaxhighlighting_export.h"
11
12#include <QObject>
13#include <memory>
14
15namespace KSyntaxHighlighting
16{
17class DefinitionDownloaderPrivate;
18class Repository;
19
20/**
21 * Helper class to download definition file updates.
22 *
23 * With the DefinitionDownloader you can download new and update existing
24 * syntax highlighting definition files (xml files).
25 *
26 * An example that updates the highlighting Definition%s and prints the current
27 * update progress to the console may look as follows:
28 *
29 * @code
30 * auto downloader = new DefinitionDownloader(repo); // repo is a pointer to a Repository
31 *
32 * // print update progress to console
33 * QObject::connect(downloader, &DefinitionDownloader::informationMessage, [](const QString &msg) {
34 * std::cout << qPrintable(msg) << std::endl;
35 * });
36 *
37 * // connect to signal done to delete the downloader later
38 * QObject::connect(downloader, &DefinitionDownloader::done,
39 * downloader, &DefinitionDownloader::deleteLater);
40 * downloader->start();
41 * @endcode
42 *
43 * @see Repository, Definition
44 * @since 5.28
45 */
46class KSYNTAXHIGHLIGHTING_EXPORT DefinitionDownloader : public QObject
47{
48 Q_OBJECT
49public:
50 /**
51 * Constructor.
52 * The Repository @p repo is used as reference to compare the versions of
53 * the existing Definition%s with the ones that are available online.
54 *
55 * Optionally, @p parent is a pointer to the owner of this instance.
56 */
57 explicit DefinitionDownloader(Repository *repo, QObject *parent = nullptr);
58
59 /**
60 * Destructor.
61 */
62 ~DefinitionDownloader() override;
63
64 /**
65 * Starts the update procedure.
66 * Once no more updates are available (i.e. either the local definition files
67 * are up-to-date, or all updates have been downloaded), the signal done()
68 * is emitted.
69 *
70 * During the update process, the signal informationMessage() can be used
71 * to display the current update progress to the user.
72 *
73 * @see done(), informationMessage()
74 */
75 void start();
76
77Q_SIGNALS:
78 /**
79 * Prints the information about the current state of the definition files.
80 * If all files are up-to-date, this signal is emitted informing you that
81 * all highlighting files are up-to-date. If there are updates, this signal
82 * is emitted for each update being downloaded.
83 */
84 void informationMessage(const QString &msg);
85
86 /**
87 * This signal is emitted when there are no pending downloads anymore.
88 */
89 void done();
90
91private:
92 std::unique_ptr<DefinitionDownloaderPrivate> d;
93};
94}
95
96#endif // KSYNTAXHIGHLIGHTING_DEFINITIONDOWNLOADER_H
Helper class to download definition file updates.
void done()
This signal is emitted when there are no pending downloads anymore.
void informationMessage(const QString &msg)
Prints the information about the current state of the definition files.
Syntax highlighting repository.
Definition repository.h:122
Q_SCRIPTABLE Q_NOREPLY void start()
Syntax highlighting engine for Kate syntax definitions.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.