Replace use of QVariant::type() with Qt 6
This commit is contained in:
parent
1d555ca17e
commit
f7b36ac4c7
|
@ -37,6 +37,7 @@
|
|||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QMap>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
@ -1730,7 +1731,13 @@ bool CollectionModel::CompareItems(const CollectionItem *a, const CollectionItem
|
|||
QVariant left(data(a, CollectionModel::Role_SortText));
|
||||
QVariant right(data(b, CollectionModel::Role_SortText));
|
||||
|
||||
if (left.type() == QVariant::Int) return left.toInt() < right.toInt();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (left.metaType().id() == QMetaType::Int)
|
||||
#else
|
||||
if (left.type() == QVariant::Int)
|
||||
#endif
|
||||
return left.toInt() < right.toInt();
|
||||
else
|
||||
return left.toString() < right.toString();
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QMetaType>
|
||||
#include <QDateTime>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
@ -133,10 +134,20 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
|||
}
|
||||
else {
|
||||
// Do integers inline - sqlite seems to get confused when you pass integers to bound parameters
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.metaType().id() == QMetaType::Int) {
|
||||
#else
|
||||
if (value.type() == QVariant::Int) {
|
||||
#endif
|
||||
where_clauses_ << QString("%1 %2 %3").arg(column, op, value.toString());
|
||||
}
|
||||
else if (value.type() == QVariant::String && value.toString().isNull()) {
|
||||
else if (
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
value.metaType().id() == QMetaType::QString
|
||||
#else
|
||||
value.type() == QVariant::String
|
||||
#endif
|
||||
&& value.toString().isNull()) {
|
||||
where_clauses_ << QString("%1 %2 ?").arg(column, op);
|
||||
bound_values_ << QString("");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <QMutex>
|
||||
#include <QMimeData>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
|
@ -444,8 +445,13 @@ bool ContextAlbumsModel::CompareItems(const CollectionItem *a, const CollectionI
|
|||
QVariant left(data(a, ContextAlbumsModel::Role_SortText));
|
||||
QVariant right(data(b, ContextAlbumsModel::Role_SortText));
|
||||
|
||||
if (left.type() == QVariant::Int) return left.toInt() < right.toInt();
|
||||
return left.toString() < right.toString();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (left.metaType().id() == QMetaType::Int)
|
||||
#else
|
||||
if (left.type() == QVariant::Int)
|
||||
#endif
|
||||
return left.toInt() < right.toInt();
|
||||
else return left.toString() < right.toString();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,20 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
|
|||
|
||||
// Copied from the QSortFilterProxyModel::lessThan implementation, but returns -1, 0 or 1 instead of true or false.
|
||||
switch (left.userType()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMetaType::UnknownType: return (right.metaType().id() != QMetaType::UnknownType) ? -1 : 0;
|
||||
case QMetaType::Int: return DoCompare(left.toInt(), right.toInt());
|
||||
case QMetaType::UInt: return DoCompare(left.toUInt(), right.toUInt());
|
||||
case QMetaType::LongLong: return DoCompare(left.toLongLong(), right.toLongLong());
|
||||
case QMetaType::ULongLong: return DoCompare(left.toULongLong(), right.toULongLong());
|
||||
case QMetaType::Float: return DoCompare(left.toFloat(), right.toFloat());
|
||||
case QMetaType::Double: return DoCompare(left.toDouble(), right.toDouble());
|
||||
case QMetaType::Char: return DoCompare(left.toChar(), right.toChar());
|
||||
case QMetaType::QDate: return DoCompare(left.toDate(), right.toDate());
|
||||
case QMetaType::QTime: return DoCompare(left.toTime(), right.toTime());
|
||||
case QMetaType::QDateTime: return DoCompare(left.toDateTime(), right.toDateTime());
|
||||
case QMetaType::QString:
|
||||
#else
|
||||
case QVariant::Invalid: return (right.type() != QVariant::Invalid) ? -1 : 0;
|
||||
case QVariant::Int: return DoCompare(left.toInt(), right.toInt());
|
||||
case QVariant::UInt: return DoCompare(left.toUInt(), right.toUInt());
|
||||
|
@ -81,6 +95,7 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
|
|||
case QVariant::Time: return DoCompare(left.toTime(), right.toTime());
|
||||
case QVariant::DateTime: return DoCompare(left.toDateTime(), right.toDateTime());
|
||||
case QVariant::String:
|
||||
#endif
|
||||
default:
|
||||
if (isSortLocaleAware())
|
||||
return left.toString().localeAwareCompare(right.toString());
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QtConcurrent>
|
||||
#include <QMutex>
|
||||
#include <QMetaType>
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
|
@ -242,21 +243,42 @@ bool GstEnginePipeline::InitAudioBin() {
|
|||
}
|
||||
|
||||
if (device_.isValid() && g_object_class_find_property(G_OBJECT_GET_CLASS(audiosink), "device")) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
switch (device_.metaType().id()) {
|
||||
case QMetaType::QString:
|
||||
#else
|
||||
switch (device_.type()) {
|
||||
case QVariant::String:
|
||||
#endif
|
||||
if (device_.toString().isEmpty()) break;
|
||||
g_object_set(G_OBJECT(audiosink), "device", device_.toString().toUtf8().constData(), nullptr);
|
||||
break;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMetaType::QByteArray:
|
||||
#else
|
||||
case QVariant::ByteArray:
|
||||
#endif
|
||||
g_object_set(G_OBJECT(audiosink), "device", device_.toByteArray().constData(), nullptr);
|
||||
break;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMetaType::LongLong:
|
||||
#else
|
||||
case QVariant::LongLong:
|
||||
#endif
|
||||
g_object_set(G_OBJECT(audiosink), "device", device_.toLongLong(), nullptr);
|
||||
break;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMetaType::Int:
|
||||
#else
|
||||
case QVariant::Int:
|
||||
#endif
|
||||
g_object_set(G_OBJECT(audiosink), "device", device_.toInt(), nullptr);
|
||||
break;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMetaType::QUuid:
|
||||
#else
|
||||
case QVariant::Uuid:
|
||||
#endif
|
||||
g_object_set(G_OBJECT(audiosink), "device", device_.toUuid(), nullptr);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <vlc/vlc.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
#include <QByteArray>
|
||||
#include <QUrl>
|
||||
|
@ -130,7 +131,13 @@ bool VLCEngine::Play(const quint64 offset_nanosec) {
|
|||
}
|
||||
|
||||
// Set audio device
|
||||
if (device_.isValid() && device_.type() == QVariant::String && !device_.toString().isEmpty()) {
|
||||
if (device_.isValid() &&
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
device_.metaType().id() == QMetaType::QString
|
||||
#else
|
||||
device_.type() == QVariant::String
|
||||
#endif
|
||||
&& !device_.toString().isEmpty()) {
|
||||
libvlc_audio_output_device_set(player_, nullptr, device_.toString().toLocal8Bit().data());
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,11 @@ QString PlaylistDelegateBase::displayText(const QVariant &value, const QLocale&)
|
|||
|
||||
QString text;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
switch(value.metaType().id()) {
|
||||
#else
|
||||
switch (static_cast<QMetaType::Type>(value.type())) {
|
||||
#endif
|
||||
case QMetaType::Int: {
|
||||
int v = value.toInt();
|
||||
if (v > 0) text = QString::number(v);
|
||||
|
@ -432,7 +436,11 @@ QString NativeSeparatorsDelegate::displayText(const QVariant &value, const QLoca
|
|||
const QString string_value = value.toString();
|
||||
|
||||
QUrl url;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.metaType().id() == QMetaType::QUrl) {
|
||||
#else
|
||||
if (value.type() == QVariant::Url) {
|
||||
#endif
|
||||
url = value.toUrl();
|
||||
}
|
||||
else if (string_value.contains("://")) {
|
||||
|
|
|
@ -116,7 +116,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
|||
enum DatabaseColumn { Column_CollectionId };
|
||||
|
||||
virtual QVariant DatabaseValue(DatabaseColumn) const {
|
||||
return QVariant(QVariant::String);
|
||||
return QVariant(QString());
|
||||
}
|
||||
virtual Song DatabaseSongMetadata() const { return Song(); }
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QFontMetrics>
|
||||
#include <QKeySequence>
|
||||
#include <QMimeData>
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
#include <QTimeLine>
|
||||
|
@ -1328,7 +1329,11 @@ void PlaylistView::CopyCurrentSongToClipboard() const {
|
|||
}
|
||||
|
||||
const QVariant var_data = model()->data(currentIndex().sibling(currentIndex().row(), i));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (var_data.metaType().id() == QMetaType::QString) {
|
||||
#else
|
||||
if (var_data.type() == QVariant::String) {
|
||||
#endif
|
||||
columns << var_data.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QSettings>
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
@ -365,7 +366,13 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
|||
}
|
||||
|
||||
// This allows a custom ALSA device string ie: "hw:0,0" even if it is not listed.
|
||||
if (engine()->CustomDeviceSupport(output) && device.type() == QVariant::String && !device.toString().isEmpty()) {
|
||||
if (engine()->CustomDeviceSupport(output) &&
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
device.metaType().id() == QMetaType::QString
|
||||
#else
|
||||
device.type() == QVariant::String
|
||||
#endif
|
||||
&& !device.toString().isEmpty()) {
|
||||
ui_->lineedit_device->setText(device.toString());
|
||||
if (!found) {
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
|
@ -484,7 +491,12 @@ void BackendSettingsPage::DeviceSelectionChanged(int index) {
|
|||
if (engine()->CustomDeviceSupport(output.name)) {
|
||||
ui_->lineedit_device->setEnabled(true);
|
||||
if (ui_->combobox_device->currentText() != "Custom") {
|
||||
if (device.type() == QVariant::String) ui_->lineedit_device->setText(device.toString());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (device.metaType().id() == QMetaType::QString)
|
||||
#else
|
||||
if (device.type() == QVariant::String)
|
||||
#endif
|
||||
ui_->lineedit_device->setText(device.toString());
|
||||
else ui_->lineedit_device->clear();
|
||||
}
|
||||
}
|
||||
|
@ -519,7 +531,11 @@ void BackendSettingsPage::DeviceStringChanged() {
|
|||
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
QVariant device = ui_->combobox_device->itemData(i).value<QVariant>();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (device.metaType().id() != QMetaType::QString) continue;
|
||||
#else
|
||||
if (device.type() != QVariant::String) continue;
|
||||
#endif
|
||||
if (device.toString().isEmpty()) continue;
|
||||
if (ui_->combobox_device->itemText(i) == "Custom") continue;
|
||||
if (device.toString() == ui_->lineedit_device->text()) {
|
||||
|
@ -599,7 +615,11 @@ void BackendSettingsPage::radiobutton_alsa_hw_clicked(const bool checked) {
|
|||
bool found(false);
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
QVariant device = ui_->combobox_device->itemData(i).value<QVariant>();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (device.metaType().id() != QMetaType::QString) continue;
|
||||
#else
|
||||
if (device.type() != QVariant::String) continue;
|
||||
#endif
|
||||
if (device.toString().isEmpty()) continue;
|
||||
if (device.toString() == device_new) {
|
||||
if (ui_->combobox_device->currentIndex() != i) ui_->combobox_device->setCurrentIndex(i);
|
||||
|
@ -630,7 +650,11 @@ void BackendSettingsPage::radiobutton_alsa_plughw_clicked(const bool checked) {
|
|||
bool found(false);
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
QVariant device = ui_->combobox_device->itemData(i).value<QVariant>();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (device.metaType().id() != QMetaType::QString) continue;
|
||||
#else
|
||||
if (device.type() != QVariant::String) continue;
|
||||
#endif
|
||||
if (device.toString().isEmpty()) continue;
|
||||
if (device.toString() == device_new) {
|
||||
if (ui_->combobox_device->currentIndex() != i) ui_->combobox_device->setCurrentIndex(i);
|
||||
|
|
Loading…
Reference in New Issue