diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-09 10:26:49 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-13 10:21:37 +0000 |
commit | ac6bb3170d86006832170377cd5f51ff809b4455 (patch) | |
tree | a4ff77347e9c5b87e94a19f827e7248201e7bd93 /src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h | |
parent | 8fdfd9ff5ded388a3d29c917aebb795485abfbfd (diff) |
Tooling: Add QML preview debug service
Task-number: QDS-181
Change-Id: I02193afb84aa111792d8bebff3bdd9b410f9db5a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h new file mode 100644 index 0000000000..de0a9cadea --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QML preview debug service. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLPREVIEWFILELOADER_H +#define QQMLPREVIEWFILELOADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlpreviewblacklist.h" + +#include <QtCore/qobject.h> +#include <QtCore/qthread.h> +#include <QtCore/qmutex.h> +#include <QtCore/qwaitcondition.h> +#include <QtCore/qvector.h> +#include <QtCore/qurl.h> +#include <QtCore/qpointer.h> +#include <QtCore/qset.h> + +QT_BEGIN_NAMESPACE + +class QQmlPreviewServiceImpl; +class QQmlPreviewFileLoader : public QObject +{ + Q_OBJECT +public: + enum Result { + File, + Directory, + Fallback, + Unknown + }; + + QQmlPreviewFileLoader(QQmlPreviewServiceImpl *service); + ~QQmlPreviewFileLoader(); + + Result load(const QString &file); + QByteArray contents(); + QStringList entries(); + + void whitelist(const QUrl &url); + bool isBlacklisted(const QString &file); + +signals: + void request(const QString &file); + +private: + QMutex m_mutex; + QWaitCondition m_waitCondition; + + QThread m_thread; + QPointer<QQmlPreviewServiceImpl> m_service; + + QString m_path; + QByteArray m_contents; + QStringList m_entries; + Result m_result; + + QQmlPreviewBlacklist m_blacklist; + QHash<QString, QByteArray> m_fileCache; + QHash<QString, QStringList> m_directoryCache; + + void file(const QString &file, const QByteArray &contents); + void directory(const QString &file, const QStringList &entries); + void error(const QString &file); + void clearCache(); +}; + +QT_END_NAMESPACE + +#endif // QQMLPREVIEWFILELOADER_H |