File indexing completed on 2023-09-24 08:07:37
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef DEPRECATED_H 0008 #define DEPRECATED_H 0009 0010 #include "charts_deprecated_logging.h" 0011 0012 #include <QQmlContext> 0013 #include <QQmlEngine> 0014 0015 /** 0016 * Tiny helper macro to mark a QML item as deprecated. 0017 * 0018 * This should be placed into the item's constructor and will output a 0019 * deprecation message when the item is instantiated. 0020 * 0021 * All parameters are expected to be strings. 0022 * 0023 * \param item The name of the item that is deprecated. 0024 * \param since The version since when the deprecation happened. 0025 * \param message An extra message to display, like which item to use instead. 0026 */ 0027 // clang-format off 0028 #define QML_DEPRECATED(item, since, message) \ 0029 QMetaObject::invokeMethod(this, [this]() {\ 0030 qCWarning(DEPRECATED).nospace() << item << " is deprecated (since " << since << "): " << message;\ 0031 if (!qmlContext(this)) return;\ 0032 QString elidedName = QStringLiteral("...") + qmlContext(this)->baseUrl().toString().right(80);\ 0033 qCWarning(DEPRECATED) << "Note: Instantiated from" << elidedName;\ 0034 }, Qt::QueuedConnection); 0035 // clang-format on 0036 0037 #endif // DEPRECATED_H