File indexing completed on 2024-05-12 11:55:20
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 QMLDEPRECATED_H 0008 #define QMLDEPRECATED_H 0009 0010 #include "kitemmodelsqml_logdeprecated.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 0028 /* clang-format off */ 0029 #define QML_DEPRECATED(item, since, message) \ 0030 QMetaObject::invokeMethod( \ 0031 this, \ 0032 [this]() { \ 0033 qCWarning(KITEMMODELS_LOGDEPRECATED).nospace() << item << " is deprecated (since " << since << "): " << message;\ 0034 const QString elidedName = QLatin1String("...") + qmlContext(this)->baseUrl().toString().right(80); \ 0035 qCWarning(KITEMMODELS_LOGDEPRECATED) << "Note: Instantiated from" << elidedName; \ 0036 }, \ 0037 Qt::QueuedConnection); 0038 /* clang-format on */ 0039 #endif // QMLDEPRECATED_H