summaryrefslogtreecommitdiff
path: root/UDPExamples
diff options
context:
space:
mode:
Diffstat (limited to 'UDPExamples')
-rw-r--r--UDPExamples/ClientWidget.cpp33
-rw-r--r--UDPExamples/ClientWidget.hpp11
-rw-r--r--UDPExamples/MessageAggregatorMainWindow.cpp131
-rw-r--r--UDPExamples/MessageAggregatorMainWindow.hpp21
-rw-r--r--UDPExamples/UDPDaemon.cpp34
5 files changed, 215 insertions, 15 deletions
diff --git a/UDPExamples/ClientWidget.cpp b/UDPExamples/ClientWidget.cpp
index de77286b..06b09ba4 100644
--- a/UDPExamples/ClientWidget.cpp
+++ b/UDPExamples/ClientWidget.cpp
@@ -3,6 +3,8 @@
#include <QRegExp>
#include <QColor>
+#include "MaidenheadLocatorValidator.hpp"
+
namespace
{
//QRegExp message_alphabet {"[- A-Za-z0-9+./?]*"};
@@ -113,16 +115,19 @@ namespace
ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemModel * beacons_model
, QString const& id, QString const& version, QString const& revision
- , QWidget * parent)
+ , QListWidget const * calls_of_interest, QWidget * parent)
: QDockWidget {make_title (id, version, revision), parent}
, id_ {id}
+ , calls_of_interest_ {calls_of_interest}
, decodes_proxy_model_ {id_}
, decodes_table_view_ {new QTableView}
, beacons_table_view_ {new QTableView}
, message_line_edit_ {new QLineEdit}
+ , grid_line_edit_ {new QLineEdit}
, decodes_stack_ {new QStackedLayout}
, auto_off_button_ {new QPushButton {tr ("&Auto Off")}}
, halt_tx_button_ {new QPushButton {tr ("&Halt Tx")}}
+ , de_label_ {new QLabel}
, mode_label_ {new QLabel}
, fast_mode_ {false}
, frequency_label_ {new QLabel}
@@ -141,13 +146,18 @@ ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemMod
auto form_layout = new QFormLayout;
form_layout->addRow (tr ("Free text:"), message_line_edit_);
+ form_layout->addRow (tr ("Temporary grid:"), grid_line_edit_);
message_line_edit_->setValidator (new QRegExpValidator {message_alphabet, this});
+ grid_line_edit_->setValidator (new MaidenheadLocatorValidator {this});
connect (message_line_edit_, &QLineEdit::textEdited, [this] (QString const& text) {
Q_EMIT do_free_text (id_, text, false);
});
connect (message_line_edit_, &QLineEdit::editingFinished, [this] () {
Q_EMIT do_free_text (id_, message_line_edit_->text (), true);
});
+ connect (grid_line_edit_, &QLineEdit::editingFinished, [this] () {
+ Q_EMIT location (id_, grid_line_edit_->text ());
+ });
auto decodes_page = new QWidget;
auto decodes_layout = new QVBoxLayout {decodes_page};
@@ -189,6 +199,7 @@ ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemMod
// set up status area
auto status_bar = new QStatusBar;
+ status_bar->addPermanentWidget (de_label_);
status_bar->addPermanentWidget (mode_label_);
status_bar->addPermanentWidget (frequency_label_);
status_bar->addPermanentWidget (dx_label_);
@@ -206,17 +217,33 @@ ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemMod
// setMinimumSize (QSize {550, 0});
setFeatures (DockWidgetMovable | DockWidgetFloatable);
setAllowedAreas (Qt::BottomDockWidgetArea);
+ setFloating (true);
// connect up table view signals
connect (decodes_table_view_, &QTableView::doubleClicked, this, [this] (QModelIndex const& index) {
Q_EMIT do_reply (decodes_proxy_model_.mapToSource (index), QApplication::keyboardModifiers () >> 24);
});
+
+ // tell new client about calls of interest
+ for (int row = 0; row < calls_of_interest_->count (); ++row)
+ {
+ Q_EMIT highlight_callsign (id_, calls_of_interest_->item (row)->text (), QColor {Qt::blue}, QColor {Qt::yellow});
+ }
+}
+
+ClientWidget::~ClientWidget ()
+{
+ for (int row = 0; row < calls_of_interest_->count (); ++row)
+ {
+ // tell client to forget calls of interest
+ Q_EMIT highlight_callsign (id_, calls_of_interest_->item (row)->text ());
+ }
}
void ClientWidget::update_status (QString const& id, Frequency f, QString const& mode, QString const& dx_call
, QString const& report, QString const& tx_mode, bool tx_enabled
, bool transmitting, bool decoding, qint32 rx_df, qint32 tx_df
- , QString const& de_call, QString const& /*de_grid*/, QString const& dx_grid
+ , QString const& de_call, QString const& de_grid, QString const& dx_grid
, bool watchdog_timeout, QString const& sub_mode, bool fast_mode)
{
if (id == id_)
@@ -224,6 +251,8 @@ void ClientWidget::update_status (QString const& id, Frequency f, QString const&
fast_mode_ = fast_mode;
decodes_proxy_model_.de_call (de_call);
decodes_proxy_model_.rx_df (rx_df);
+ de_label_->setText (de_call.size () >= 0 ? QString {"DE: %1%2"}.arg (de_call)
+ .arg (de_grid.size () ? '(' + de_grid + ')' : QString {}) : QString {});
mode_label_->setText (QString {"Mode: %1%2%3%4"}
.arg (mode)
.arg (sub_mode)
diff --git a/UDPExamples/ClientWidget.hpp b/UDPExamples/ClientWidget.hpp
index 1f5ae601..29059bfa 100644
--- a/UDPExamples/ClientWidget.hpp
+++ b/UDPExamples/ClientWidget.hpp
@@ -11,6 +11,7 @@
class QAbstractItemModel;
class QModelIndex;
+class QColor;
using Frequency = MessageServer::Frequency;
@@ -22,7 +23,8 @@ class ClientWidget
public:
explicit ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemModel * beacons_model
, QString const& id, QString const& version, QString const& revision
- , QWidget * parent = nullptr);
+ , QListWidget const * calls_of_interest, QWidget * parent = nullptr);
+ ~ClientWidget ();
bool fast_mode () const {return fast_mode_;}
@@ -43,9 +45,14 @@ public:
Q_SIGNAL void do_reply (QModelIndex const&, quint8 modifier);
Q_SIGNAL void do_halt_tx (QString const& id, bool auto_only);
Q_SIGNAL void do_free_text (QString const& id, QString const& text, bool);
+ Q_SIGNAL void location (QString const& id, QString const& text);
+ Q_SIGNAL void highlight_callsign (QString const& id, QString const& call
+ , QColor const& bg = QColor {}, QColor const& fg = QColor {}
+ , bool last_only = false);
private:
QString id_;
+ QListWidget const * calls_of_interest_;
class IdFilterModel final
: public QSortFilterProxyModel
{
@@ -69,9 +76,11 @@ private:
QTableView * decodes_table_view_;
QTableView * beacons_table_view_;
QLineEdit * message_line_edit_;
+ QLineEdit * grid_line_edit_;
QStackedLayout * decodes_stack_;
QAbstractButton * auto_off_button_;
QAbstractButton * halt_tx_button_;
+ QLabel * de_label_;
QLabel * mode_label_;
bool fast_mode_;
QLabel * frequency_label_;
diff --git a/UDPExamples/MessageAggregatorMainWindow.cpp b/UDPExamples/MessageAggregatorMainWindow.cpp
index 196282d6..1d1dce5d 100644
--- a/UDPExamples/MessageAggregatorMainWindow.cpp
+++ b/UDPExamples/MessageAggregatorMainWindow.cpp
@@ -22,17 +22,25 @@ namespace
QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "Sent"),
QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "Rec'd"),
QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "Power"),
+ QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "Operator"),
+ QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "My Call"),
+ QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "My Grid"),
QT_TRANSLATE_NOOP ("MessageAggregatorMainWindow", "Comments"),
};
}
MessageAggregatorMainWindow::MessageAggregatorMainWindow ()
- : log_ {new QStandardItemModel {0, 11, this}}
+ : log_ {new QStandardItemModel {0, 14, this}}
, decodes_model_ {new DecodesModel {this}}
, beacons_model_ {new BeaconsModel {this}}
, server_ {new MessageServer {this}}
, multicast_group_line_edit_ {new QLineEdit}
, log_table_view_ {new QTableView}
+ , add_call_of_interest_action_ {new QAction {tr ("&Add callsign"), this}}
+ , delete_call_of_interest_action_ {new QAction {tr ("&Delete callsign"), this}}
+ , last_call_of_interest_action_ {new QAction {tr ("&Highlight last only"), this}}
+ , call_of_interest_bg_colour_action_ {new QAction {tr ("&Background colour"), this}}
+ , call_of_interest_fg_colour_action_ {new QAction {tr ("&Foreground colour"), this}}
{
// logbook
int column {0};
@@ -80,6 +88,91 @@ MessageAggregatorMainWindow::MessageAggregatorMainWindow ()
setDockOptions (AnimatedDocks | AllowNestedDocks | AllowTabbedDocks);
setTabPosition (Qt::BottomDockWidgetArea, QTabWidget::North);
+ QDockWidget * calls_dock {new QDockWidget {tr ("Calls of Interest"), this}};
+ calls_dock->setAllowedAreas (Qt::RightDockWidgetArea);
+ calls_of_interest_ = new QListWidget {calls_dock};
+ calls_of_interest_->setContextMenuPolicy (Qt::ActionsContextMenu);
+ calls_of_interest_->insertAction (nullptr, add_call_of_interest_action_);
+ connect (add_call_of_interest_action_, &QAction::triggered, [this] () {
+ auto item = new QListWidgetItem {};
+ item->setFlags (item->flags () | Qt::ItemIsEditable);
+ item->setData (Qt::UserRole, QString {});
+ calls_of_interest_->addItem (item);
+ calls_of_interest_->editItem (item);
+ });
+ calls_of_interest_->insertAction (nullptr, delete_call_of_interest_action_);
+ connect (delete_call_of_interest_action_, &QAction::triggered, [this] () {
+ for (auto item : calls_of_interest_->selectedItems ())
+ {
+ auto old_call = item->data (Qt::UserRole);
+ if (old_call.isValid ()) change_highlighting (old_call.toString ());
+ delete item;
+ }
+ });
+ calls_of_interest_->insertAction (nullptr, last_call_of_interest_action_);
+ connect (last_call_of_interest_action_, &QAction::triggered, [this] () {
+ for (auto item : calls_of_interest_->selectedItems ())
+ {
+ auto old_call = item->data (Qt::UserRole);
+ change_highlighting (old_call.toString ());
+ change_highlighting (old_call.toString ()
+ , item->background ().color (), item->foreground ().color (), true);
+ delete item;
+ }
+ });
+ calls_of_interest_->insertAction (nullptr, call_of_interest_bg_colour_action_);
+ connect (call_of_interest_bg_colour_action_, &QAction::triggered, [this] () {
+ for (auto item : calls_of_interest_->selectedItems ())
+ {
+ auto old_call = item->data (Qt::UserRole);
+ auto new_colour = QColorDialog::getColor (item->background ().color ()
+ , this, tr ("Select background color"));
+ if (new_colour.isValid ())
+ {
+ change_highlighting (old_call.toString (), new_colour, item->foreground ().color ());
+ item->setBackground (new_colour);
+ }
+ }
+ });
+ calls_of_interest_->insertAction (nullptr, call_of_interest_fg_colour_action_);
+ connect (call_of_interest_fg_colour_action_, &QAction::triggered, [this] () {
+ for (auto item : calls_of_interest_->selectedItems ())
+ {
+ auto old_call = item->data (Qt::UserRole);
+ auto new_colour = QColorDialog::getColor (item->foreground ().color ()
+ , this, tr ("Select foreground color"));
+ if (new_colour.isValid ())
+ {
+ change_highlighting (old_call.toString (), item->background ().color (), new_colour);
+ item->setForeground (new_colour);
+ }
+ }
+ });
+ connect (calls_of_interest_, &QListWidget::itemChanged, [this] (QListWidgetItem * item) {
+ auto old_call = item->data (Qt::UserRole);
+ auto new_call = item->text ().toUpper ();
+ if (new_call != old_call)
+ {
+ // tell all clients
+ if (old_call.isValid ())
+ {
+ change_highlighting (old_call.toString ());
+ }
+ item->setData (Qt::UserRole, new_call);
+ item->setText (new_call);
+ auto bg = item->listWidget ()->palette ().text ().color ();
+ auto fg = item->listWidget ()->palette ().base ().color ();
+ item->setBackground (bg);
+ item->setForeground (fg);
+ change_highlighting (new_call, bg, fg);
+ }
+ });
+
+ calls_dock->setWidget (calls_of_interest_);
+ addDockWidget (Qt::RightDockWidgetArea, calls_dock);
+ view_menu_->addAction (calls_dock->toggleViewAction ());
+ view_menu_->addSeparator ();
+
// connect up server
connect (server_, &MessageServer::error, [this] (QString const& message) {
QMessageBox::warning (this, QApplication::applicationName (), tr ("Network Error"), message);
@@ -111,10 +204,12 @@ MessageAggregatorMainWindow::MessageAggregatorMainWindow ()
show ();
}
-void MessageAggregatorMainWindow::log_qso (QString const& /*id*/, QDateTime time_off, QString const& dx_call, QString const& dx_grid
- , Frequency dial_frequency, QString const& mode, QString const& report_sent
- , QString const& report_received, QString const& tx_power, QString const& comments
- , QString const& name, QDateTime time_on)
+void MessageAggregatorMainWindow::log_qso (QString const& /*id*/, QDateTime time_off, QString const& dx_call
+ , QString const& dx_grid, Frequency dial_frequency, QString const& mode
+ , QString const& report_sent, QString const& report_received
+ , QString const& tx_power, QString const& comments
+ , QString const& name, QDateTime time_on, QString const& operator_call
+ , QString const& my_call, QString const& my_grid)
{
QList<QStandardItem *> row;
row << new QStandardItem {time_on.toString ("dd-MMM-yyyy hh:mm:ss")}
@@ -127,6 +222,9 @@ void MessageAggregatorMainWindow::log_qso (QString const& /*id*/, QDateTime time
<< new QStandardItem {report_sent}
<< new QStandardItem {report_received}
<< new QStandardItem {tx_power}
+ << new QStandardItem {operator_call}
+ << new QStandardItem {my_call}
+ << new QStandardItem {my_grid}
<< new QStandardItem {comments};
log_->appendRow (row);
log_table_view_->resizeColumnsToContents ();
@@ -136,7 +234,7 @@ void MessageAggregatorMainWindow::log_qso (QString const& /*id*/, QDateTime time
void MessageAggregatorMainWindow::add_client (QString const& id, QString const& version, QString const& revision)
{
- auto dock = new ClientWidget {decodes_model_, beacons_model_, id, version, revision, this};
+ auto dock = new ClientWidget {decodes_model_, beacons_model_, id, version, revision, calls_of_interest_, this};
dock->setAttribute (Qt::WA_DeleteOnClose);
auto view_action = dock->toggleViewAction ();
view_action->setEnabled (true);
@@ -149,9 +247,11 @@ void MessageAggregatorMainWindow::add_client (QString const& id, QString const&
connect (dock, &ClientWidget::do_reply, decodes_model_, &DecodesModel::do_reply);
connect (dock, &ClientWidget::do_halt_tx, server_, &MessageServer::halt_tx);
connect (dock, &ClientWidget::do_free_text, server_, &MessageServer::free_text);
+ connect (dock, &ClientWidget::location, server_, &MessageServer::location);
connect (view_action, &QAction::toggled, dock, &ClientWidget::setVisible);
+ connect (dock, &ClientWidget::highlight_callsign, server_, &MessageServer::highlight_callsign);
dock_widgets_[id] = dock;
- server_->replay (id);
+ server_->replay (id); // request decodes and status
}
void MessageAggregatorMainWindow::remove_client (QString const& id)
@@ -164,4 +264,21 @@ void MessageAggregatorMainWindow::remove_client (QString const& id)
}
}
+MessageAggregatorMainWindow::~MessageAggregatorMainWindow ()
+{
+ for (auto client : dock_widgets_)
+ {
+ delete client;
+ }
+}
+
+void MessageAggregatorMainWindow::change_highlighting (QString const& call, QColor const& bg, QColor const& fg
+ , bool last_only)
+{
+ for (auto id : dock_widgets_.keys ())
+ {
+ server_->highlight_callsign (id, call, bg, fg, last_only);
+ }
+}
+
#include "moc_MessageAggregatorMainWindow.cpp"
diff --git a/UDPExamples/MessageAggregatorMainWindow.hpp b/UDPExamples/MessageAggregatorMainWindow.hpp
index 4039c60a..b699bee9 100644
--- a/UDPExamples/MessageAggregatorMainWindow.hpp
+++ b/UDPExamples/MessageAggregatorMainWindow.hpp
@@ -15,6 +15,7 @@ class BeaconsModel;
class QLineEdit;
class QTableView;
class ClientWidget;
+class QListWidget;
using Frequency = MessageServer::Frequency;
@@ -25,15 +26,23 @@ class MessageAggregatorMainWindow
public:
MessageAggregatorMainWindow ();
+ ~MessageAggregatorMainWindow ();
Q_SLOT void log_qso (QString const& /*id*/, QDateTime time_off, QString const& dx_call, QString const& dx_grid
, Frequency dial_frequency, QString const& mode, QString const& report_sent
, QString const& report_received, QString const& tx_power, QString const& comments
- , QString const& name, QDateTime time_on);
+ , QString const& name, QDateTime time_on, QString const& operator_call
+ , QString const& my_call, QString const& my_grid);
private:
void add_client (QString const& id, QString const& version, QString const& revision);
void remove_client (QString const& id);
+ void change_highlighting (QString const& call, QColor const& bg = QColor {}, QColor const& fg = QColor {},
+ bool last_only = false);
+
+ // maps client id to widgets
+ using ClientsDictionary = QHash<QString, ClientWidget *>;
+ ClientsDictionary dock_widgets_;
QStandardItemModel * log_;
QMenu * view_menu_;
@@ -42,10 +51,12 @@ private:
MessageServer * server_;
QLineEdit * multicast_group_line_edit_;
QTableView * log_table_view_;
-
- // maps client id to widgets
- using ClientsDictionary = QHash<QString, ClientWidget *>;
- ClientsDictionary dock_widgets_;
+ QListWidget * calls_of_interest_;
+ QAction * add_call_of_interest_action_;
+ QAction * delete_call_of_interest_action_;
+ QAction * last_call_of_interest_action_;
+ QAction * call_of_interest_bg_colour_action_;
+ QAction * call_of_interest_fg_colour_action_;
};
#endif
diff --git a/UDPExamples/UDPDaemon.cpp b/UDPExamples/UDPDaemon.cpp
index 2d3b1b2d..b75a8ade 100644
--- a/UDPExamples/UDPDaemon.cpp
+++ b/UDPExamples/UDPDaemon.cpp
@@ -95,6 +95,38 @@ public:
}
}
+ Q_SLOT void qso_logged (QString const&client_id, QDateTime time_off, QString const& dx_call, QString const& dx_grid
+ , Frequency dial_frequency, QString const& mode, QString const& report_sent
+ , QString const& report_received, QString const& tx_power
+ , QString const& comments, QString const& name, QDateTime time_on
+ , QString const& operator_call, QString const& my_call, QString const& my_grid)
+ {
+ if (client_id == id_)
+ {
+ qDebug () << "time_on:" << time_on << "time_off:" << time_off << "dx_call:" << dx_call << "grid:" << dx_grid
+ << "freq:" << dial_frequency << "mode:" << mode << "rpt_sent:" << report_sent
+ << "rpt_rcvd:" << report_received << "Tx_pwr:" << tx_power << "comments:" << comments
+ << "name:" << name << "operator_call:" << operator_call << "my_call:" << my_call
+ << "my_grid:" << my_grid;
+ std::cout << QByteArray {80, '-'}.data () << '\n';
+ std::cout << tr ("%1: Logged %2 grid: %3 power: %4 sent: %5 recd: %6 freq: %7 time_off: %8 op: %9 my_call: %10 my_grid: %11")
+ .arg (id_).arg (dx_call).arg (dx_grid).arg (tx_power).arg (report_sent).arg (report_received)
+ .arg (dial_frequency).arg (time_off.toString("yyyy-MM-dd hh:mm:ss.z")).arg (operator_call)
+ .arg (my_call).arg (my_grid).toStdString ()
+ << std::endl;
+ }
+ }
+
+ Q_SLOT void logged_ADIF (QString const&client_id, QByteArray const& ADIF)
+ {
+ if (client_id == id_)
+ {
+ qDebug () << "ADIF:" << ADIF;
+ std::cout << QByteArray {80, '-'}.data () << '\n';
+ std::cout << ADIF.data () << std::endl;
+ }
+ }
+
private:
QString id_;
Frequency dial_frequency_;
@@ -127,6 +159,8 @@ private:
connect (server_, &MessageServer::status_update, client, &Client::update_status);
connect (server_, &MessageServer::decode, client, &Client::decode_added);
connect (server_, &MessageServer::WSPR_decode, client, &Client::beacon_spot_added);
+ connect (server_, &MessageServer::qso_logged, client, &Client::qso_logged);
+ connect (server_, &MessageServer::logged_ADIF, client, &Client::logged_ADIF);
clients_[id] = client;
server_->replay (id);
std::cout << "Discovered WSJT-X instance: " << id.toStdString ();