27#ifndef LMMS_DEPRECATIONHELPER_H
28#define LMMS_DEPRECATIONHELPER_H
32#include <QDomDocument>
33#include <QFontMetrics>
34#include <QKeySequence>
50#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
51 return de->position().toPoint();
67#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
68 return me->position().toPoint();
84#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
85 return me->position();
87 return me->localPos();
101#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
102 return me->globalPosition().toPoint();
104 return me->globalPos();
113 || std::is_same_v<T, Qt::Modifier> || std::is_same_v<T, Qt::KeyboardModifier>;
129 return (0 | ... |
static_cast<int>(args));
138inline QMetaType::Type
typeId(
const QVariant& variant)
140#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
141 return static_cast<QMetaType::Type
>(variant.typeId());
143 return static_cast<QMetaType::Type
>(variant.type());
151inline bool setContent(QDomDocument& doc,
const QByteArray& text,
152 QString* errorMsg =
nullptr,
int* errorLine =
nullptr,
int* errorColumn =
nullptr)
154#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
155 auto result = doc.setContent(text, QDomDocument::ParseOption::Default);
156 if (result) {
return true; }
157 if (errorMsg) { *errorMsg = std::move(result.errorMessage); }
158 if (errorLine) { *errorLine =
static_cast<int>(result.errorLine); }
159 if (errorColumn) { *errorColumn =
static_cast<int>(result.errorColumn); }
162 return doc.setContent(text, errorMsg, errorLine, errorColumn);
170inline bool setContent(QDomDocument& doc, QIODevice* dev,
bool namespaceProcessing,
171 QString* errorMsg =
nullptr,
int* errorLine =
nullptr,
int* errorColumn =
nullptr)
173#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
174 const auto options = namespaceProcessing
175 ? QDomDocument::ParseOption::UseNamespaceProcessing
176 : QDomDocument::ParseOption::Default;
177 auto result = doc.setContent(dev, options);
178 if (result) {
return true; }
179 if (errorMsg) { *errorMsg = std::move(result.errorMessage); }
180 if (errorLine) { *errorLine =
static_cast<int>(result.errorLine); }
181 if (errorColumn) { *errorColumn =
static_cast<int>(result.errorColumn); }
184 return doc.setContent(dev, namespaceProcessing, errorMsg, errorLine, errorColumn);
constexpr bool IsKeyOrModifier
Definition DeprecationHelper.h:112
Definition RemotePluginBase.cpp:34
QPointF positionF(const QMouseEvent *me)
Backwards-compatible adapter for QMouseEvent's new position() to the old localPos() method.
Definition DeprecationHelper.h:82
QPoint position(const QDropEvent *de)
Backwards-compatible adapter for QDropEvent's new position() to the old pos() method.
Definition DeprecationHelper.h:48
QMetaType::Type typeId(const QVariant &variant)
Backwards-compatible adapter for QVariant's new typeId() to the old type() method.
Definition DeprecationHelper.h:138
bool setContent(QDomDocument &doc, const QByteArray &text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr)
Backwards-compatible adapter for QDomDocument::setContent() for QByteArray input.
Definition DeprecationHelper.h:151
QPoint globalPosition(const QMouseEvent *me)
Backwards-compatible adapter for QMouseEvent's new globalPosition() to the old globalPos() method.
Definition DeprecationHelper.h:99
QKeySequence keySequence(Args... args)
Combines Qt key and modifier arguments together.
Definition DeprecationHelper.h:127