Skip to content

Commit

Permalink
Added a non-standard date attribute to source records (fix #524)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Jan 26, 2024
1 parent 4c85869 commit a00c07c
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 34 deletions.
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>??.??.2024 [v2.29.0 &amp; v3.5.0]</b><ul>
<li>Added a non-standard date attribute to source records (for clarifying and sorting censuses, parish books, confession books and personal documents).
<li>Fixed missing empty lines in notes.
<li>Fixed an error in attaching unknown (and webp) multimedia files.
<li>Added columns for signs of the presence of multimedia, notes and sources to the lists of events/facts.
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>??.??.2024 [v2.29.0 &amp; v3.5.0]</b><ul>
<li>Добавлен нестандартный атрибут даты в записи источников (для уточнения и сортировки переписей, метрических книг, ревизских сказок, исповедных книг и личных документов).
<li>Исправлены отсутствующие пустые строки в заметках.
<li>Исправлена ошибка присоединения неизвестных (и webp) мультимедиа файлов.
<li>Добавлены столбцы признаков наличия мультимедиа, заметок и источников в списки событий/фактов.
Expand Down
27 changes: 25 additions & 2 deletions projects/GKCore/GDModel/GDMSourceRecord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2021 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand All @@ -27,6 +27,7 @@ namespace GDModel
public sealed class GDMSourceRecord : GDMRecord
{
private GDMSourceData fData;
private readonly GDMDateValue fDate;
private GDMTextTag fOriginator;
private GDMTextTag fPublication;
private GDMList<GDMRepositoryCitation> fRepositoryCitations;
Expand All @@ -40,6 +41,11 @@ public GDMSourceData Data
get { return fData; }
}

public GDMDateValue Date
{
get { return fDate; }
}

public GDMTextTag Originator
{
get { return fOriginator; }
Expand Down Expand Up @@ -83,6 +89,9 @@ public GDMSourceRecord(GDMTree tree) : base(tree)
fShortTitle = string.Empty;
fText = new GDMTextTag((int)GEDCOMTagType.TEXT);
fTitle = new GDMTextTag((int)GEDCOMTagType.TITL);

fDate = new GDMDateValue();
fDate.SetName((int)GEDCOMTagType._DATE);
}

protected override void Dispose(bool disposing)
Expand All @@ -94,6 +103,8 @@ protected override void Dispose(bool disposing)
fRepositoryCitations.Dispose();
fText.Dispose();
fTitle.Dispose();

fDate.Dispose();
}
base.Dispose(disposing);
}
Expand All @@ -108,6 +119,8 @@ internal override void TrimExcess()
fRepositoryCitations.TrimExcess();
fText.TrimExcess();
fTitle.TrimExcess();

fDate.TrimExcess();
}

public override void Assign(GDMTag source)
Expand All @@ -125,6 +138,8 @@ public override void Assign(GDMTag source)
fText.Assign(otherSource.fText);
fTitle.Assign(otherSource.fTitle);
AssignList(otherSource.fRepositoryCitations, fRepositoryCitations);

fDate.Assign(otherSource.fDate);
}

public override void Clear()
Expand All @@ -138,13 +153,16 @@ public override void Clear()
fRepositoryCitations.Clear();
fText.Clear();
fTitle.Clear();

fDate.Clear();
}

public override bool IsEmpty()
{
return base.IsEmpty() && fData.IsEmpty() && fOriginator.IsEmpty() && fPublication.IsEmpty()
&& string.IsNullOrEmpty(fShortTitle) && fText.IsEmpty() && fTitle.IsEmpty()
&& (fRepositoryCitations.Count == 0);
&& (fRepositoryCitations.Count == 0)
&& fDate.IsEmpty();
}

public override void MoveTo(GDMRecord targetRecord)
Expand Down Expand Up @@ -174,12 +192,17 @@ public override void MoveTo(GDMRecord targetRecord)
GDMRepositoryCitation obj = fRepositoryCitations.Extract(0);
targetSource.RepositoryCitations.Add(obj);
}

if (targetSource.Date.IsEmpty() && !fDate.IsEmpty()) {
targetSource.Date.Assign(fDate);
}
}

public override void ReplaceXRefs(GDMXRefReplacer map)
{
base.ReplaceXRefs(map);
fRepositoryCitations.ReplaceXRefs(map);
fDate.ReplaceXRefs(map);
}


Expand Down
8 changes: 7 additions & 1 deletion projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMProvider.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 @@ -814,6 +814,9 @@ private StackTuple AddSourceRecordTag(GDMTag owner, int tagLevel, int tagId, str
curTag = sourRec.Title;
curTag.ParseString(tagValue);
addHandler = AddTextTag;
} else if (tagType == GEDCOMTagType._DATE) {
curTag = sourRec.Date;
GEDCOMUtils.ParseDateValue(fTree, sourRec.Date, tagValue);
} else {
return AddRecordTag(owner, tagLevel, tagId, tagValue);
}
Expand All @@ -836,6 +839,8 @@ private static void WriteSourceRecord(StreamWriter stream, int level, GDMTag tag
WriteSourceData(stream, level, sourRec.Data);
WriteText(stream, level, sourRec.Originator);
WriteText(stream, level, sourRec.Text);

WriteBaseTag(stream, level, sourRec.Date);
}


Expand Down Expand Up @@ -2674,6 +2679,7 @@ static GEDCOMProvider()
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._AWARD, GEDCOMTagName._AWARD, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._BGRO, GEDCOMTagName._BGRO, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._CENN, GEDCOMTagName._CENN, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._DATE, GEDCOMTagName._DATE, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._ELEC, GEDCOMTagName._ELEC, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._EXCM, GEDCOMTagName._EXCM, true);
GEDCOMTagsTable.RegisterTag(GEDCOMTagType._EYES, GEDCOMTagName._EYES, true);
Expand Down
4 changes: 3 additions & 1 deletion projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMTagType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2019 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -175,6 +175,7 @@ public enum GEDCOMTagType
_BGRO, // [MyFamilyTree] INDI.ATTR
_BOOKMARK, // [GK]
_CENN, // Census Name [BKW6]
_DATE, // Date value in non-standard use (source records) [GK]
_ELEC, // Election [???] INDI.ATTR
_EXCM, // Excommunication [FTM] INDI.ATTR
_EYES, // [Gen] INDI.ATTR
Expand Down Expand Up @@ -367,6 +368,7 @@ public static class GEDCOMTagName
public const string _AWARD = "_AWARD";
public const string _BGRO = "_BGRO"; // [MyFamilyTree]
public const string _CENN = "_CENN"; // Census Name [BKW6]
public const string _DATE = "_DATE"; // Date value in non-standard use (source records) [GK]
public const string _ELEC = "_ELEC"; // Election [???]
public const string _EXCM = "_EXCM"; // Excommunication [FTM]
public const string _EYES = "_EYES"; // [Gen]
Expand Down
15 changes: 14 additions & 1 deletion projects/GKCore/GKCore/Controllers/SourceEditDlgController.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 @@ -75,6 +75,16 @@ public override bool Accept()
fSourceRecord.Text.Clear();
fSourceRecord.SetTextArray(fView.Text.Lines);

try {
GDMCustomDate dt = fView.Date.Date;
if (dt == null) throw new ArgumentNullException("dt");

fSourceRecord.Date.ParseString(dt.StringValue);
} catch (Exception ex) {
AppHost.StdDialogs.ShowError(LangMan.LS(LSID.DateInvalid));
throw ex;
}

fLocalUndoman.Commit();

fBase.NotifyRecord(fSourceRecord, RecordAction.raEdit);
Expand All @@ -94,6 +104,8 @@ public override void UpdateView()
fView.Publication.Text = fSourceRecord.Publication.Lines.Text.Trim();
fView.Text.Text = fSourceRecord.Text.Lines.Text.Trim();

fView.Date.Date = fSourceRecord.Date.Value;

fView.RepositoriesList.ListModel.DataOwner = fSourceRecord;
fView.NotesList.ListModel.DataOwner = fSourceRecord;
fView.MediaList.ListModel.DataOwner = fSourceRecord;
Expand All @@ -109,6 +121,7 @@ public override void SetLocale()
GetControl<ILabel>("lblAuthor").Text = LangMan.LS(LSID.Author);
GetControl<ILabel>("lblTitle").Text = LangMan.LS(LSID.Title);
GetControl<ILabel>("lblPublication").Text = LangMan.LS(LSID.Publication);
GetControl<ILabel>("lblDate").Text = LangMan.LS(LSID.Date);
GetControl<ITabPage>("pageCommon").Text = LangMan.LS(LSID.Common);
GetControl<ITabPage>("pageText").Text = LangMan.LS(LSID.Text);
GetControl<ITabPage>("pageRepositories").Text = LangMan.LS(LSID.RPRepositories);
Expand Down
4 changes: 3 additions & 1 deletion projects/GKCore/GKCore/Design/Views/ISourceEditDlg.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 @@ -38,5 +38,7 @@ public interface ISourceEditDlg : ICommonDialog, IBaseEditor
ITextBox DescTitle { get; }
ITextBox Publication { get; }
ITextBox Text { get; }

IDateControl Date { get; }
}
}
18 changes: 15 additions & 3 deletions projects/GKCore/GKCore/Lists/SourceListModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -37,9 +37,11 @@ public sealed class SourceListModel : RecordsListModel<GDMSourceRecord>
public enum ColumnType
{
ctXRefNum,
ctShortName,
ctShortTitle,
ctDate,
ctAuthor,
ctTitle,
//ctPublication,
ctRepositories,
ctChangeDate
}
Expand All @@ -56,8 +58,10 @@ public static ListColumns<GDMSourceRecord> CreateSourceListColumns()

result.AddColumn(LSID.NumberSym, DataType.dtInteger, 50, true);
result.AddColumn(LSID.ShortTitle, DataType.dtString, 120, true, true);
result.AddColumn(LSID.Date, 80, false);
result.AddColumn(LSID.Author, DataType.dtString, 200, true);
result.AddColumn(LSID.Title, DataType.dtString, 200, true);
//result.AddColumn(LSID.Publication, DataType.dtString, 200, true);
result.AddColumn(LSID.RPRepositories, DataType.dtString, 200, true);
result.AddColumn(LSID.Changed, DataType.dtDateTime, 150, true);

Expand All @@ -82,10 +86,14 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV
result = fFetchedRec.GetId();
break;

case ColumnType.ctShortName:
case ColumnType.ctShortTitle:
result = fFetchedRec.ShortTitle.Trim();
break;

case ColumnType.ctDate:
result = new GDMDateItem(fFetchedRec.Date.Value);
break;

case ColumnType.ctAuthor:
result = fFetchedRec.Originator.Lines.Text.Trim();
break;
Expand All @@ -94,6 +102,10 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV
result = fFetchedRec.Title.Lines.Text.Trim();
break;

//case ColumnType.ctPublication:
// result = fFetchedRec.Publication.Lines.Text.Trim();
// break;

case ColumnType.ctRepositories:
result = GKUtils.GetSourceRepositories(fBaseContext.Tree, fFetchedRec);
break;
Expand Down
Loading

0 comments on commit a00c07c

Please sign in to comment.