Skip to content

Commit

Permalink
Minor improvements (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Mar 1, 2024
1 parent e7f357d commit 62b82d4
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 65 deletions.
2 changes: 1 addition & 1 deletion locales/Hungarian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,4 @@
942={0} fotó hozzáadva innen: {1}.
943=Legfelső szintű linkek
944=Eltávolítja a legfelső szintű linket?
945=Help is not available for this language. An English help will be shown.
945=Ezen a nyelven nem érhető el súgó. Megjelenik egy angol nyelvű súgó.
2 changes: 1 addition & 1 deletion locales/Japanese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,4 @@
942={1} から {0} の写真を追加しました。
943=トップレベルのリンク
944=トップレベルのリンクを削除しますか?
945=Help is not available for this language. An English help will be shown.
945=この言語ではヘルプを利用できません。英語のヘルプが表示されます。
2 changes: 1 addition & 1 deletion locales/german.lng
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,4 @@
942={0} Fotografien von {1} hinzugefügt.
943=Verweise auf oberster Ebene
944=Verweis auf oberster Ebene löschen?
945=Help is not available for this language. An English help will be shown.
945=Hilfe ist für diese Sprache nicht verfügbar. Es wird eine englische Hilfe angezeigt.
15 changes: 7 additions & 8 deletions projects/GKCore/GDModel/GDMDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

using System;
using System.Collections.Generic;
using BSLib;
using GDModel.Providers.GEDCOM;
using GKCore;
Expand Down Expand Up @@ -537,8 +536,8 @@ public string GetDisplayString(DateFormat format, bool includeBC = false, bool s
if (year > 0 || month > 0 || day > 0) {
switch (format) {
case DateFormat.dfDD_MM_YYYY:
parts[pIdx++] = day > 0 ? ConvertHelper.AdjustNumber(day, 2) + "." : "__.";
parts[pIdx++] = month > 0 ? ConvertHelper.AdjustNumber(month, 2) + "." : "__.";
parts[pIdx++] = day > 0 ? day.ToString("D2", null) + "." : "__.";
parts[pIdx++] = month > 0 ? month.ToString("D2", null) + "." : "__.";
parts[pIdx++] = year > 0 ? year.ToString().PadLeft(4, '_') : "____";
if (includeBC && ybc) {
parts[pIdx++] = " BC";
Expand All @@ -550,8 +549,8 @@ public string GetDisplayString(DateFormat format, bool includeBC = false, bool s
parts[pIdx++] = "BC ";
}
parts[pIdx++] = year > 0 ? year.ToString().PadLeft(4, '_') + "." : "____.";
parts[pIdx++] = month > 0 ? ConvertHelper.AdjustNumber(month, 2) + "." : "__.";
parts[pIdx++] = day > 0 ? ConvertHelper.AdjustNumber(day, 2) : "__";
parts[pIdx++] = month > 0 ? month.ToString("D2", null) + "." : "__.";
parts[pIdx++] = day > 0 ? day.ToString("D2", null) : "__";
break;

case DateFormat.dfYYYY:
Expand All @@ -563,10 +562,10 @@ public string GetDisplayString(DateFormat format, bool includeBC = false, bool s
}
break;
}
}

if (showCalendar) {
parts[pIdx] = GKUtils.GetCalendarSign(fCalendar);
if (showCalendar) {
parts[pIdx] = GKUtils.GetCalendarSign(fCalendar);
}
}

return string.Concat(parts);
Expand Down
32 changes: 19 additions & 13 deletions projects/GKCore/GDModel/GDMDatePeriod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ protected override string GetStringValue()
bool frEmpty = fDateFrom.IsEmpty();
bool toEmpty = fDateTo.IsEmpty();

if (!frEmpty && !toEmpty) {
result = string.Concat("FROM ", fDateFrom.StringValue, " TO ", fDateTo.StringValue);
} else if (!frEmpty) {
result = "FROM " + fDateFrom.StringValue;
if (!frEmpty) {
if (!toEmpty) {
result = string.Concat("FROM ", fDateFrom.StringValue, " TO ", fDateTo.StringValue);
} else {
result = "FROM " + fDateFrom.StringValue;
}
} else if (!toEmpty) {
result = "TO " + fDateTo.StringValue;
} else {
Expand Down Expand Up @@ -139,10 +141,12 @@ public override UDN GetUDN()
bool frEmpty = fDateFrom.IsEmpty();
bool toEmpty = fDateTo.IsEmpty();

if (!frEmpty && !toEmpty) {
result = UDN.CreateBetween(fDateFrom.GetUDN(), fDateTo.GetUDN(), false);
} else if (!frEmpty) {
result = UDN.CreateAfter(fDateFrom.GetUDN());
if (!frEmpty) {
if (!toEmpty) {
result = UDN.CreateBetween(fDateFrom.GetUDN(), fDateTo.GetUDN(), false);
} else {
result = UDN.CreateAfter(fDateFrom.GetUDN());
}
} else if (!toEmpty) {
result = UDN.CreateBefore(fDateTo.GetUDN());
} else {
Expand All @@ -159,11 +163,13 @@ public override string GetDisplayStringExt(DateFormat format, bool sign, bool sh
bool frEmpty = fDateFrom.IsEmpty();
bool toEmpty = fDateTo.IsEmpty();

if (!frEmpty && !toEmpty) {
result = fDateFrom.GetDisplayString(format, true, showCalendar) + " - " + fDateTo.GetDisplayString(format, true, showCalendar);
} else if (!frEmpty) {
result = fDateFrom.GetDisplayString(format, true, showCalendar);
if (sign) result += " >";
if (!frEmpty) {
if (!toEmpty) {
result = fDateFrom.GetDisplayString(format, true, showCalendar) + " - " + fDateTo.GetDisplayString(format, true, showCalendar);
} else {
result = fDateFrom.GetDisplayString(format, true, showCalendar);
if (sign) result += " >";
}
} else if (!toEmpty) {
result = fDateTo.GetDisplayString(format, true, showCalendar);
if (sign) result = "< " + result;
Expand Down
50 changes: 28 additions & 22 deletions projects/GKCore/GDModel/GDMDateRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ protected override string GetStringValue()
bool aftEmpty = fDateAfter.IsEmpty();
bool befEmpty = fDateBefore.IsEmpty();

if (!aftEmpty && !befEmpty) {
result = string.Concat(GEDCOMConsts.GEDCOMDateRangeArray[2], " ", fDateAfter.StringValue, " ", GEDCOMConsts.GEDCOMDateRangeArray[3], " ", fDateBefore.StringValue);
} else if (!aftEmpty) {
result = GEDCOMConsts.GEDCOMDateRangeArray[0] + " " + fDateAfter.StringValue;
if (!aftEmpty) {
if (!befEmpty) {
result = string.Concat(GEDCOMConsts.GEDCOMDateRangeArray[2], " ", fDateAfter.StringValue, " ", GEDCOMConsts.GEDCOMDateRangeArray[3], " ", fDateBefore.StringValue);
} else {
result = GEDCOMConsts.GEDCOMDateRangeArray[0] + " " + fDateAfter.StringValue;
}
} else if (!befEmpty) {
result = GEDCOMConsts.GEDCOMDateRangeArray[1] + " " + fDateBefore.StringValue;
} else {
Expand Down Expand Up @@ -137,10 +139,12 @@ public override UDN GetUDN()
bool aftEmpty = fDateAfter.IsEmpty();
bool befEmpty = fDateBefore.IsEmpty();

if (!aftEmpty && !befEmpty) {
result = UDN.CreateBetween(fDateAfter.GetUDN(), fDateBefore.GetUDN(), false);
} else if (!aftEmpty) {
result = UDN.CreateAfter(fDateAfter.GetUDN());
if (!aftEmpty) {
if (!befEmpty) {
result = UDN.CreateBetween(fDateAfter.GetUDN(), fDateBefore.GetUDN(), false);
} else {
result = UDN.CreateAfter(fDateAfter.GetUDN());
}
} else if (!befEmpty) {
result = UDN.CreateBefore(fDateBefore.GetUDN());
} else {
Expand All @@ -157,25 +161,27 @@ public override string GetDisplayStringExt(DateFormat format, bool sign, bool sh
bool aftEmpty = fDateAfter.IsEmpty();
bool befEmpty = fDateBefore.IsEmpty();

if (!aftEmpty && !befEmpty) {
var dateAfter = fDateAfter.GetDisplayString(format, true, showCalendar);
var dateBefore = fDateBefore.GetDisplayString(format, true, showCalendar);

if (shorten) {
// FIXME: bad algorithm!
string dtA = dateAfter.Replace("__.__.", "");
string dtB = dateBefore.Replace("__.__.", "");
if (dtA.Length == 4 && dtB.Length == 4 && dtB.StartsWith(dtA.Substring(0, 2))) {
result = dtA + "/" + dtB.Substring(2);
if (!aftEmpty) {
if (!befEmpty) {
var dateAfter = fDateAfter.GetDisplayString(format, true, showCalendar);
var dateBefore = fDateBefore.GetDisplayString(format, true, showCalendar);

if (shorten) {
// FIXME: bad algorithm!
string dtA = dateAfter.Replace("__.__.", "");
string dtB = dateBefore.Replace("__.__.", "");
if (dtA.Length == 4 && dtB.Length == 4 && dtB.StartsWith(dtA.Substring(0, 2))) {
result = dtA + "/" + dtB.Substring(2);
} else {
result = dateAfter + " - " + dateBefore;
}
} else {
result = dateAfter + " - " + dateBefore;
}
} else {
result = dateAfter + " - " + dateBefore;
result = fDateAfter.GetDisplayString(format, true, showCalendar);
if (sign) result += " >";
}
} else if (!aftEmpty) {
result = fDateAfter.GetDisplayString(format, true, showCalendar);
if (sign) result += " >";
} else if (!befEmpty) {
result = fDateBefore.GetDisplayString(format, true, showCalendar);
if (sign) result = "< " + result;
Expand Down
6 changes: 3 additions & 3 deletions projects/GKCore/GDModel/GDMDateValue.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 @@ -60,12 +60,12 @@ internal override void TrimExcess()

protected override string GetStringValue()
{
return ((fValue == null) ? "" : fValue.StringValue);
return (fValue == null) ? "" : fValue.StringValue;
}

public override DateTime GetDateTime()
{
DateTime result = ((fValue == null) ? new DateTime(0) : fValue.GetDateTime());
DateTime result = (fValue == null) ? new DateTime(0) : fValue.GetDateTime();
return result;
}

Expand Down
6 changes: 4 additions & 2 deletions projects/GKCore/GKCore/GKUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,9 @@ public static string GetFmtSurname(GDMSex iSex, GDMPersonalName personalName, st

string result;

WomanSurnameFormat wsFmt = GlobalOptions.Instance.WomanSurnameFormat;
var globOpts = GlobalOptions.Instance;

WomanSurnameFormat wsFmt = globOpts.WomanSurnameFormat;
if (iSex == GDMSex.svFemale && wsFmt != WomanSurnameFormat.wsfNotExtend) {
string marriedSurname = personalName.MarriedName;
switch (wsFmt) {
Expand Down Expand Up @@ -3503,7 +3505,7 @@ public static string GetFmtSurname(GDMSex iSex, GDMPersonalName personalName, st
result = defSurname;
}

if (GlobalOptions.Instance.SurnameInCapitals) {
if (globOpts.SurnameInCapitals) {
result = result.ToUpper();
}

Expand Down
3 changes: 2 additions & 1 deletion projects/GKCore/GKCore/Interfaces/IListFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2017 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -81,6 +81,7 @@ public interface IListColumns
ListColumn this[int index] { get; }
IList<ListColumn> OrderedColumns { get; }

void Clear();
void CopyTo(IListColumns target);
bool MoveColumn(int idx, bool up);
void ResetDefaults();
Expand Down
3 changes: 2 additions & 1 deletion projects/GKCore/GKCore/Interfaces/IListSource.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 @@ -104,6 +104,7 @@ public interface IListSource
int TotalCount { get; }
QuickFilterParams QuickFilter { get; }

void Clear();
void AddCondition(byte columnId, ConditionKind condition, string value);
void ChangeColumnWidth(int colIndex, int colWidth);
string[] CreateFields();
Expand Down
10 changes: 6 additions & 4 deletions projects/GKCore/GKCore/Lists/IndividualListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,15 @@ private object GetNameValueEx(int colSubtype)
if (colSubtype == -1) {
result = GKUtils.GetNameString(fFetchedRec, false);
} else {
NameFormat defNameFormat = (SimpleList) ? NameFormat.nfFNP : GlobalOptions.Instance.DefNameFormat;
var globOpts = GlobalOptions.Instance;

NameFormat defNameFormat = (SimpleList) ? NameFormat.nfFNP : globOpts.DefNameFormat;
NamePartsRet parts;
GDMLanguageID defLang = fBaseContext.DefaultLanguage;

switch (defNameFormat) {
case NameFormat.nfFNP:
result = GKUtils.GetNameString(fFetchedRec, GlobalOptions.Instance.SurnameFirstInOrder, false, defLang);
result = GKUtils.GetNameString(fFetchedRec, globOpts.SurnameFirstInOrder, false, defLang);
break;

case NameFormat.nfF_NP:
Expand Down Expand Up @@ -451,7 +453,7 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV
break;

case ColumnType.ctPatriarch:
result = ((fFetchedRec.Patriarch) ? "*" : " ");
result = fFetchedRec.Patriarch ? "*" : " ";
break;

case ColumnType.ctName:
Expand Down Expand Up @@ -545,7 +547,7 @@ protected override object GetColumnValueEx(int colType, int colSubtype, bool isV
break;

case ColumnType.ctBookmark:
result = ((fFetchedRec.Bookmark) ? "*" : " ");
result = fFetchedRec.Bookmark ? "*" : " ";
break;

case ColumnType.ctTitle:
Expand Down
8 changes: 7 additions & 1 deletion projects/GKCore/GKCore/Lists/ListColumns.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 @@ -95,6 +95,12 @@ public ListColumns()
ResetDefaults();
}

public void Clear()
{
fColumns.Clear();
fOrderedColumns.Clear();
}

public void AddColumn(LSID colName, int defWidth, bool autosize = false)
{
AddColumn(colName, DataType.dtString, defWidth, true, autosize, null, null);
Expand Down
23 changes: 20 additions & 3 deletions projects/GKCore/GKCore/Lists/ListSource.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 @@ -117,6 +117,23 @@ protected ListSource(IBaseContext baseContext, ListColumns<T> defaultListColumns
CreateFilter();
}

public void Clear()
{
fContentList.Clear();
fTotalCount = 0;

fMask = string.Empty;
fRegexMask = null;
fSimpleMask = string.Empty;
fExternalFilter = null;
fFilter.Clear();

fFetchedRec = null;

fColumnsMap.Clear();
fListColumns.Clear();
}

#region Columns

protected virtual void UpdateColumnsMap()
Expand Down Expand Up @@ -514,8 +531,8 @@ protected static string ConvertColumnValue(object val, ListColumn cs)
return ((double)val).ToString(cs.Format, cs.NumFmt);

case DataType.dtDateTime:
DateTime dtx = ((DateTime)val);
return ((dtx.Ticks == 0) ? "" : dtx.ToString("yyyy.MM.dd HH:mm:ss", null));
DateTime dtx = (DateTime)val;
return (dtx.Ticks == 0) ? "" : dtx.ToString("yyyy.MM.dd HH:mm:ss", null);

case DataType.dtGEDCOMDate:
return val.ToString();
Expand Down
Loading

0 comments on commit 62b82d4

Please sign in to comment.