File: dockrds.cpp

package info (click to toggle)
gqrx-sdr 2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,700 kB
  • ctags: 2,724
  • sloc: cpp: 22,413; ansic: 564; xml: 25; makefile: 4
file content (128 lines) | stat: -rw-r--r-- 3,319 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* -*- c++ -*- */
/*
 * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
 *           http://gqrx.dk/
 *
 * Copyright 2011-2013 Alexandru Csete OZ9AEC.
 *
 * Gqrx 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; either version 3, or (at your option)
 * any later version.
 *
 * Gqrx 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 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gqrx; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */
#include <QDebug>
#include <QVariant>
#include "dockrds.h"
#include "ui_dockrds.h"

DockRDS::DockRDS(QWidget *parent) :
    QDockWidget(parent),
    ui(new Ui::DockRDS)
{
    ui->setupUi(this);

#if QT_VERSION >= 0x050200
    ui->scrollArea->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
#endif
}

DockRDS::~DockRDS()
{
    delete ui;
}

void DockRDS::updateRDS(QString text, int type)
{
    std::string     str, out;

    /* type 0 = PI
     * type 1 = PS
     * type 2 = PTY
     * type 3 = flagstring: TP, TA, MuSp, MoSt, AH, CMP, stPTY
     * type 4 = RadioText
     * type 5 = ClockTime
     * type 6 = Alternative Frequencies
     */
    switch (type)
    {
    case 0:
        ui->program_information->setText(text);
        break;
    case 1:
        ui->station_name->setText(text);
        break;
    case 2:
        ui->program_type->setText(text);
        break;
    case 3:
        str = text.toStdString();
        out = "";
        if (str.at(0) == '1') out.append("TP ");
        if (str.at(1) == '1') out.append("TA ");
        if (str.at(2) == '0') out.append("Speech ");
        if (str.at(2) == '1') out.append("Music ");
        if (str.at(3) == '0') out.append("Stereo ");
        if (str.at(3) == '1') out.append("Mono ");
        if (str.at(4) == '1') out.append("AH ");
        if (str.at(5) == '1') out.append("CMP ");
        if (str.at(6) == '1') out.append("stPTY ");
        ui->flags->setText(QString::fromStdString(out));
        break;
    case 4:
        ui->radiotext->setText(text);
        break;
    case 5:
        ui->clocktime->setText(text);
        break;
    case 6:
        ui->alt_freq->setText(text);
        break;
    default:
        // nothing to do
        break;
    }
}

void DockRDS::showEnabled()
{
}

void DockRDS::showDisabled()
{
    ui->program_information->setText("");
    ui->station_name->setText("");
    ui->program_type->setText("");
    ui->flags->setText("");
    ui->radiotext->setText("");
    ui->clocktime->setText("");
    ui->alt_freq->setText("");
}

void DockRDS::setDisabled()
{
    ui->rdsCheckbox->setDisabled(true);
    ui->rdsCheckbox->blockSignals(true);
    ui->rdsCheckbox->setChecked(false);
    ui->rdsCheckbox->blockSignals(false);
}

void DockRDS::setEnabled()
{
    ui->rdsCheckbox->setDisabled(false);
}

/** Enable/disable RDS decoder */
void DockRDS::on_rdsCheckbox_toggled(bool checked)
{
    emit rdsDecoderToggled(checked);
}