diff --git a/MetaDataRegistry.cpp b/MetaDataRegistry.cpp index 4a93131aa..c39551fa1 100644 --- a/MetaDataRegistry.cpp +++ b/MetaDataRegistry.cpp @@ -54,6 +54,7 @@ void register_types () // Frequency list model qRegisterMetaTypeStreamOperators ("Item_v2"); + QMetaType::registerConverter (&FrequencyList_v2::Item::toString); qRegisterMetaTypeStreamOperators ("FrequencyItems_v2"); // defunct old versions @@ -69,6 +70,7 @@ void register_types () // Station details qRegisterMetaType ("Station"); + QMetaType::registerConverter (&StationList::Station::toString); qRegisterMetaType ("Stations"); qRegisterMetaTypeStreamOperators ("Station"); qRegisterMetaTypeStreamOperators ("Stations"); @@ -92,5 +94,6 @@ void register_types () // DecodeHighlightingModel qRegisterMetaTypeStreamOperators ("HighlightInfo"); + QMetaType::registerConverter (&DecodeHighlightingModel::HighlightInfo::toString); qRegisterMetaTypeStreamOperators ("HighlightItems"); } diff --git a/models/DecodeHighlightingModel.cpp b/models/DecodeHighlightingModel.cpp index d6c7a028a..01b039e69 100644 --- a/models/DecodeHighlightingModel.cpp +++ b/models/DecodeHighlightingModel.cpp @@ -5,9 +5,10 @@ #include #include #include - #include +#include #include #include +#include #include #include #include @@ -72,16 +73,23 @@ QDataStream& operator >> (QDataStream& is, DecodeHighlightingModel::HighlightInf >> item.background_; } +QString DecodeHighlightingModel::HighlightInfo::toString () const +{ + QString string; + QTextStream ots {&string}; + ots << "HighlightInfo(" + << highlight_name (type_) << ", " + << enabled_ << ", " + << foreground_.color ().name () << ", " + << background_.color ().name () << ')'; + return string; +} + #if !defined (QT_NO_DEBUG_STREAM) QDebug operator << (QDebug debug, DecodeHighlightingModel::HighlightInfo const& item) { QDebugStateSaver save {debug}; - debug.nospace () << "HighlightInfo(" - << item.type_ << ", " - << item.enabled_ << ", " - << item.foreground_ << ", " - << item.background_ << ')'; - return debug; + return debug.nospace () << item.toString (); } #endif diff --git a/models/DecodeHighlightingModel.hpp b/models/DecodeHighlightingModel.hpp index afb66276e..e173b9f42 100644 --- a/models/DecodeHighlightingModel.hpp +++ b/models/DecodeHighlightingModel.hpp @@ -30,6 +30,7 @@ public: bool enabled_; QBrush foreground_; QBrush background_; + QString toString () const; }; using HighlightItems = QList; diff --git a/models/FrequencyList.cpp b/models/FrequencyList.cpp index 7523b20a3..83d3750b1 100644 --- a/models/FrequencyList.cpp +++ b/models/FrequencyList.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -347,14 +348,21 @@ namespace QDebug operator << (QDebug debug, FrequencyList_v2::Item const& item) { QDebugStateSaver saver {debug}; - debug.nospace () << "FrequencyItem(" - << item.frequency_ << ", " - << item.region_ << ", " - << item.mode_ << ')'; - return debug; + return debug.nospace () << item.toString (); } #endif +QString FrequencyList_v2::Item::toString () const +{ + QString string; + QTextStream qts {&string}; + qts << "FrequencyItem(" + << Radio::frequency_MHz_string (frequency_) << ", " + << IARURegions::name (region_) << ", " + << Modes::name (mode_) << ')'; + return string; +} + QDataStream& operator << (QDataStream& os, FrequencyList_v2::Item const& item) { return os << item.frequency_ diff --git a/models/FrequencyList.hpp b/models/FrequencyList.hpp index aa93352a6..a3b9c117a 100644 --- a/models/FrequencyList.hpp +++ b/models/FrequencyList.hpp @@ -52,6 +52,7 @@ public: Frequency frequency_; Mode mode_; Region region_; + QString toString () const; }; using FrequencyItems = QList; using BandSet = QSet; diff --git a/models/StationList.cpp b/models/StationList.cpp index 202cac0e7..ff8d153f0 100644 --- a/models/StationList.cpp +++ b/models/StationList.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -26,14 +27,21 @@ QDebug operator << (QDebug debug, StationList::Station const& station) { QDebugStateSaver saver {debug}; - debug.nospace () << "Station(" - << station.band_name_ << ", " - << station.offset_ << ", " - << station.antenna_description_ << ')'; - return debug; + return debug.nospace () << station.toString (); } #endif +QString StationList::Station::toString () const +{ + QString string; + QTextStream ots {&string}; + ots << "Station(" + << band_name_ << ", " + << Radio::frequency_MHz_string (offset_) << ", " + << antenna_description_ << ')'; + return string; +} + QDataStream& operator << (QDataStream& os, StationList::Station const& station) { return os << station.band_name_ diff --git a/models/StationList.hpp b/models/StationList.hpp index 3b0955c18..92c149fef 100644 --- a/models/StationList.hpp +++ b/models/StationList.hpp @@ -56,6 +56,7 @@ public: QString band_name_; FrequencyDelta offset_; QString antenna_description_; + QString toString () const; }; using Stations = QList;