Commit a2ecf104 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[Qt6] Port some deprecated QVariant functions

parent 842958f2
......@@ -220,7 +220,11 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, const QVariant &ne
if (ptr->m_selectedKeyframes.size() > 1) {
// We have several selected keyframes, move them all
double offset = 0.;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (newVal.isValid() && newVal.type() == QVariant::Double) {
#else
if (newVal.isValid() && newVal.typeId() == QMetaType::Double) {
#endif
int row = static_cast<int>(std::distance(m_keyframeList.begin(), m_keyframeList.find(oldPos)));
double oldVal = data(index(row), NormalizedValueRole).toDouble();
offset = newVal.toDouble() - oldVal;
......@@ -1023,7 +1027,7 @@ void KeyframeModel::parseRotoProperty(const QString &prop)
QJsonParseError jsonError;
QJsonDocument doc = QJsonDocument::fromJson(prop.toLatin1(), &jsonError);
QVariant data = doc.toVariant();
if (data.canConvert(QMetaType::QVariantMap)) {
if (data.canConvert<QVariantMap>()) {
QMap<QString, QVariant> map = data.toMap();
QMap<QString, QVariant>::const_iterator i = map.constBegin();
while (i != map.constEnd()) {
......
......@@ -68,7 +68,7 @@ QList<BPoint> RotoHelper::getPoints(const QVariant &value, const QSize frame)
QList<QVariant> data = value.toList();
// skip tracking flag
if (data.count() && data.at(0).canConvert(QMetaType::QString)) {
if (data.count() && data.at(0).canConvert<QString>()) {
data.removeFirst();
}
......
......@@ -907,7 +907,13 @@ QJsonDocument AssetParameterModel::toJson(bool includeFixed) const
QModelIndex ix = index(m_rows.indexOf(fixed.first), 0);
currentParam.insert(QLatin1String("name"), QJsonValue(fixed.first));
currentParam.insert(QLatin1String("value"),
fixed.second.type() == QVariant::Double ? QJsonValue(fixed.second.toDouble()) : QJsonValue(fixed.second.toString()));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
fixed.second.type() == QVariant::Double
#else
fixed.second.typeId() == QMetaType::Double
#endif
? QJsonValue(fixed.second.toDouble())
: QJsonValue(fixed.second.toString()));
int type = data(ix, AssetParameterModel::TypeRole).toInt();
double min = data(ix, AssetParameterModel::MinRole).toDouble();
double max = data(ix, AssetParameterModel::MaxRole).toDouble();
......@@ -954,8 +960,15 @@ QJsonDocument AssetParameterModel::toJson(bool includeFixed) const
currentParam.insert(QLatin1String("name"), QJsonValue(param.first));
currentParam.insert(QLatin1String("DisplayName"), QJsonValue(param.second.name));
currentParam.insert(QLatin1String("value"), param.second.value.type() == QVariant::Double ? QJsonValue(param.second.value.toDouble())
: QJsonValue(param.second.value.toString()));
currentParam.insert(QLatin1String("value"),
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
param.second.value.type() == QVariant::Double
#else
param.second.value.typeId() == QMetaType::Double
#endif
? QJsonValue(param.second.value.toDouble())
: QJsonValue(param.second.value.toString()));
int type = data(ix, AssetParameterModel::TypeRole).toInt();
double min = data(ix, AssetParameterModel::MinRole).toDouble();
double max = data(ix, AssetParameterModel::MaxRole).toDouble();
......@@ -1018,7 +1031,14 @@ QJsonDocument AssetParameterModel::valueAsJson(int pos, bool includeFixed) const
auto value = m_keyframes->getInterpolatedValue(pos, ix);
currentParam.insert(QLatin1String("name"), QJsonValue(fixed.first));
currentParam.insert(QLatin1String("value"), QJsonValue(QStringLiteral("0=%1").arg(
value.type() == QVariant::Double ? QString::number(value.toDouble()) : value.toString())));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
value.type() == QVariant::Double
#else
value.typeId() == QMetaType::Double
#endif
? QString::number(value.toDouble())
: value.toString())));
int type = data(ix, AssetParameterModel::TypeRole).toInt();
double min = data(ix, AssetParameterModel::MinRole).toDouble();
double max = data(ix, AssetParameterModel::MaxRole).toDouble();
......@@ -1066,8 +1086,16 @@ QJsonDocument AssetParameterModel::valueAsJson(int pos, bool includeFixed) const
}
currentParam.insert(QLatin1String("name"), QJsonValue(param.first));
currentParam.insert(QLatin1String("value"),
QJsonValue(QStringLiteral("0=%1").arg(value.type() == QVariant::Double ? QString::number(value.toDouble()) : value.toString())));
currentParam.insert(QLatin1String("value"), QJsonValue(QStringLiteral("0=%1").arg(
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
value.type() == QVariant::Double
#else
value.typeId() == QMetaType::Double
#endif
? QString::number(value.toDouble())
: value.toString())));
int type = data(ix, AssetParameterModel::TypeRole).toInt();
double min = data(ix, AssetParameterModel::MinRole).toDouble();
double max = data(ix, AssetParameterModel::MaxRole).toDouble();
......
......@@ -112,10 +112,18 @@ bool ProjectSortProxyModel::lessThan(const QModelIndex &left, const QModelIndex
// Let the normal alphabetical sort happen
const QVariant leftData = sourceModel()->data(left, Qt::DisplayRole);
const QVariant rightData = sourceModel()->data(right, Qt::DisplayRole);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (leftData.type() == QVariant::DateTime) {
#else
if (leftData.typeId() == QMetaType::QDateTime) {
#endif
return leftData.toDateTime() < rightData.toDateTime();
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (leftData.type() == QVariant::Int) {
#else
if (leftData.typeId() == QMetaType::Int) {
#endif
return leftData.toInt() < rightData.toInt();
}
return m_collator.compare(leftData.toString(), rightData.toString()) < 0;
......
......@@ -91,7 +91,7 @@ private:
std::unique_ptr<QAudioRecorder> m_audioRecorder;
#else
// TODO: Qt6
//std::unique_ptr<QMediaCaptureSession> m_mediaCapture;
// std::unique_ptr<QMediaCaptureSession> m_mediaCapture;
#endif
std::unique_ptr<QAudioInput> m_audioInput;
QScopedPointer<AudioDevInfo> m_audioInfo;
......
......@@ -157,7 +157,11 @@ void FilterTask::run()
if (it.first == QLatin1String("in") || it.first == QLatin1String("out")) {
continue;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (it.second.type() == QVariant::Double) {
#else
if (it.second.typeId() == QMetaType::Double) {
#endif
filter.set(it.first.toUtf8().constData(), it.second.toDouble());
} else {
filter.set(it.first.toUtf8().constData(), it.second.toString().toUtf8().constData());
......
......@@ -215,7 +215,11 @@ void SpeedTask::run()
// Process filter params
for (const auto &it : m_filterParams) {
qDebug() << ". . ." << it.first << " = " << it.second;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (it.second.type() == QVariant::Double) {
#else
if (it.second.typeId() == QMetaType::Double) {
#endif
producerArgs << QString("%1=%2").arg(it.first, QString::number(it.second.toDouble()));
} else {
producerArgs << QString("%1=%2").arg(it.first, it.second.toString());
......
......@@ -150,7 +150,11 @@ void StabilizeTask::run()
qDebug() << " = = = = = CONFIGURING FILTER PARAMS = = = = = ";
for (const auto &it : m_filterParams) {
qDebug() << ". . ." << it.first << " = " << it.second;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (it.second.type() == QVariant::Double) {
#else
if (it.second.typeId() == QMetaType::Double) {
#endif
producerArgs << QString("%1=%2").arg(it.first, QString::number(it.second.toDouble()));
} else {
producerArgs << QString("%1=%2").arg(it.first, it.second.toString());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment