SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
preferences.cpp
Go to the documentation of this file.
1 #include "settings/preferences.h"
3 
5 {
7 }
8 
10 {
11  m_sourceDevice.clear();
12  m_audioType.clear();
13  m_audioDevice.clear();
14  m_sourceIndex = 0;
15  m_latitude = 0.0;
16  m_longitude = 0.0;
17  m_useLogFile = false;
18  m_logFileName = "sdrangel.log";
19  m_consoleMinLogLevel = QtDebugMsg;
20  m_fileMinLogLevel = QtDebugMsg;
21 }
22 
23 QByteArray Preferences::serialize() const
24 {
25  SimpleSerializer s(1);
29  s.writeS32(5, m_sourceIndex);
30  s.writeFloat(6, m_latitude);
31  s.writeFloat(7, m_longitude);
32  s.writeS32(8, (int) m_consoleMinLogLevel);
33  s.writeBool(9, m_useLogFile);
35  s.writeS32(11, (int) m_fileMinLogLevel);
36  return s.final();
37 }
38 
39 bool Preferences::deserialize(const QByteArray& data)
40 {
41  int tmpInt;
42 
43  SimpleDeserializer d(data);
44 
45  if(!d.isValid()) {
47  return false;
48  }
49 
50  if(d.getVersion() == 1)
51  {
53  d.readString(3, &m_audioType);
55  d.readS32(5, &m_sourceIndex, 0);
56  d.readFloat(6, &m_latitude, 0.0);
57  d.readFloat(7, &m_longitude, 0.0);
58 
59  d.readS32(8, &tmpInt, (int) QtDebugMsg);
60 
61  if ((tmpInt == (int) QtDebugMsg) ||
62  (tmpInt == (int) QtInfoMsg) ||
63  (tmpInt == (int) QtWarningMsg) ||
64  (tmpInt == (int) QtCriticalMsg) ||
65  (tmpInt == (int) QtFatalMsg)) {
66  m_consoleMinLogLevel = (QtMsgType) tmpInt;
67  } else {
68  m_consoleMinLogLevel = QtDebugMsg;
69  }
70 
71  d.readBool(9, &m_useLogFile, false);
72  d.readString(10, &m_logFileName, "sdrangel.log");
73 
74  d.readS32(11, &tmpInt, (int) QtDebugMsg);
75 
76  if ((tmpInt == (int) QtDebugMsg) ||
77  (tmpInt == (int) QtInfoMsg) ||
78  (tmpInt == (int) QtWarningMsg) ||
79  (tmpInt == (int) QtCriticalMsg) ||
80  (tmpInt == (int) QtFatalMsg)) {
81  m_fileMinLogLevel = (QtMsgType) tmpInt;
82  } else {
83  m_fileMinLogLevel = QtDebugMsg;
84  }
85 
86  return true;
87  } else
88  {
90  return false;
91  }
92 }
void resetToDefaults()
Definition: preferences.cpp:9
bool readFloat(quint32 id, float *result, float def=0) const
float m_longitude
Definition: preferences.h:50
QtMsgType m_consoleMinLogLevel
Definition: preferences.h:52
void writeFloat(quint32 id, float value)
bool m_useLogFile
Definition: preferences.h:54
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
int m_sourceIndex
Index of the source used in R0 tab (GUI flavor) at startup.
Definition: preferences.h:44
bool isValid() const
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
QString m_audioType
Definition: preferences.h:46
void writeS32(quint32 id, qint32 value)
QString m_sourceDevice
Identification of the source used in R0 tab (GUI flavor) at startup.
Definition: preferences.h:43
quint32 getVersion() const
bool deserialize(const QByteArray &data)
Definition: preferences.cpp:39
float m_latitude
Definition: preferences.h:49
QByteArray serialize() const
Definition: preferences.cpp:23
QString m_audioDevice
Definition: preferences.h:47
void writeBool(quint32 id, bool value)
QtMsgType m_fileMinLogLevel
Definition: preferences.h:53
QString m_logFileName
Definition: preferences.h:55
void writeString(quint32 id, const QString &value)
const QByteArray & final()