Skip to content

Commit

Permalink
Merge branch 'ms-request-qsy' into ms-rel-v1812
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Jun 18, 2023
2 parents cebfe4c + 4fd0af4 commit d49fbad
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 91 deletions.
55 changes: 36 additions & 19 deletions src/freedv_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,28 +193,38 @@ void FreeDVReporterDialog::refreshQSYButtonState()
void FreeDVReporterDialog::onReporterConnect_()
{
CallAfter([&]() {
m_listSpots->Freeze();

for (auto index = m_listSpots->GetItemCount() - 1; index >= 0; index--)
{
delete (std::string*)m_listSpots->GetItemData(index);
m_listSpots->DeleteItem(index);
}

m_listSpots->Thaw();
});
}

void FreeDVReporterDialog::onReporterDisconnect_()
{
CallAfter([&]() {
m_listSpots->Freeze();

for (auto index = m_listSpots->GetItemCount() - 1; index >= 0; index--)
{
delete (std::string*)m_listSpots->GetItemData(index);
m_listSpots->DeleteItem(index);
}

m_listSpots->Thaw();
});
}

void FreeDVReporterDialog::onUserConnectFn_(std::string sid, std::string lastUpdate, std::string callsign, std::string gridSquare, std::string version)
{
CallAfter([&, sid, lastUpdate, callsign, gridSquare, version]() {
m_listSpots->Freeze();

auto itemIndex = m_listSpots->InsertItem(m_listSpots->GetItemCount(), callsign);
m_listSpots->SetItem(itemIndex, 1, gridSquare);
m_listSpots->SetItem(itemIndex, 2, version);
Expand All @@ -234,8 +244,10 @@ void FreeDVReporterDialog::onUserConnectFn_(std::string sid, std::string lastUpd
// Resize all columns to the biggest value.
for (int col = 0; col <= 10; col++)
{
m_listSpots->SetColumnWidth(col, wxLIST_AUTOSIZE);
m_listSpots->SetColumnWidth(col, wxLIST_AUTOSIZE_USEHEADER);
}

m_listSpots->Thaw();
});
}

Expand Down Expand Up @@ -265,17 +277,15 @@ void FreeDVReporterDialog::onFrequencyChangeFn_(std::string sid, std::string las
{
double frequencyMHz = frequencyHz / 1000000.0;

m_listSpots->Freeze();

wxString frequencyMHzString = wxString::Format(_("%.04f MHz"), frequencyMHz);
m_listSpots->SetItem(index, 3, frequencyMHzString);

auto lastUpdateTime = makeValidTime_(lastUpdate);
m_listSpots->SetItem(index, 10, lastUpdateTime);

// Resize all columns to the biggest value.
for (int col = 0; col <= 10; col++)
{
m_listSpots->SetColumnWidth(col, wxLIST_AUTOSIZE);
}
m_listSpots->Thaw();

break;
}
Expand Down Expand Up @@ -303,6 +313,8 @@ void FreeDVReporterDialog::onTransmitUpdateFn_(std::string sid, std::string last
//m_listSpots->SetItemBackgroundColour(index, nonRedBackground_);
}

m_listSpots->Freeze();

m_listSpots->SetItem(index, 4, txStatus);
m_listSpots->SetItem(index, 5, txMode);

Expand All @@ -311,12 +323,9 @@ void FreeDVReporterDialog::onTransmitUpdateFn_(std::string sid, std::string last

auto lastUpdateTime = makeValidTime_(lastUpdate);
m_listSpots->SetItem(index, 10, lastUpdateTime);

m_listSpots->Thaw();

// Resize all columns to the biggest value.
for (int col = 0; col <= 10; col++)
{
m_listSpots->SetColumnWidth(col, wxLIST_AUTOSIZE);
}
break;
}
}
Expand All @@ -331,6 +340,8 @@ void FreeDVReporterDialog::onReceiveUpdateFn_(std::string sid, std::string lastU
std::string* sidPtr = (std::string*)m_listSpots->GetItemData(index);
if (sid == *sidPtr)
{
m_listSpots->Freeze();

m_listSpots->SetItem(index, 7, receivedCallsign);
m_listSpots->SetItem(index, 8, rxMode);

Expand All @@ -339,12 +350,8 @@ void FreeDVReporterDialog::onReceiveUpdateFn_(std::string sid, std::string lastU

auto lastUpdateTime = makeValidTime_(lastUpdate);
m_listSpots->SetItem(index, 10, lastUpdateTime);

// Resize all columns to the biggest value.
for (int col = 0; col <= 10; col++)
{
m_listSpots->SetColumnWidth(col, wxLIST_AUTOSIZE);
}

m_listSpots->Thaw();

break;
}
Expand Down Expand Up @@ -375,16 +382,26 @@ wxString FreeDVReporterDialog::makeValidTime_(std::string timeStr)
}

timezoneRgx.Replace(&tmp, _(""));

timeZone = wxDateTime::TimeZone(tzMinutes);
}

wxDateTime tmpDate;
if (tmpDate.ParseISOCombined(tmp))
{
tmpDate.MakeFromTimezone(timeZone);
return tmpDate.Format();
if (wxGetApp().m_useUTCTime)
{
timeZone = wxDateTime::TimeZone(wxDateTime::TZ::UTC);
}
else
{
timeZone = wxDateTime::TimeZone(wxDateTime::TZ::Local);
}
return tmpDate.Format(wxDefaultDateTimeFormat, timeZone);
}
else
{
return _("Unknown");
}
}
}
2 changes: 1 addition & 1 deletion src/freedv_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FreeDVReporterDialog : public wxDialog
wxWindowID id = wxID_ANY, const wxString& title = _("FreeDV Reporter"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL );
long style = wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL | wxMINIMIZE_BOX);
~FreeDVReporterDialog();

void setReporter(FreeDVReporter* reporter);
Expand Down
2 changes: 2 additions & 0 deletions src/ongui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void MainFrame::OnToolsFreeDVReporter(wxCommandEvent& event)
if (m_reporterDialog != nullptr)
{
m_reporterDialog->Show();
m_reporterDialog->Iconize(false); // undo minimize if required
m_reporterDialog->Raise(); // brings from background to foreground if required
}
else
{
Expand Down
Loading

0 comments on commit d49fbad

Please sign in to comment.