mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 11:31:51 -05:00
Conversions to QString for user-defined Qt types
This commit is contained in:
parent
4b85d916ec
commit
db9b2d538d
@ -54,6 +54,7 @@ void register_types ()
|
||||
|
||||
// Frequency list model
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList_v2::Item> ("Item_v2");
|
||||
QMetaType::registerConverter<FrequencyList_v2::Item, QString> (&FrequencyList_v2::Item::toString);
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList_v2::FrequencyItems> ("FrequencyItems_v2");
|
||||
|
||||
// defunct old versions
|
||||
@ -69,6 +70,7 @@ void register_types ()
|
||||
|
||||
// Station details
|
||||
qRegisterMetaType<StationList::Station> ("Station");
|
||||
QMetaType::registerConverter<StationList::Station, QString> (&StationList::Station::toString);
|
||||
qRegisterMetaType<StationList::Stations> ("Stations");
|
||||
qRegisterMetaTypeStreamOperators<StationList::Station> ("Station");
|
||||
qRegisterMetaTypeStreamOperators<StationList::Stations> ("Stations");
|
||||
@ -92,5 +94,6 @@ void register_types ()
|
||||
|
||||
// DecodeHighlightingModel
|
||||
qRegisterMetaTypeStreamOperators<DecodeHighlightingModel::HighlightInfo> ("HighlightInfo");
|
||||
QMetaType::registerConverter<DecodeHighlightingModel::HighlightInfo, QString> (&DecodeHighlightingModel::HighlightInfo::toString);
|
||||
qRegisterMetaTypeStreamOperators<DecodeHighlightingModel::HighlightItems> ("HighlightItems");
|
||||
}
|
||||
|
@ -5,9 +5,10 @@
|
||||
#include <QList>
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QFont>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
#include <QTextStream>
|
||||
#include <QDataStream>
|
||||
#include <QMetaType>
|
||||
#include <QDebug>
|
||||
@ -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
|
||||
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
bool enabled_;
|
||||
QBrush foreground_;
|
||||
QBrush background_;
|
||||
QString toString () const;
|
||||
};
|
||||
using HighlightItems = QList<HighlightInfo>;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
#include <QMimeData>
|
||||
#include <QTextSTream>
|
||||
#include <QDataStream>
|
||||
#include <QByteArray>
|
||||
#include <QDebugStateSaver>
|
||||
@ -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_
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
Frequency frequency_;
|
||||
Mode mode_;
|
||||
Region region_;
|
||||
QString toString () const;
|
||||
};
|
||||
using FrequencyItems = QList<Item>;
|
||||
using BandSet = QSet<QString>;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QDataStream>
|
||||
#include <QByteArray>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <QDebugStateSaver>
|
||||
|
||||
@ -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_
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
QString band_name_;
|
||||
FrequencyDelta offset_;
|
||||
QString antenna_description_;
|
||||
QString toString () const;
|
||||
};
|
||||
|
||||
using Stations = QList<Station>;
|
||||
|
Loading…
Reference in New Issue
Block a user