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