2022-01-21 19:23:32 +00:00
|
|
|
#include "logcategories.h"
|
|
|
|
#include "selectradio.h"
|
|
|
|
#include "ui_selectradio.h"
|
|
|
|
|
|
|
|
|
|
|
|
selectRadio::selectRadio(QWidget* parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::selectRadio)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
selectRadio::~selectRadio()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void selectRadio::populate(QList<radio_cap_packet> radios)
|
|
|
|
{
|
|
|
|
ui->table->clearContents();
|
2022-01-21 23:58:18 +00:00
|
|
|
for (int row = ui->table->rowCount() - 1;row>=0; row--) {
|
|
|
|
ui->table->removeRow(row);
|
|
|
|
}
|
|
|
|
|
2022-01-21 19:23:32 +00:00
|
|
|
for (int row = 0; row < radios.count(); row++) {
|
|
|
|
ui->table->insertRow(ui->table->rowCount());
|
2022-01-21 23:58:18 +00:00
|
|
|
ui->table->setItem(row, 0, new QTableWidgetItem(QString(radios[row].name)));
|
|
|
|
ui->table->setItem(row, 1, new QTableWidgetItem(QString("%1").arg((unsigned char)radios[row].civ, 2, 16, QLatin1Char('0')).toUpper()));
|
|
|
|
ui->table->setItem(row, 2, new QTableWidgetItem(QString::number(qFromBigEndian(radios[row].baudrate))));
|
2022-01-21 19:23:32 +00:00
|
|
|
}
|
2022-01-22 22:53:06 +00:00
|
|
|
if (radios.count() > 1) {
|
|
|
|
this->setVisible(true);
|
|
|
|
}
|
2022-01-21 19:23:32 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 17:54:40 +00:00
|
|
|
void selectRadio::setInUse(quint8 radio, quint8 busy, QString user, QString ip)
|
2022-01-21 19:23:32 +00:00
|
|
|
{
|
2022-05-08 11:19:35 +00:00
|
|
|
//if ((radio > 0)&& !this->isVisible()) {
|
|
|
|
// qInfo() << "setInUse: radio:" << radio <<"busy" << busy << "user" << user << "ip"<<ip;
|
|
|
|
// this->setVisible(true);
|
|
|
|
//}
|
2022-01-21 19:23:32 +00:00
|
|
|
ui->table->setItem(radio, 3, new QTableWidgetItem(user));
|
|
|
|
ui->table->setItem(radio, 4, new QTableWidgetItem(ip));
|
2022-01-23 17:54:40 +00:00
|
|
|
for (int f = 0; f < 5; f++) {
|
2022-05-14 00:11:15 +00:00
|
|
|
if (busy == 1)
|
|
|
|
{
|
2022-01-23 17:54:40 +00:00
|
|
|
ui->table->item(radio, f)->setBackground(Qt::darkGreen);
|
2022-05-14 00:11:15 +00:00
|
|
|
}
|
|
|
|
else if (busy == 2)
|
|
|
|
{
|
2022-01-23 17:54:40 +00:00
|
|
|
ui->table->item(radio, f)->setBackground(Qt::red);
|
2022-05-14 00:11:15 +00:00
|
|
|
}
|
2022-01-23 17:54:40 +00:00
|
|
|
else
|
2022-05-14 00:11:15 +00:00
|
|
|
{
|
2022-01-23 17:54:40 +00:00
|
|
|
ui->table->item(radio, f)->setBackground(Qt::black);
|
2022-05-14 00:11:15 +00:00
|
|
|
}
|
2022-01-23 17:54:40 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 19:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void selectRadio::on_table_cellClicked(int row, int col) {
|
|
|
|
qInfo() << "Clicked on " << row << "," << col;
|
2023-01-01 20:28:59 +00:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5,11,0))
|
2022-05-14 00:11:15 +00:00
|
|
|
if (ui->table->item(row, col)->backgroundColor() != Qt::darkGreen) {
|
2022-08-22 22:09:09 +00:00
|
|
|
#else
|
|
|
|
if (ui->table->item(row, col)->background() != Qt::darkGreen) {
|
|
|
|
#endif
|
2022-05-14 00:11:15 +00:00
|
|
|
ui->table->selectRow(row);
|
|
|
|
emit selectedRadio(row);
|
|
|
|
this->setVisible(false);
|
|
|
|
}
|
2022-01-21 19:23:32 +00:00
|
|
|
}
|
2022-01-21 23:58:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
void selectRadio::on_cancelButton_clicked() {
|
|
|
|
this->setVisible(false);
|
2022-01-21 19:23:32 +00:00
|
|
|
}
|
2022-01-22 15:12:36 +00:00
|
|
|
|
|
|
|
void selectRadio::audioOutputLevel(quint16 level) {
|
|
|
|
ui->afLevel->setValue(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
void selectRadio::audioInputLevel(quint16 level) {
|
|
|
|
ui->modLevel->setValue(level);
|
|
|
|
}
|