Skip to content

Commit

Permalink
Transfer of location integrity control
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Apr 14, 2024
1 parent 6e4d010 commit 95354fe
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
51 changes: 49 additions & 2 deletions projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ private void CheckEventPlace(GDMPlace place, GDMCustomEvent evt)
placeLocation.XRef = "";
}

if (place.StringValue != "" && locRec != null) {
/*if (place.StringValue != "" && locRec != null) {
place.StringValue = GKUtils.GetLocationNameExt(locRec, evt.Date.Value);
}
}*/

CheckTagWithNotes(place);
}
Expand Down Expand Up @@ -550,5 +550,52 @@ public static bool CheckGEDCOMFormat(IBaseContext baseContext, IProgressControll
var instance = new GEDCOMChecker(baseContext, pc);
return instance.CheckFormat();
}


public static void SyncTreeLocations(IBaseContext baseContext, IProgressController pc)
{
if (baseContext == null)
throw new ArgumentNullException("baseContext");

if (pc == null)
throw new ArgumentNullException("pc");

try {
var tree = baseContext.Tree;
pc.Begin(LangMan.LS(LSID.FormatCheck), 100);

try {
int progress = 0;
int num = tree.RecordsCount;
for (int i = 0; i < num; i++) {
GDMRecord rec = tree[i];
if (rec.RecordType == GDMRecordType.rtIndividual || rec.RecordType == GDMRecordType.rtFamily) {
var rwe = rec as GDMRecordWithEvents;
if (rwe.HasEvents) {
for (int k = 0, num2 = rwe.Events.Count; k < num2; k++) {
GDMCustomEvent evt = rwe.Events[k];
if (!evt.HasPlace) continue;

GDMLocationRecord locRec = tree.GetPtrValue<GDMLocationRecord>(evt.Place.Location);
if (locRec != null) {
evt.Place.StringValue = GKUtils.GetLocationNameExt(locRec, evt.Date.Value);
}
}
}
}

int newProgress = (int)Math.Min(100, ((i + 1) * 100.0f) / num);
if (progress != newProgress) {
progress = newProgress;
pc.StepTo(progress);
}
}
} finally {
pc.End();
}
} catch (Exception ex) {
Logger.WriteError("GEDCOMChecker.SyncTreeLocations()", ex);
}
}
}
}
8 changes: 8 additions & 0 deletions projects/GKCore/GKCore/Controllers/PlacesManagerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Collections.Generic;
using BSLib;
using GDModel;
using GDModel.Providers.GEDCOM;
using GKCore.Design;
using GKCore.Design.Controls;
using GKCore.Design.Views;
Expand All @@ -46,6 +47,13 @@ public override void UpdateView()
{
}

public void SyncAll()
{
AppHost.Instance.ExecuteWork((controller) => {
GEDCOMChecker.SyncTreeLocations(fBase.Context, controller);
});
}

public void Clear()
{
TreeTools.SearchPlaces_Clear(fPlaces);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/GKv2/GEDKeeper2/GKUI/Forms/TTPlacesManagerDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

private void Form_Load(object sender, EventArgs e)
{
fController.SyncAll();
}

private void miDetails_Click(object sender, EventArgs e)
{
fController.ShowDetails();
Expand Down
7 changes: 6 additions & 1 deletion projects/GKv3/GEDKeeper3/GKUI/Forms/TTPlacesManagerDlg.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2023 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -87,6 +87,11 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

private void Form_Load(object sender, EventArgs e)
{
fController.SyncAll();
}

private void miDetails_Click(object sender, EventArgs e)
{
fController.ShowDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:forms="clr-namespace:GKUI.Forms" xmlns:comcom="clr-namespace:GKUI.Components;assembly=GKComponents"
x:Class="GKUI.Forms.TTPlacesManagerDlg"
AbortButton="{x:Reference btnClose}">
AbortButton="{x:Reference btnClose}" Load="Form_Load">

<TableLayout Style="paddedTable8">

Expand Down

0 comments on commit 95354fe

Please sign in to comment.