From bb3c22e4a584ee550f394e2e1c13aa505ec71eab Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 1 Apr 2024 00:15:58 +0100 Subject: [PATCH] Add and register SettingValue stream operators --- components/config/gamesettings.cpp | 21 +++++++++++++++++++++ components/config/gamesettings.hpp | 3 +++ 2 files changed, 24 insertions(+) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 21110562d5..a7da8fa150 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -24,6 +24,11 @@ namespace Config::GameSettings::GameSettings(const Files::ConfigurationManager& cfg) : mCfgMgr(cfg) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // this needs calling once so Qt can see its stream operators, which it needs when dragging and dropping + // it's automatic with Qt 6 + qRegisterMetaTypeStreamOperators("Config::SettingValue"); +#endif } void Config::GameSettings::validatePaths() @@ -591,3 +596,19 @@ void Config::GameSettings::clear() mDataDirs.clear(); mDataLocal.clear(); } + +QDataStream& Config::operator<<(QDataStream& out, const SettingValue& settingValue) +{ + out << settingValue.value; + out << settingValue.originalRepresentation; + out << settingValue.context; + return out; +} + +QDataStream& Config::operator>>(QDataStream& in, SettingValue& settingValue) +{ + in >> settingValue.value; + in >> settingValue.originalRepresentation; + in >> settingValue.context; + return in; +} diff --git a/components/config/gamesettings.hpp b/components/config/gamesettings.hpp index d23f225eb0..7627d5153a 100644 --- a/components/config/gamesettings.hpp +++ b/components/config/gamesettings.hpp @@ -132,6 +132,9 @@ namespace Config static bool isOrderedLine(const QString& line); }; + + QDataStream& operator<<(QDataStream& out, const SettingValue& settingValue); + QDataStream& operator>>(QDataStream& in, SettingValue& settingValue); } Q_DECLARE_METATYPE(Config::SettingValue)