Edit and delete contacts in the log

Double-click a cell in the log window to change it. The columns follow the
contest exchange instead of being fixed in the XAML, so CQ WW gets a Zone
column and Sweepstakes gets Nr, Prec, Ck and Sec.

QsoEditor holds the column list and applies one field edit. Validation comes
from the ExchangeFieldKind the contest declared: a CQ zone is 1 to 40, an ITU
zone 1 to 90, a section is looked up in the ARRL list, a grid must parse.
A refused edit returns the reason and leaves the log alone, so the cell
reverts. Changing the callsign runs the country lookup again.

Delete, or the right-click menu, removes the selected contact after a
confirmation. Either way the log is rescored, so a multiplier the removed
contact held passes to the next contact that claims it.

Both go out to the other stations in N1MM's own messages: contactreplace
carries oldcall and oldtimestamp, contactdelete names the contact. An incoming
edit or delete is matched by contact id first, falling back to call plus
timestamp because N1MM does not know our ids.

Country, continent and the two prefixes were filled in twice, once when
logging and once when editing. They now come from CountryFields.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 15:32:32 +00:00
parent 328a40b27c
commit eb31fa5ae1
23 changed files with 953 additions and 112 deletions

View File

@@ -31,17 +31,34 @@ public sealed class StationNetwork : IDisposable
public IReadOnlyList<IPEndPoint> Peers => peers;
/// A contact another station logged. It arrives already scored; the log
/// works its points and multipliers out again from the rules.
public event EventHandler<Qso>? ContactArrived;
/// A contact another station logged, edited or deleted. A logged or edited
/// contact arrives already scored; the log works its points and multipliers
/// out again from the rules.
public event EventHandler<ContactUpdate>? UpdateArrived;
public event EventHandler<string>? Failed;
public void Start() => loop ??= Task.Run(() => ListenAsync(stopping.Token));
public async Task SendAsync(Qso qso, string myCallsign, CancellationToken cancellation = default)
public Task SendAsync(Qso qso, string myCallsign, CancellationToken cancellation = default) =>
SendTextAsync(ContactMessage.Write(qso, myCallsign, stationName), cancellation);
public Task SendEditAsync(
Qso qso,
string myCallsign,
string oldCall,
DateTime oldTimestampUtc,
CancellationToken cancellation = default) =>
SendTextAsync(
ContactMessage.WriteReplace(qso, myCallsign, stationName, oldCall, oldTimestampUtc),
cancellation);
public Task SendDeleteAsync(Qso qso, string myCallsign, CancellationToken cancellation = default) =>
SendTextAsync(ContactMessage.WriteDelete(qso, myCallsign, stationName), cancellation);
private async Task SendTextAsync(string xml, CancellationToken cancellation)
{
byte[] message = Encoding.UTF8.GetBytes(ContactMessage.Write(qso, myCallsign, stationName));
byte[] message = Encoding.UTF8.GetBytes(xml);
foreach (IPEndPoint peer in Destinations())
{
try
@@ -75,10 +92,10 @@ public sealed class StationNetwork : IDisposable
try
{
UdpReceiveResult received = await listener.ReceiveAsync(cancellation).ConfigureAwait(false);
Qso? qso = ContactMessage.Read(Encoding.UTF8.GetString(received.Buffer));
if (qso is not null && qso.StationName != stationName)
ContactUpdate? update = ContactMessage.Read(Encoding.UTF8.GetString(received.Buffer));
if (update is not null && update.StationName != stationName)
{
ContactArrived?.Invoke(this, qso);
UpdateArrived?.Invoke(this, update);
}
}
catch (OperationCanceledException)