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.
dynamicargsettinggui.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include "dynamicargsettinggui.h"
19 
20 DynamicArgSettingGUI::DynamicArgSettingGUI(ArgInfoGUI *argSettingGUI, const QString& name, QObject *parent) :
21  QObject(parent),
22  m_argSettingGUI(argSettingGUI),
23  m_name(name)
24 {
25  connect(m_argSettingGUI, SIGNAL(valueChanged()), this, SLOT(processValueChanged()));
26 }
27 
29 {
30  disconnect(m_argSettingGUI, SIGNAL(valueChanged()), this, SLOT(processValueChanged()));
31 }
32 
34 {
36  emit valueChanged(m_name, QVariant(m_argSettingGUI->getBoolValue()));
38  emit valueChanged(m_name, QVariant(m_argSettingGUI->getIntValue()));
43  }
44 }
45 
47 {
49  return QVariant(m_argSettingGUI->getBoolValue());
51  return QVariant(m_argSettingGUI->getIntValue());
53  return QVariant(m_argSettingGUI->getFloatValue());
55  return QVariant(m_argSettingGUI->getStringValue());
56  } else {
57  return QVariant(false);
58  }
59 }
60 
61 void DynamicArgSettingGUI::setValue(const QVariant& value)
62 {
63  bool ok = false;
64 
65  if (value.type() == QVariant::Bool)
66  {
67  m_argSettingGUI->setBoolValue(value.toBool());
68  }
69  else if (value.type() == QVariant::Int)
70  {
71  int newValue = value.toInt(&ok);
72 
73  if (ok) {
74  m_argSettingGUI->setIntValue(newValue);
75  }
76  }
77  else if (value.type() == QVariant::Double)
78  {
79  double newValue = value.toDouble(&ok);
80 
81  if (ok) {
82  m_argSettingGUI->setFloatValue(newValue);
83  }
84  }
85  else if (value.type() == QVariant::String)
86  {
87  m_argSettingGUI->setStringValue(value.toString());
88  }
89 }
void valueChanged(QString itemName, QVariant value)
double getFloatValue() const
Definition: arginfogui.h:68
DynamicArgSettingGUI(ArgInfoGUI *argSettingGUI, const QString &name, QObject *parent=0)
ArgInfoValueType getValueType() const
Definition: arginfogui.h:57
bool getBoolValue() const
Definition: arginfogui.h:60
const QString & getStringValue() const
Definition: arginfogui.h:72
void setIntValue(int value)
Definition: arginfogui.cpp:131
int getIntValue() const
Definition: arginfogui.h:64
void setBoolValue(bool value)
Definition: arginfogui.cpp:100
void setFloatValue(double value)
Definition: arginfogui.cpp:162
void setValue(const QVariant &value)
void setStringValue(const QString &value)
Definition: arginfogui.cpp:193