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.
discreterangegui.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 "ui_discreterangegui.h"
19 #include "discreterangegui.h"
20 
22  ItemSettingGUI(parent),
23  ui(new Ui::DiscreteRangeGUI)
24 {
25  ui->setupUi(this);
26 }
27 
29 {
30  delete ui;
31 }
32 
33 void DiscreteRangeGUI::setLabel(const QString& text)
34 {
35  ui->rangeLabel->setText(text);
36 }
37 
38 void DiscreteRangeGUI::setUnits(const QString& units)
39 {
40  ui->rangeUnits->setText(units);
41 }
42 
43 void DiscreteRangeGUI::addItem(const QString& itemStr, double itemValue)
44 {
45  ui->rangeCombo->blockSignals(true);
46  ui->rangeCombo->addItem(itemStr);
47  itemValues.push_back(itemValue);
48  ui->rangeCombo->blockSignals(false);
49 }
50 
52 {
53  return itemValues[ui->rangeCombo->currentIndex()];
54 }
55 
56 void DiscreteRangeGUI::setValue(double value)
57 {
58  int index = 0;
59 
60  for (const auto &it : itemValues)
61  {
62  if (it >= value)
63  {
64  ui->rangeCombo->blockSignals(true);
65  ui->rangeCombo->setCurrentIndex(index);
66  ui->rangeCombo->blockSignals(false);
67  break;
68  }
69 
70  index++;
71  }
72 }
73 
75 {
76  double newRange = itemValues[index];
77  emit ItemSettingGUI::valueChanged(newRange);
78 }
void setLabel(const QString &text)
virtual double getCurrentValue()
void valueChanged(double value)
virtual void setValue(double value)
void addItem(const QString &itemStr, double itemValue)
void setUnits(const QString &units)
DiscreteRangeGUI(QWidget *parent=0)
Ui::DiscreteRangeGUI * ui
virtual ~DiscreteRangeGUI()
std::vector< double > itemValues
void on_rangeCombo_currentIndexChanged(int index)