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:
@@ -1,24 +1,36 @@
|
||||
using Avalonia.Media;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// One line of the log window. It carries the colour so the log is coloured by
|
||||
/// the same scorer as the entry window and the bandmap.
|
||||
public sealed record LogRow(Qso Qso, Verdict? Verdict)
|
||||
/// One line of the log window. The grid reaches the editable fields through the
|
||||
/// indexer, so the columns can follow the contest exchange instead of being
|
||||
/// fixed in the XAML. The colour comes from the same scorer as the entry window
|
||||
/// and the bandmap.
|
||||
public sealed class LogRow
|
||||
{
|
||||
public string Time => Qso.TimestampUtc.ToString("MM-dd HH:mm");
|
||||
private readonly Func<Qso, QsoField, string, bool> edit;
|
||||
|
||||
public string Call => Qso.Call.Text;
|
||||
public LogRow(Qso qso, Verdict? verdict, Func<Qso, QsoField, string, bool> edit)
|
||||
{
|
||||
Qso = qso;
|
||||
Verdict = verdict;
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
public string Frequency => Qso.Frequency.Kilohertz.ToString("0.0");
|
||||
public Qso Qso { get; }
|
||||
|
||||
public string Mode => Qso.Mode.Name;
|
||||
public Verdict? Verdict { get; }
|
||||
|
||||
public string Sent => $"{Qso.SentReport} {SentExchange()}".Trim();
|
||||
|
||||
public string Received => $"{Qso.ReceivedReport} {ReceivedExchange()}".Trim();
|
||||
/// `name` is a `QsoField` name. A refused edit leaves the contact alone, so
|
||||
/// the grid reads the old value back and the cell reverts.
|
||||
public string this[string name]
|
||||
{
|
||||
get => QsoEditor.Read(Qso, Enum.Parse<QsoField>(name));
|
||||
set => edit(Qso, Enum.Parse<QsoField>(name), value);
|
||||
}
|
||||
|
||||
public string Country => Qso.CountryPrefix;
|
||||
|
||||
@@ -29,31 +41,5 @@ public sealed record LogRow(Qso Qso, Verdict? Verdict)
|
||||
Qso.IsMultiplier2 ? "2" : "",
|
||||
Qso.IsMultiplier3 ? "3" : "");
|
||||
|
||||
public string Operator => Qso.Operator;
|
||||
|
||||
public IBrush Colour => Verdicts.Colour(Verdict);
|
||||
|
||||
private string SentExchange() =>
|
||||
Qso.SentNumber > 0 ? Qso.SentNumber.ToString() : "";
|
||||
|
||||
private string ReceivedExchange()
|
||||
{
|
||||
List<string> parts = [];
|
||||
if (Qso.ReceivedNumber > 0)
|
||||
{
|
||||
parts.Add(Qso.ReceivedNumber.ToString());
|
||||
}
|
||||
if (Qso.Zone > 0)
|
||||
{
|
||||
parts.Add(Qso.Zone.ToString());
|
||||
}
|
||||
foreach (string value in new[] { Qso.Section, Qso.Exchange1, Qso.Name, Qso.GridSquare, Qso.MiscText })
|
||||
{
|
||||
if (value.Length > 0)
|
||||
{
|
||||
parts.Add(value);
|
||||
}
|
||||
}
|
||||
return string.Join(' ', parts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user