Skip to content

Commit

Permalink
Implemented M17 channel dialog. Addresses hmatuschek#251.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Sep 19, 2022
1 parent 05249f6 commit bbe95ed
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 62 deletions.
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SET(qdmr_SOURCES main.cc
zonelistview.cc scanlistsview.cc positioningsystemlistview.cc roamingzonelistview.cc
collapsablewidget.cc extensionview.cc extensionwrapper.cc propertydelegate.cc errormessageview.cc
deviceselectiondialog.cc radioselectiondialog.cc dmriddialog.cc configobjecttypeselectiondialog.cc
repeaterbookcompleter.cc m17contactdialog.cc)
repeaterbookcompleter.cc m17contactdialog.cc m17channeldialog.cc)
SET(qdmr_MOC_HEADERS
configitemwrapper.hh
application.hh settings.hh dmrcontactdialog.hh dtmfcontactdialog.hh rxgrouplistdialog.hh
Expand All @@ -23,7 +23,7 @@ SET(qdmr_MOC_HEADERS
zonelistview.hh scanlistsview.hh positioningsystemlistview.hh roamingzonelistview.hh
collapsablewidget.hh extensionview.hh extensionwrapper.hh propertydelegate.hh errormessageview.hh
deviceselectiondialog.hh radioselectiondialog.hh dmriddialog.hh configobjecttypeselectiondialog.hh
repeaterbookcompleter.hh m17contactdialog.hh)
repeaterbookcompleter.hh m17contactdialog.hh m17channeldialog.hh)
SET(qdmr_HEADERS )
SET(qdmr_UI_FORMS dmrcontactdialog.ui dtmfcontactdialog.ui rxgrouplistdialog.ui analogchanneldialog.ui zonedialog.ui
digitalchanneldialog.ui scanlistdialog.ui configwizardstart.ui verifydialog.ui settingsdialog.ui
Expand All @@ -33,7 +33,7 @@ SET(qdmr_UI_FORMS dmrcontactdialog.ui dtmfcontactdialog.ui rxgrouplistdialog.ui
zonelistview.ui scanlistsview.ui positioningsystemlistview.ui roamingzonelistview.ui
errormessageview.ui extensionview.ui
deviceselectiondialog.ui radioselectiondialog.ui dmriddialog.ui configobjecttypeselectiondialog.ui
m17contactdialog.ui)
m17contactdialog.ui m17channeldialog.ui)

qt5_wrap_cpp(qdmr_MOC_SOURCES ${qdmr_MOC_HEADERS})
qt5_wrap_ui(qdmr_UI_SOURCES ${qdmr_UI_FORMS})
Expand Down
18 changes: 9 additions & 9 deletions src/analogchanneldialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
/* ********************************************************************************************* *
* Implementation of AnalogChannelDialog
* ********************************************************************************************* */
AnalogChannelDialog::AnalogChannelDialog(Config *config, QWidget *parent)
FMChannelDialog::FMChannelDialog(Config *config, QWidget *parent)
: QDialog(parent), _config(config), _myChannel(new FMChannel(this)), _channel(nullptr)
{
construct();
}

AnalogChannelDialog::AnalogChannelDialog(Config *config, FMChannel *channel, QWidget *parent)
FMChannelDialog::FMChannelDialog(Config *config, FMChannel *channel, QWidget *parent)
: QDialog(parent), _config(config), _myChannel(nullptr), _channel(channel)
{
if (nullptr == _channel)
Expand All @@ -28,7 +28,7 @@ AnalogChannelDialog::AnalogChannelDialog(Config *config, FMChannel *channel, QWi
}

void
AnalogChannelDialog::construct() {
FMChannelDialog::construct() {
setupUi(this);
Settings settings;

Expand Down Expand Up @@ -127,7 +127,7 @@ AnalogChannelDialog::construct() {
}

FMChannel *
AnalogChannelDialog::channel()
FMChannelDialog::channel()
{
_myChannel->setName(channelName->text());
_myChannel->setRXFrequency(rxFrequency->text().toDouble());
Expand Down Expand Up @@ -169,7 +169,7 @@ AnalogChannelDialog::channel()
}

void
AnalogChannelDialog::onRepeaterSelected(const QModelIndex &index) {
FMChannelDialog::onRepeaterSelected(const QModelIndex &index) {
Application *app = qobject_cast<Application *>(qApp);

QModelIndex src = qobject_cast<QAbstractProxyModel*>(
Expand All @@ -189,22 +189,22 @@ AnalogChannelDialog::onRepeaterSelected(const QModelIndex &index) {
}

void
AnalogChannelDialog::onPowerDefaultToggled(bool checked) {
FMChannelDialog::onPowerDefaultToggled(bool checked) {
powerValue->setEnabled(!checked);
}

void
AnalogChannelDialog::onTimeoutDefaultToggled(bool checked) {
FMChannelDialog::onTimeoutDefaultToggled(bool checked) {
totValue->setEnabled(!checked);
}

void
AnalogChannelDialog::onSquelchDefaultToggled(bool checked) {
FMChannelDialog::onSquelchDefaultToggled(bool checked) {
squelchValue->setEnabled(! checked);
}

void
AnalogChannelDialog::onVOXDefaultToggled(bool checked) {
FMChannelDialog::onVOXDefaultToggled(bool checked) {
voxValue->setEnabled(! checked);
}

6 changes: 3 additions & 3 deletions src/analogchanneldialog.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

#include "ui_analogchanneldialog.h"

class AnalogChannelDialog: public QDialog, private Ui::AnalogChannelDialog
class FMChannelDialog: public QDialog, private Ui::AnalogChannelDialog
{
Q_OBJECT

public:
AnalogChannelDialog(Config *config, QWidget *parent=nullptr);
AnalogChannelDialog(Config *config, FMChannel *channel, QWidget *parent=nullptr);
FMChannelDialog(Config *config, QWidget *parent=nullptr);
FMChannelDialog(Config *config, FMChannel *channel, QWidget *parent=nullptr);

FMChannel *channel();

Expand Down
37 changes: 28 additions & 9 deletions src/channellistview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "analogchanneldialog.hh"
#include "digitalchanneldialog.hh"
#include "m17channeldialog.hh"
#include "config.hh"
#include "settings.hh"

Expand Down Expand Up @@ -42,7 +43,7 @@ ChannelListView::~ChannelListView() {

void
ChannelListView::onAddFMChannel() {
AnalogChannelDialog dialog(_config);
FMChannelDialog dialog(_config);
if (QDialog::Accepted != dialog.exec())
return;

Expand All @@ -54,7 +55,7 @@ ChannelListView::onAddFMChannel() {

void
ChannelListView::onAddDMRChannel() {
DigitalChannelDialog dialog(_config);
DMRChannelDialog dialog(_config);
if (QDialog::Accepted != dialog.exec())
return;

Expand All @@ -66,7 +67,7 @@ ChannelListView::onAddDMRChannel() {

void
ChannelListView::onAddM17Channel() {
DigitalChannelDialog dialog(_config);
M17ChannelDialog dialog(_config);
if (QDialog::Accepted != dialog.exec())
return;

Expand Down Expand Up @@ -97,7 +98,7 @@ ChannelListView::onCloneChannel() {
// clone channel
FMChannel *clone = new FMChannel(*(channel->as<FMChannel>()));
// open editor
AnalogChannelDialog dialog(_config, clone);
FMChannelDialog dialog(_config, clone);
if (QDialog::Accepted != dialog.exec()) {
// if rejected -> destroy clone
clone->deleteLater();
Expand All @@ -107,11 +108,24 @@ ChannelListView::onCloneChannel() {
dialog.channel();
// add to list (below selected one)
_config->channelList()->add(clone, row+1);
} else {
} else if (channel->is<DMRChannel>()) {
// clone channel
DMRChannel *clone = new DMRChannel(*(channel->as<DMRChannel>()));
// open editor
DigitalChannelDialog dialog(_config, clone);
DMRChannelDialog dialog(_config, clone);
if (QDialog::Accepted != dialog.exec()) {
clone->deleteLater();
return;
}
// update channel
dialog.channel();
// add to list (below selected one)
_config->channelList()->add(clone, row+1);
} else if (channel->is<M17Channel>()) {
// clone channel
M17Channel *clone = new M17Channel(*(channel->as<M17Channel>()));
// open editor
M17ChannelDialog dialog(_config, clone);
if (QDialog::Accepted != dialog.exec()) {
clone->deleteLater();
return;
Expand Down Expand Up @@ -162,12 +176,17 @@ ChannelListView::onEditChannel(unsigned row) {
if (! channel)
return;
if (channel->is<FMChannel>()) {
AnalogChannelDialog dialog(_config, channel->as<FMChannel>());
FMChannelDialog dialog(_config, channel->as<FMChannel>());
if (QDialog::Accepted != dialog.exec())
return;
dialog.channel();
} else {
DigitalChannelDialog dialog(_config, channel->as<DMRChannel>());
} else if (channel->is<DMRChannel>()) {
DMRChannelDialog dialog(_config, channel->as<DMRChannel>());
if (QDialog::Accepted != dialog.exec())
return;
dialog.channel();
} else if (channel->is<M17Channel>()) {
M17ChannelDialog dialog(_config, channel->as<M17Channel>());
if (QDialog::Accepted != dialog.exec())
return;
dialog.channel();
Expand Down
77 changes: 50 additions & 27 deletions src/configitemwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
switch (index.column()) {
case 0:
if (channel->is<FMChannel>())
return tr("Analog");
return tr("FM");
else if (channel->is<DMRChannel>())
return tr("DMR");
else if (channel->is<M17Channel>())
return tr("M17");
else
return tr("Digital");
return QVariant();
case 1:
return channel->name();
case 2:
Expand Down Expand Up @@ -287,44 +291,54 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
case 6:
return channel->rxOnly() ? tr("On") : tr("Off");
case 7:
if (DMRChannel *digi = channel->as<DMRChannel>()) {
switch (digi->admit()) {
if (DMRChannel *dmr = channel->as<DMRChannel>()) {
switch (dmr->admit()) {
case DMRChannel::Admit::Always: return tr("Always"); break;
case DMRChannel::Admit::Free: return tr("Free"); break;
case DMRChannel::Admit::ColorCode: return tr("Color"); break;
}
} else if (FMChannel *analog = channel->as<FMChannel>()) {
switch (analog->admit()) {
} else if (FMChannel *fm = channel->as<FMChannel>()) {
switch (fm->admit()) {
case FMChannel::Admit::Always: return tr("Always"); break;
case FMChannel::Admit::Free: return tr("Free"); break;
case FMChannel::Admit::Tone: return tr("Tone"); break;
}
} else if (channel->is<M17Channel>()) {
return tr("[None]");
}
break;
case 8:
if (channel->scanList()) {
return channel->scanList()->name();
} else {
return tr("-");
return tr("[None]");
}
case 9:
if (DMRChannel *digi = channel->as<DMRChannel>()) {
return digi->colorCode();
if (DMRChannel *dmr = channel->as<DMRChannel>()) {
return dmr->colorCode();
} else if (M17Channel *m17 = channel->as<M17Channel>()) {
return m17->accessNumber();
} else if (channel->is<FMChannel>()) {
return tr("[None]");
}
break;
case 10:
if (DMRChannel *digi = channel->as<DMRChannel>()) {
return (DMRChannel::TimeSlot::TS1 == digi->timeSlot()) ? 1 : 2;
} else if (channel->is<FMChannel>()) {
if (DMRChannel *dmr = channel->as<DMRChannel>()) {
return (DMRChannel::TimeSlot::TS1 == dmr->timeSlot()) ? 1 : 2;
} else if (channel->is<FMChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
}
break;
case 11:
if (DMRChannel *digi = channel->as<DMRChannel>()) {
if (digi->groupListObj()) {
return digi->groupListObj()->name();
if (DMRChannel *dmr = channel->as<DMRChannel>()) {
if (dmr->groupListObj()) {
return dmr->groupListObj()->name();
} else {
return tr("-");
}
} else if (M17Channel *m17 = channel->as<M17Channel>()) {
if (m17->groupList()) {
return m17->groupList()->name();
} else {
return tr("-");
}
Expand All @@ -338,6 +352,11 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
return digi->txContactObj()->name();
else
return tr("-");
} else if (M17Channel *m17 = channel->as<M17Channel>()) {
if (m17->contact())
return m17->contact()->name();
else
return tr("-");
} else if (channel->is<FMChannel>()) {
return tr("[None]");
}
Expand All @@ -347,19 +366,23 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
if ((nullptr == digi->radioIdObj()) || (DefaultRadioID::get() == digi->radioIdObj()))
return tr("[Default]");
return digi->radioIdObj()->name();
} else if (channel->is<FMChannel>()) {
} else if (channel->is<FMChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
}
break;
case 14:
if (DMRChannel *digi = channel->as<DMRChannel>()) {
if (digi->aprsObj())
return digi->aprsObj()->name();
if (DMRChannel *dmr = channel->as<DMRChannel>()) {
if (dmr->aprsObj())
return dmr->aprsObj()->name();
else
return tr("-");
} else if (FMChannel *analog = channel->as<FMChannel>()) {
if (analog->aprsSystem())
return analog->aprsSystem()->name();
} else if (M17Channel *m17 = channel->as<M17Channel>()) {
if (m17->gpsEnabled())
return tr("Enabled");
return tr("Disabled");
} else if (FMChannel *fm = channel->as<FMChannel>()) {
if (fm->aprsSystem())
return fm->aprsSystem()->name();
else
return tr("-");
}
Expand All @@ -371,12 +394,12 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
else if (DefaultRoamingZone::get() == digi->roamingZone())
return tr("[Default]");
return digi->roamingZone()->name();
} else if (channel->is<FMChannel>()) {
} else if (channel->is<FMChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
}
break;
case 16:
if (channel->is<DMRChannel>()) {
if (channel->is<DMRChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
} else if (FMChannel *analog = channel->as<FMChannel>()) {
if (analog->defaultSquelch())
Expand All @@ -388,7 +411,7 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
}
break;
case 17:
if (channel->is<DMRChannel>()) {
if (channel->is<DMRChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
} else if (FMChannel *analog = channel->as<FMChannel>()) {
if (Signaling::SIGNALING_NONE == analog->rxTone()) {
Expand All @@ -398,7 +421,7 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
}
break;
case 18:
if (channel->is<DMRChannel>()) {
if (channel->is<DMRChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
} else if (FMChannel *analog = channel->as<FMChannel>()) {
if (Signaling::SIGNALING_NONE == analog->txTone()) {
Expand All @@ -408,7 +431,7 @@ ChannelListWrapper::data(const QModelIndex &index, int role) const {
}
break;
case 19:
if (channel->is<DMRChannel>()) {
if (channel->is<DMRChannel>() || channel->is<M17Channel>()) {
return tr("[None]");
} else if (FMChannel *analog = channel->as<FMChannel>()) {
if (FMChannel::Bandwidth::Wide == analog->bandwidth()) {
Expand Down
Loading

0 comments on commit bbe95ed

Please sign in to comment.