mirror of https://github.com/f4exb/sdrangel.git
Created a Serializable interface for where only the serialization methods are needed from an object. Applied to AM demod channel marker
This commit is contained in:
parent
f10d486b28
commit
2b2b0eff8d
|
@ -104,7 +104,7 @@ void AMDemodGUI::channelMarkerChanged()
|
||||||
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
|
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
|
||||||
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
||||||
displayUDPAddress();
|
displayUDPAddress();
|
||||||
m_settings.m_channelMarkerBytes = m_channelMarker.serialize();
|
//m_settings.m_channelMarkerBytes = m_channelMarker.serialize();
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
|
||||||
m_channelMarker.setUDPSendPort(9999);
|
m_channelMarker.setUDPSendPort(9999);
|
||||||
m_channelMarker.setVisible(true);
|
m_channelMarker.setVisible(true);
|
||||||
setTitleColor(m_channelMarker.getColor());
|
setTitleColor(m_channelMarker.getColor());
|
||||||
|
m_settings.setChannelMarker(&m_channelMarker);
|
||||||
|
|
||||||
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
||||||
|
|
||||||
|
@ -281,7 +282,7 @@ void AMDemodGUI::updateChannelMarker()
|
||||||
{
|
{
|
||||||
m_channelMarker.blockSignals(true);
|
m_channelMarker.blockSignals(true);
|
||||||
|
|
||||||
m_channelMarker.deserialize(m_settings.m_channelMarkerBytes);
|
//m_channelMarker.deserialize(m_settings.m_channelMarkerBytes);
|
||||||
this->setWindowTitle(m_channelMarker.getTitle());
|
this->setWindowTitle(m_channelMarker.getTitle());
|
||||||
|
|
||||||
m_channelMarker.blockSignals(false);
|
m_channelMarker.blockSignals(false);
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
|
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
#include "settings/serializable.h"
|
||||||
#include "amdemodsettings.h"
|
#include "amdemodsettings.h"
|
||||||
|
|
||||||
AMDemodSettings::AMDemodSettings()
|
AMDemodSettings::AMDemodSettings() :
|
||||||
|
m_channelMarker(0)
|
||||||
{
|
{
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +47,11 @@ QByteArray AMDemodSettings::serialize() const
|
||||||
s.writeS32(2, m_rfBandwidth/100);
|
s.writeS32(2, m_rfBandwidth/100);
|
||||||
s.writeS32(4, m_volume*10);
|
s.writeS32(4, m_volume*10);
|
||||||
s.writeS32(5, m_squelch);
|
s.writeS32(5, m_squelch);
|
||||||
s.writeBlob(6, m_channelMarkerBytes);
|
|
||||||
|
if (m_channelMarker) {
|
||||||
|
s.writeBlob(6, m_channelMarker->serialize());
|
||||||
|
}
|
||||||
|
|
||||||
s.writeU32(7, m_rgbColor);
|
s.writeU32(7, m_rgbColor);
|
||||||
s.writeBool(8, m_bandpassEnable);
|
s.writeBool(8, m_bandpassEnable);
|
||||||
return s.final();
|
return s.final();
|
||||||
|
@ -74,7 +80,12 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
|
||||||
m_volume = tmp * 0.1;
|
m_volume = tmp * 0.1;
|
||||||
d.readS32(5, &tmp, -40);
|
d.readS32(5, &tmp, -40);
|
||||||
m_squelch = tmp;
|
m_squelch = tmp;
|
||||||
d.readBlob(6, &m_channelMarkerBytes);
|
d.readBlob(6, &bytetmp);
|
||||||
|
|
||||||
|
if (m_channelMarker) {
|
||||||
|
m_channelMarker->deserialize(bytetmp);
|
||||||
|
}
|
||||||
|
|
||||||
d.readU32(7, &m_rgbColor);
|
d.readU32(7, &m_rgbColor);
|
||||||
d.readBool(8, &m_bandpassEnable, false);
|
d.readBool(8, &m_bandpassEnable, false);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
|
class Serializable;
|
||||||
|
|
||||||
struct AMDemodSettings
|
struct AMDemodSettings
|
||||||
{
|
{
|
||||||
int m_inputSampleRate;
|
int m_inputSampleRate;
|
||||||
|
@ -33,10 +35,11 @@ struct AMDemodSettings
|
||||||
QString m_udpAddress;
|
QString m_udpAddress;
|
||||||
quint16 m_udpPort;
|
quint16 m_udpPort;
|
||||||
quint32 m_rgbColor;
|
quint32 m_rgbColor;
|
||||||
QByteArray m_channelMarkerBytes;
|
Serializable *m_channelMarker;
|
||||||
|
|
||||||
AMDemodSettings();
|
AMDemodSettings();
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
|
#include "settings/serializable.h"
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
|
|
||||||
class SDRANGEL_API ChannelMarker : public QObject {
|
class SDRANGEL_API ChannelMarker : public QObject, public Serializable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -76,8 +77,8 @@ public:
|
||||||
const QString& getDisplayAddressSend() const { return m_displayAddressSend; }
|
const QString& getDisplayAddressSend() const { return m_displayAddressSend; }
|
||||||
const QString& getDisplayAddressReceive() const { return m_displayAddressReceive; }
|
const QString& getDisplayAddressReceive() const { return m_displayAddressReceive; }
|
||||||
|
|
||||||
QByteArray serialize() const;
|
virtual QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
virtual bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static QRgb m_colorTable[];
|
static QRgb m_colorTable[];
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SDRBASE_SETTINGS_SERIALIZABLE_H_
|
||||||
|
#define SDRBASE_SETTINGS_SERIALIZABLE_H_
|
||||||
|
|
||||||
|
class Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Serializable() {}
|
||||||
|
virtual QByteArray serialize() const = 0;
|
||||||
|
virtual bool deserialize(const QByteArray& data) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SDRBASE_SETTINGS_SERIALIZABLE_H_ */
|
Loading…
Reference in New Issue