From 5d442bb596f3ed2a950261682e4422afd1a5eeaf Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 22 Sep 2017 22:08:41 +0000 Subject: [PATCH] Improve performance of the UDP reference application message_aggregator git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8107 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- UDPExamples/BeaconsModel.cpp | 8 ++++---- UDPExamples/ClientWidget.cpp | 21 ++++++++++++++++----- UDPExamples/ClientWidget.hpp | 2 ++ UDPExamples/DecodesModel.cpp | 10 +++++----- UDPExamples/MessageAggregatorMainWindow.cpp | 1 + 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/UDPExamples/BeaconsModel.cpp b/UDPExamples/BeaconsModel.cpp index 6e83fa382..1302dc05e 100644 --- a/UDPExamples/BeaconsModel.cpp +++ b/UDPExamples/BeaconsModel.cpp @@ -12,10 +12,10 @@ namespace QT_TRANSLATE_NOOP ("BeaconsModel", "DT"), QT_TRANSLATE_NOOP ("BeaconsModel", "Frequency"), QT_TRANSLATE_NOOP ("BeaconsModel", "Drift"), - QT_TRANSLATE_NOOP ("BeaconsModel", "Callsign"), QT_TRANSLATE_NOOP ("BeaconsModel", "Grid"), QT_TRANSLATE_NOOP ("BeaconsModel", "Power"), QT_TRANSLATE_NOOP ("BeaconsModel", "Live"), + QT_TRANSLATE_NOOP ("BeaconsModel", "Callsign"), }; QString live_string (bool off_air) @@ -60,7 +60,7 @@ namespace live->setTextAlignment (Qt::AlignHCenter); QList row { - new QStandardItem {client_id}, time_item, snr_item, dt, freq, dri, new QStandardItem {callsign}, gd, pwr, live}; + new QStandardItem {client_id}, time_item, snr_item, dt, freq, dri, gd, pwr, live, new QStandardItem {callsign}}; Q_FOREACH (auto& item, row) { item->setEditable (false); @@ -98,10 +98,10 @@ void BeaconsModel::add_beacon_spot (bool is_new, QString const& client_id, QTime && item (row, 3)->data ().toFloat () == delta_time && item (row, 4)->data ().value () == frequency && data (index (row, 5)).toInt () == drift - && data (index (row, 6)).toString () == callsign && data (index (row, 7)).toString () == grid && data (index (row, 8)).toInt () == power - && data (index (row, 9)).toString () == live_string (off_air)) + && data (index (row, 6)).toString () == live_string (off_air) + && data (index (row, 9)).toString () == callsign) { return; } diff --git a/UDPExamples/ClientWidget.cpp b/UDPExamples/ClientWidget.cpp index 357875327..de77286b8 100644 --- a/UDPExamples/ClientWidget.cpp +++ b/UDPExamples/ClientWidget.cpp @@ -30,7 +30,7 @@ QVariant ClientWidget::IdFilterModel::data (QModelIndex const& proxy_index, int { switch (proxy_index.column ()) { - case 6: // message + case 8: // message { auto message = QSortFilterProxyModel::data (proxy_index).toString (); if (base_call_re_.pattern ().size () @@ -130,6 +130,7 @@ ClientWidget::ClientWidget (QAbstractItemModel * decodes_model, QAbstractItemMod , rx_df_label_ {new QLabel} , tx_df_label_ {new QLabel} , report_label_ {new QLabel} + , columns_resized_ {false} { // set up widgets decodes_proxy_model_.setSourceModel (decodes_model); @@ -246,12 +247,13 @@ void ClientWidget::decode_added (bool /*is_new*/, QString const& client_id, QTim , float /*delta_time*/, quint32 /*delta_frequency*/, QString const& /*mode*/ , QString const& /*message*/, bool /*low_confidence*/, bool /*off_air*/) { - if (client_id == id_) + if (client_id == id_ && !columns_resized_) { decodes_stack_->setCurrentIndex (0); decodes_table_view_->resizeColumnsToContents (); - decodes_table_view_->scrollToBottom (); + columns_resized_ = true; } + decodes_table_view_->scrollToBottom (); } void ClientWidget::beacon_spot_added (bool /*is_new*/, QString const& client_id, QTime /*time*/, qint32 /*snr*/ @@ -259,11 +261,20 @@ void ClientWidget::beacon_spot_added (bool /*is_new*/, QString const& client_id, , QString const& /*callsign*/, QString const& /*grid*/, qint32 /*power*/ , bool /*off_air*/) { - if (client_id == id_) + if (client_id == id_ && !columns_resized_) { decodes_stack_->setCurrentIndex (1); beacons_table_view_->resizeColumnsToContents (); - beacons_table_view_->scrollToBottom (); + columns_resized_ = true; + } + beacons_table_view_->scrollToBottom (); +} + +void ClientWidget::clear_decodes (QString const& client_id) +{ + if (client_id == id_) + { + columns_resized_ = false; } } diff --git a/UDPExamples/ClientWidget.hpp b/UDPExamples/ClientWidget.hpp index 37126520e..1f5ae6012 100644 --- a/UDPExamples/ClientWidget.hpp +++ b/UDPExamples/ClientWidget.hpp @@ -38,6 +38,7 @@ public: , float delta_time, Frequency delta_frequency, qint32 drift , QString const& callsign, QString const& grid, qint32 power , bool off_air); + Q_SLOT void clear_decodes (QString const& client_id); Q_SIGNAL void do_reply (QModelIndex const&, quint8 modifier); Q_SIGNAL void do_halt_tx (QString const& id, bool auto_only); @@ -78,6 +79,7 @@ private: QLabel * rx_df_label_; QLabel * tx_df_label_; QLabel * report_label_; + bool columns_resized_; }; #endif diff --git a/UDPExamples/DecodesModel.cpp b/UDPExamples/DecodesModel.cpp index bf1acf9b8..5847e49ff 100644 --- a/UDPExamples/DecodesModel.cpp +++ b/UDPExamples/DecodesModel.cpp @@ -16,9 +16,9 @@ namespace QT_TRANSLATE_NOOP ("DecodesModel", "DT"), QT_TRANSLATE_NOOP ("DecodesModel", "DF"), QT_TRANSLATE_NOOP ("DecodesModel", "Md"), - QT_TRANSLATE_NOOP ("DecodesModel", "Message"), QT_TRANSLATE_NOOP ("DecodesModel", "Confidence"), QT_TRANSLATE_NOOP ("DecodesModel", "Live"), + QT_TRANSLATE_NOOP ("DecodesModel", "Message"), }; QString confidence_string (bool low_confidence) @@ -63,7 +63,7 @@ namespace live->setTextAlignment (Qt::AlignHCenter); QList row { - new QStandardItem {client_id}, time_item, snr_item, dt, df, md, new QStandardItem {message}, confidence, live}; + new QStandardItem {client_id}, time_item, snr_item, dt, df, md, confidence, live, new QStandardItem {message}}; Q_FOREACH (auto& item, row) { item->setEditable (false); @@ -101,9 +101,9 @@ void DecodesModel::add_decode (bool is_new, QString const& client_id, QTime time && item (row, 3)->data ().toFloat () == delta_time && item (row, 4)->data ().toUInt () == delta_frequency && data (index (row, 5)).toString () == mode - && data (index (row, 6)).toString () == message && data (index (row, 7)).toString () == confidence_string (low_confidence) - && data (index (row, 8)).toString () == live_string (off_air)) + && data (index (row, 6)).toString () == live_string (off_air) + && data (index (row, 8)).toString () == message) { return; } @@ -145,7 +145,7 @@ void DecodesModel::do_reply (QModelIndex const& source, quint8 modifiers) , item (row, 3)->data ().toFloat () , item (row, 4)->data ().toInt () , data (index (row, 5)).toString () - , data (index (row, 6)).toString () + , data (index (row, 8)).toString () , confidence_string (true) == data (index (row, 7)).toString () , modifiers); } diff --git a/UDPExamples/MessageAggregatorMainWindow.cpp b/UDPExamples/MessageAggregatorMainWindow.cpp index eadb6bf4a..196282d61 100644 --- a/UDPExamples/MessageAggregatorMainWindow.cpp +++ b/UDPExamples/MessageAggregatorMainWindow.cpp @@ -145,6 +145,7 @@ void MessageAggregatorMainWindow::add_client (QString const& id, QString const& connect (server_, &MessageServer::status_update, dock, &ClientWidget::update_status); connect (server_, &MessageServer::decode, dock, &ClientWidget::decode_added); connect (server_, &MessageServer::WSPR_decode, dock, &ClientWidget::beacon_spot_added); + connect (server_, &MessageServer::clear_decodes, dock, &ClientWidget::clear_decodes); 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);