Skip to content

Commit

Permalink
Added the option to generate extended places by full or abbreviated n…
Browse files Browse the repository at this point in the history
…ames
  • Loading branch information
Serg-Norseman committed Mar 29, 2024
1 parent d35a8c8 commit 082bc73
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 28 deletions.
1 change: 1 addition & 0 deletions locales/Afrikaans.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Belarusian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Chinese Simplified.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Dutch.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Hungarian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Icelandic.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Japanese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Kazakh (Cyrillic).lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Portuguese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Serbian (Latin).lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/Spanish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/czech.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/french.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/german.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/help_enu/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Change log</h1>

<p>
<b>02.03.2024 [v2.29.1 &amp; v3.5.1]</b><ul>
<li>Added the option to generate extended places by full or abbreviated names.
<li>Added option for the reverse order of listing places in the ATD (by default, direct - from largest to smallest, reverse - from smallest to largest),
the option only affects the listing of places in events/facts (when using extended processing of places) and when displayed in diagrams trees.
<li>Added a user reference icon for the "RI:Recruit" on tree diagrams (to mark those who were recruited into the Russian Imperial Army).
Expand Down
1 change: 1 addition & 0 deletions locales/help_rus/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>История версий</h1>

<p>
<b>02.03.2024 [v2.29.1 &amp; v3.5.1]</b><ul>
<li>Добавлена опция формирования расширенных мест по полным или сокращенным названиям.
<li>Выведена опция обратного порядка перечисления мест в АТД (по умолчанию прямой - от большего к меньшему, обратный - от меньшего к большему),
опция действует только на перечисление мест в событиях/фактах (при использовании расширенной обработки мест) и при выводе в диаграммах деревьев.
<li>Добавлен значок пользовательской сноски для диаграмм деревьев "РИ:Рекрут" (для пометки отданных в рекруты русской императорской армии).
Expand Down
1 change: 1 addition & 0 deletions locales/italian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/polish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
1 change: 1 addition & 0 deletions locales/russian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=РИ:Рекрут
952=Обратный порядок мест (от меньш. к больш.)
953=Сокращенные названия мест
1 change: 1 addition & 0 deletions locales/ukrainian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -960,3 +960,4 @@

951=RI:Recruit
952=Reverse order of places
953=Abbreviated location names
14 changes: 9 additions & 5 deletions projects/GKCore/GDModel/GDMLocationRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public override void ReplaceXRefs(GDMXRefReplacer map)
fTopLevels.ReplaceXRefs(map);
}

public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnum)
public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnum, bool abbreviations = false)
{
GDMList<GDMLocationName> result;

Expand All @@ -189,14 +189,16 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu
if (topLoc == null) continue;

bool wasJoin = false;
var topNames = topLoc.GetFullNames(tree, atdEnum);
var topNames = topLoc.GetFullNames(tree, atdEnum, abbreviations);
for (int i = 0; i < topNames.Count; i++) {
var topName = topNames[i];

var interDate = GDMCustomDate.GetIntersection(topLevel.Date.Value, topName.Date.Value);
if (!interDate.IsEmpty()) {
string tnVal = (abbreviations && !string.IsNullOrEmpty(topName.Abbreviation)) ? topName.Abbreviation : topName.StringValue;

var newLocName = new GDMLocationName();
newLocName.SetRawData(topName.StringValue, interDate);
newLocName.SetRawData(tnVal, interDate);
buffer.Add(newLocName);
wasJoin = true;
}
Expand All @@ -219,7 +221,9 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu

var interDate = GDMCustomDate.GetIntersection(topDate, locName.Date.Value);
if (!interDate.IsEmpty()) {
string newName = (atdEnum == ATDEnumeration.fLtS) ? topName + ", " + locName.StringValue : locName.StringValue + ", " + topName;
string nVal = (abbreviations && !string.IsNullOrEmpty(locName.Abbreviation)) ? locName.Abbreviation : locName.StringValue;

string newName = (atdEnum == ATDEnumeration.fLtS) ? topName + ", " + nVal : nVal + ", " + topName;

var newLocName = new GDMLocationName();
newLocName.SetRawData(newName, interDate);
Expand All @@ -234,7 +238,7 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu

public string GetNameByDate(GDMCustomDate date, ATDEnumeration atdEnum, bool full = false)
{
var namesList = (!full) ? fNames : GetFullNames(Tree, atdEnum);
var namesList = (!full) ? fNames : GetFullNames(Tree, atdEnum, GlobalOptions.Instance.EL_AbbreviatedNames);

if (date != null && !date.IsEmpty()) {
for (int i = 0; i < namesList.Count; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ public void CheckPrimaryName()
public override bool Accept()
{
try {
bool isRenamed = (fLocationRecord.LocationName != fView.Name.Text);
//bool isRenamed = (fLocationRecord.LocationName != fView.Name.Text);

fLocationRecord.LocationName = fView.Name.Text;
fLocationRecord.Map.Lati = ConvertHelper.ParseFloat(fView.Latitude.Text, 0.0);
fLocationRecord.Map.Long = ConvertHelper.ParseFloat(fView.Longitude.Text, 0.0);

bool isChanged = isRenamed || fLocalUndoman.HasChanges();
//bool isChanged = isRenamed || fLocalUndoman.HasChanges();

fLocalUndoman.Commit();

if (isChanged) {
/*if (isChanged)*/ {
fBase.Context.Tree.RenameLocationRecord(fLocationRecord);
}

Expand Down
7 changes: 6 additions & 1 deletion projects/GKCore/GKCore/Controllers/OptionsDlgController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void UpdateColumnsList()
int num = fTempColumns.Count;
for (int i = 0; i < num; i++) {
ListColumn column = fTempColumns.OrderedColumns[i];
listView.AddItem(null, column.CurActive, LangMan.LS(column.ColName));
listView.AddItem(null, column.CurActive, column.ColName);
}
} finally {
listView.EndUpdate();
Expand Down Expand Up @@ -451,6 +451,8 @@ public void UpdateSpecials()
GetControl<ICheckBox>("chkFilesOverwriteWarn").Enabled = hasOverwritePrompt;

GetControl<ICheckBox>("chkExtendedLocations").Checked = fOptions.ExtendedLocations;
GetControl<ICheckBox>("chkELAbbreviatedNames").Checked = fOptions.EL_AbbreviatedNames;

GetControl<ICheckBox>("chkReversePlacesOrder").Checked = fOptions.ReversePlaceEntitiesOrder;
}

Expand All @@ -471,6 +473,8 @@ public void AcceptSpecials()
fOptions.FilesOverwriteWarn = GetControl<ICheckBox>("chkFilesOverwriteWarn").Checked;

fOptions.ExtendedLocations = GetControl<ICheckBox>("chkExtendedLocations").Checked;
fOptions.EL_AbbreviatedNames = GetControl<ICheckBox>("chkELAbbreviatedNames").Checked;

fOptions.ReversePlaceEntitiesOrder = GetControl<ICheckBox>("chkReversePlacesOrder").Checked;
}

Expand Down Expand Up @@ -982,6 +986,7 @@ public override void SetLocale()
GetControl<ICheckBox>("chkFilesOverwriteWarn").Text = LangMan.LS(LSID.FilesOverwriteWarn);
GetControl<ICheckBox>("chkExtendedKinships").Text = LangMan.LS(LSID.ExtendedKinships);
GetControl<ICheckBox>("chkExtendedLocations").Text = LangMan.LS(LSID.ExtendedLocations);
GetControl<ICheckBox>("chkELAbbreviatedNames").Text = LangMan.LS(LSID.EL_AbbreviatedNames);
GetControl<ICheckBox>("chkReversePlacesOrder").Text = LangMan.LS(LSID.ReversePlacesOrder);

// Plugins
Expand Down
2 changes: 1 addition & 1 deletion projects/GKCore/GKCore/GKUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3050,7 +3050,7 @@ public static void ShowLocationInfo(IBaseContext baseContext, GDMLocationRecord
summary.Add(LangMan.LS(LSID.Latitude) + ": " + locRec.Map.Lati);
summary.Add(LangMan.LS(LSID.Longitude) + ": " + locRec.Map.Long);

var fullNames = locRec.GetFullNames(tree, ATDEnumeration.fStL);
var fullNames = locRec.GetFullNames(tree, ATDEnumeration.fStL, glob.EL_AbbreviatedNames);
if (fullNames.Count > 0) {
//linkList.Sort();

Expand Down
4 changes: 3 additions & 1 deletion projects/GKCore/GKCore/LangMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,9 @@ public enum LSID

/* 951 */ RI_Recruit,
/* 952 */ ReversePlacesOrder,
/* 953 */ EL_AbbreviatedNames,

/* 000 */ Last = ReversePlacesOrder
/* 000 */ Last = EL_AbbreviatedNames
}


Expand Down Expand Up @@ -2003,6 +2004,7 @@ public static class LangMan

/* 951 */ "RI:Recruit",
/* 952 */ "Reverse order of places",
/* 953 */ "Abbreviated location names",
};

private static readonly LangManager fLangMan = new LangManager();
Expand Down
2 changes: 1 addition & 1 deletion projects/GKCore/GKCore/Lists/IndividualListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ protected override void UpdateColumnsMap()
break;
}
} else {
AddColumn(LangMan.LS(columnProps.ColName), columnProps.CurWidth, false, bColType, 0);
AddColumn(columnProps.ColName, columnProps.CurWidth, false, bColType, 0);
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions projects/GKCore/GKCore/Lists/ListColumns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace GKCore.Lists
public sealed class ListColumn
{
public readonly byte Id;
public readonly LSID ColName;
public readonly string ColName;
public readonly DataType DataType;
public readonly int DefWidth;
public readonly bool DefActive;
Expand All @@ -45,7 +45,7 @@ public sealed class ListColumn
public bool CurActive;
public int Order;

public ListColumn(byte id, LSID colName, DataType dataType,
public ListColumn(byte id, string colName, DataType dataType,
int defWidth, bool defActive, bool autosize = false,
string format = null, NumberFormatInfo numFmt = null)
{
Expand Down Expand Up @@ -103,15 +103,25 @@ public void Clear()

public void AddColumn(LSID colName, int defWidth, bool autosize = false)
{
AddColumn(colName, DataType.dtString, defWidth, true, autosize, null, null);
AddColumn(LangMan.LS(colName), DataType.dtString, defWidth, true, autosize, null, null);
}

public void AddColumn(LSID colName, DataType dataType, int defWidth, bool defActive, bool autosize = false)
{
AddColumn(LangMan.LS(colName), dataType, defWidth, defActive, autosize, null, null);
}

public void AddColumn(string colName, DataType dataType, int defWidth, bool defActive, bool autosize = false)
{
AddColumn(colName, dataType, defWidth, defActive, autosize, null, null);
}

public void AddColumn(LSID colName, DataType dataType, int defWidth, bool defActive, bool autosize, string format, NumberFormatInfo nfi)
{
AddColumn(LangMan.LS(colName), dataType, defWidth, defActive, autosize, format, nfi);
}

public void AddColumn(string colName, DataType dataType, int defWidth, bool defActive, bool autosize, string format, NumberFormatInfo nfi)
{
fLastId += 1;
fColumns.Add(new ListColumn((byte)fLastId, colName, dataType, defWidth, defActive, autosize, format, nfi));
Expand Down
14 changes: 3 additions & 11 deletions projects/GKCore/GKCore/Lists/ListSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected virtual void UpdateColumnsMap()
int num = fListColumns.Count;
for (int i = 0; i < num; i++) {
ListColumn cs = fListColumns.OrderedColumns[i];
AddColumn(LangMan.LS(cs.ColName), cs.CurWidth, false, cs.Id, 0);
AddColumn(cs.ColName, cs.CurWidth, false, cs.Id, 0);
}
}

Expand All @@ -169,20 +169,12 @@ public void UpdateColumns(IListView listView)

public string GetColumnName(int columnId)
{
if (columnId >= 0 && columnId < fListColumns.Count) {
return LangMan.LS(fListColumns[columnId].ColName);
}

return "<?>";
return (columnId >= 0 && columnId < fListColumns.Count) ? fListColumns[columnId].ColName : "<?>";
}

public DataType GetColumnDataType(int columnId)
{
if (columnId >= 0 && columnId < fListColumns.Count) {
return fListColumns[columnId].DataType;
}

return DataType.dtString;
return (columnId >= 0 && columnId < fListColumns.Count) ? fListColumns[columnId].DataType : DataType.dtString;
}

public virtual void ChangeColumnWidth(int colIndex, int colWidth)
Expand Down
6 changes: 6 additions & 0 deletions projects/GKCore/GKCore/Lists/LocationListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum ColumnType
{
ctXRefNum,
ctName,
ctExt,
ctLati,
ctLong,
ctChangeDate
Expand All @@ -51,6 +52,7 @@ public static ListColumns<GDMLocationRecord> CreateLocationListColumns()

result.AddColumn(LSID.NumberSym, DataType.dtInteger, 50, true);
result.AddColumn(LSID.Title, DataType.dtString, 300, true, true);
result.AddColumn("Ext", DataType.dtString, 60, true, true);
result.AddColumn(LSID.Latitude, DataType.dtFloat, 120, true, false, GEDCOMUtils.CoordFormat, GEDCOMUtils.CoordNumberFormatInfo);
result.AddColumn(LSID.Longitude, DataType.dtFloat, 120, true, false, GEDCOMUtils.CoordFormat, GEDCOMUtils.CoordNumberFormatInfo);
result.AddColumn(LSID.Changed, DataType.dtDateTime, 150, true);
Expand Down Expand Up @@ -118,6 +120,10 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV
result = fFetchedRec.GetNameByDate(null, ATDEnumeration.fLtS, true);
break;

case ColumnType.ctExt:
result = (fFetchedRec.Names.Count > 1 || fFetchedRec.TopLevels.Count > 0) ? " ✔ " : string.Empty;
break;

case ColumnType.ctLati:
result = fFetchedRec.Map.Lati;
break;
Expand Down
6 changes: 6 additions & 0 deletions projects/GKCore/GKCore/Options/GlobalOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public StringList EventFilters

public bool ExtendedLocations { get; set; }

public bool EL_AbbreviatedNames { get; set; }

public StringList FARPatterns
{
get { return fFARPatterns; }
Expand Down Expand Up @@ -418,7 +420,9 @@ public void ResetDefaults_Specials()
InfoPansOverallSize = -1;
KeepInfoPansOverallSize = false;
ExtendedKinships = false;

ExtendedLocations = false;
EL_AbbreviatedNames = true;
}

public void Assign(IOptions source)
Expand Down Expand Up @@ -829,6 +833,7 @@ public void LoadFromFile(IniFile ini)
FilesOverwriteWarn = ini.ReadBool("Common", "FilesOverwriteWarn", true);
ExtendedKinships = ini.ReadBool("Common", "ExtendedKinships", false);
ExtendedLocations = ini.ReadBool("Common", "ExtendedLocations", false);
EL_AbbreviatedNames = ini.ReadBool("Common", "EL_AbbreviatedNames", true);

UseSurnamesInPersonSelectionFilter = ini.ReadBool("Common", "UseSurnamesInPersonSelectionFilter", false);
UseBirthDatesInPersonSelectionFilter = ini.ReadBool("Common", "UseBirthDatesInPersonSelectionFilter", false);
Expand Down Expand Up @@ -977,6 +982,7 @@ public void SaveToFile(IniFile ini)
ini.WriteBool("Common", "FilesOverwriteWarn", FilesOverwriteWarn);
ini.WriteBool("Common", "ExtendedKinships", ExtendedKinships);
ini.WriteBool("Common", "ExtendedLocations", ExtendedLocations);
ini.WriteBool("Common", "EL_AbbreviatedNames", EL_AbbreviatedNames);

ini.WriteBool("Common", "UseSurnamesInPersonSelectionFilter", UseSurnamesInPersonSelectionFilter);
ini.WriteBool("Common", "UseBirthDatesInPersonSelectionFilter", UseBirthDatesInPersonSelectionFilter);
Expand Down
2 changes: 1 addition & 1 deletion projects/GKTests/GKCore/ListsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void Test_GDMDateItem_Common()
[Test]
public void Test_ListColumn()
{
var colStatic = new ListColumn(0, 0, DataType.dtString, 0, true);
var colStatic = new ListColumn(0, "", DataType.dtString, 0, true);
Assert.IsNotNull(colStatic);
Assert.AreEqual(0, colStatic.Order);
Assert.AreEqual(false, colStatic.CurActive);
Expand Down
Loading

0 comments on commit 082bc73

Please sign in to comment.