Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Oct 23, 2024
1 parent acc65ad commit 852d81b
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 45 deletions.
1 change: 1 addition & 0 deletions clean.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@echo off

del .\bin\* /s /q
for /d %%p in (.\bin\*) do rd "%%p" /s /q
Expand Down
1 change: 1 addition & 0 deletions clean_appdata.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@echo off

for /d %%p in (.\appdata\*) do rd "%%p" /s /q
del .\appdata\GEDKeeper2.log
Expand Down
4 changes: 3 additions & 1 deletion projects/GKCore/GKCore/Controllers/BaseWinController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public void ChangeListItem(IListView sender)
ShowRecordInfo(rec);
}

public void SelectSummaryLink(string linkName)
public void SelectSummaryLink(IHyperView sender, string linkName)
{
if (linkName.StartsWith(GKData.INFO_HTTP_PREFIX)) {
GKUtils.LoadExtFile(linkName);
Expand All @@ -385,6 +385,8 @@ public void SelectSummaryLink(string linkName)
ApplyFilter(GDMRecordType.rtIndividual, listMan);
fView.ShowRecordsTab(GDMRecordType.rtIndividual);
}
} else if (linkName.StartsWith(GKData.INFO_HREF_EXPAND_ASSO)) {
GKUtils.ExpandExtInfo(fContext, sender, linkName);
} else {
SelectRecordByXRef(linkName);
}
Expand Down
4 changes: 3 additions & 1 deletion projects/GKCore/GKCore/Controllers/PartialViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void ChangeListItem(IListView sender)
ShowRecordInfo(rec);
}

public void SelectSummaryLink(string linkName)
public void SelectSummaryLink(IHyperView sender, string linkName)
{
if (linkName.StartsWith(GKData.INFO_HTTP_PREFIX)) {
GKUtils.LoadExtFile(linkName);
Expand All @@ -195,6 +195,8 @@ public void SelectSummaryLink(string linkName)
iFilter.SourceRef = rec.XRef;
ApplyFilter(GDMRecordType.rtIndividual, listMan);
}
} else if (linkName.StartsWith(GKData.INFO_HREF_EXPAND_ASSO)) {
GKUtils.ExpandExtInfo(fBase.Context, sender, linkName);
} else {
SelectRecordByXRef(linkName);
}
Expand Down
52 changes: 37 additions & 15 deletions projects/GKCore/GKCore/Controllers/PersonsFilterDlgController.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 All @@ -19,6 +19,7 @@
*/

using System;
using BSLib;
using GDModel;
using GKCore.Design;
using GKCore.Design.Controls;
Expand All @@ -42,6 +43,30 @@ public PersonsFilterDlgController(IPersonsFilterDlg view, IRecordsListModel list
fListMan = (IndividualListModel)listMan;
}

public void RemoveFilter(IComboBox sender)
{
if (sender == null) return;

GlobalOptions options = GlobalOptions.Instance;

if (sender == fView.NameCombo) {
GKUtils.RemoveFilter(sender.Text, options.NameFilters);
UpdateFiltersCombo(sender, options.NameFilters);
}

if (sender == fView.ResidenceCombo) {
GKUtils.RemoveFilter(sender.Text, options.ResidenceFilters);
UpdateFiltersCombo(sender, options.ResidenceFilters);
}

if (sender == fView.EventValCombo) {
GKUtils.RemoveFilter(sender.Text, options.EventFilters);
UpdateFiltersCombo(sender, options.EventFilters);
}

sender.Text = "*";
}

public override bool Accept()
{
try {
Expand Down Expand Up @@ -116,25 +141,22 @@ public override bool Accept()
}
}

private void UpdateFiltersCombo(IComboBox comboBox, StringList filters)
{
comboBox.Clear();
comboBox.Add("*");
comboBox.AddStrings(filters);
comboBox.ReadOnly = false;
}

public override void UpdateView()
{
IndividualListFilter iFilter = (IndividualListFilter)fListMan.Filter;
GlobalOptions options = GlobalOptions.Instance;

fView.NameCombo.Clear();
fView.NameCombo.Add("*");
fView.NameCombo.AddStrings(options.NameFilters);
fView.NameCombo.ReadOnly = false;

fView.ResidenceCombo.Clear();
fView.ResidenceCombo.Add("*");
fView.ResidenceCombo.AddStrings(options.ResidenceFilters);
fView.ResidenceCombo.ReadOnly = false;

fView.EventValCombo.Clear();
fView.EventValCombo.Add("*");
fView.EventValCombo.AddStrings(options.EventFilters);
fView.EventValCombo.ReadOnly = false;
UpdateFiltersCombo(fView.NameCombo, options.NameFilters);
UpdateFiltersCombo(fView.ResidenceCombo, options.ResidenceFilters);
UpdateFiltersCombo(fView.EventValCombo, options.EventFilters);

int lifeSel;
if (iFilter.FilterLifeMode != FilterLifeMode.lmTimeLocked) {
Expand Down
2 changes: 1 addition & 1 deletion projects/GKCore/GKCore/Cultures/RussianCulture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override string GetMarriedSurname(string husbSurname)
char lastSym = res[res.Length - 1];
var end2 = Morpher.Right(res, 2);

if (!"иа их ых ко".Contains(end2)) {
if (!"иа их ых ко ич".Contains(end2)) {
if (CONSONANTS.IndexOf(lastSym) >= 0) {
res = res + "а";
} else if (res.EndsWith("кий")) {
Expand Down
7 changes: 4 additions & 3 deletions projects/GKCore/GKCore/GKData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ public static class GKData
public const string INFO_HTTP_PREFIX = "http";
public const string INFO_HREF_VIEW = "view_";
public const string INFO_HREF_FILTER_INDI = "filter_indi_by_";
public const string INFO_HREF_EXPAND_ASSO = "expand_asso_";

#if OS_LINUX || OS_FREEBSD
#if OS_LINUX || OS_FREEBSD
public const string DEF_FONT = "Noto Sans";
#else
#else
public const string DEF_FONT = "Tahoma";
#endif
#endif

public const string CHECK_MARK = "";
public const string CROSS_MARK = "";
Expand Down
45 changes: 41 additions & 4 deletions projects/GKCore/GKCore/GKUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using GDModel.Providers.GEDCOM;
using GKCore.Calendar;
using GKCore.Cultures;
using GKCore.Design.Controls;
using GKCore.Import;
using GKCore.Interfaces;
using GKCore.Lists;
Expand Down Expand Up @@ -178,6 +179,14 @@ public static void SaveFilter(string flt, StringList filters)
if (flt != "" && flt != "*" && filters.IndexOf(flt) < 0) filters.Add(flt);
}

public static void RemoveFilter(string flt, StringList filters)
{
if (filters == null) return;

int idx = filters.IndexOf(flt);
if (idx >= 0) filters.Delete(idx);
}

public static StringList GetLocationLinks(GDMTree tree, GDMLocationRecord locRec)
{
var linksList = new StringList();
Expand Down Expand Up @@ -2102,12 +2111,38 @@ private static void ShowLink(GDMTree tree, GDMRecord aSubject, StringList aToLis
aToList.Add(" " + prefix + GenRecordLink(tree, aRec, true) + suffix);
}

private static void ShowPersonExtInfo(GDMTree tree, GDMIndividualRecord iRec, StringList summary)
public static int FindLinkStr(StringList list, string link)
{
if (list != null) {
for (int i = 0, num = list.Count; i < num; i++) {
if (list[i].Contains(link)) {
return i;
}
}
}
return -1;
}

public static void ExpandExtInfo(IBaseContext context, IHyperView sender, string linkName)
{
string xref = linkName.Remove(0, GKData.INFO_HREF_EXPAND_ASSO.Length);
var iRec = context.Tree.FindXRef<GDMIndividualRecord>(xref);
if (iRec is GDMIndividualRecord) {
int lineIdx = GKUtils.FindLinkStr(sender.Lines, linkName);
var strList = new StringList();
GKUtils.ShowPersonExtInfo(context.Tree, iRec, strList, false);
sender.Lines.AddStrings(strList);
sender.Lines.Delete(lineIdx);
}
}

public static void ShowPersonExtInfo(GDMTree tree, GDMIndividualRecord iRec, StringList summary, bool checkOpt = true)
{
if (tree == null || iRec == null || summary == null) return;

if (!GlobalOptions.Instance.ShowIndiAssociations) return;
if (checkOpt && !GlobalOptions.Instance.ShowIndiAssociations) return;

bool first = true;
summary.Add("");
int num = tree.RecordsCount;
for (int i = 0; i < num; i++) {
Expand All @@ -2117,7 +2152,6 @@ private static void ShowPersonExtInfo(GDMTree tree, GDMIndividualRecord iRec, St
GDMIndividualRecord ir = (GDMIndividualRecord)rec;
if (!ir.HasAssociations) continue;

bool first = true;
for (int k = 0, cnt = ir.Associations.Count; k < cnt; k++) {
GDMAssociation asso = ir.Associations[k];

Expand All @@ -2126,7 +2160,7 @@ private static void ShowPersonExtInfo(GDMTree tree, GDMIndividualRecord iRec, St
summary.Add(LangMan.LS(LSID.Associations) + ":");
first = false;
}
summary.Add(" " + HyperLink(ir.XRef, GetNameString(ir, true, false)));
summary.Add(" " + asso.Relation + ", " + HyperLink(ir.XRef, GetNameString(ir, true, false)));
}
}
}
Expand Down Expand Up @@ -2778,6 +2812,9 @@ public static void ShowPersonInfo(IBaseContext baseContext, GDMIndividualRecord
ShowPersonExtInfo(tree, iRec, summary);

ShowRFN(iRec, summary);

summary.Add("");
summary.Add(HyperLink(GKData.INFO_HREF_EXPAND_ASSO + iRec.XRef, "[ + ] " + LangMan.LS(LSID.Associations)));
}
} finally {
summary.EndUpdate();
Expand Down
2 changes: 1 addition & 1 deletion projects/GKv2/GEDKeeper2/GKUI/Forms/BaseWinSDI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private void tabsRecords_SelectedIndexChanged(object sender, EventArgs e)

private void mPersonSummaryLink(object sender, string linkName)
{
fController.SelectSummaryLink(linkName);
fController.SelectSummaryLink((IHyperView)sender, linkName);
}

private void miCopyContent_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion projects/GKv2/GEDKeeper2/GKUI/Forms/PartialView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void List_SelectedIndexChanged(object sender, EventArgs e)

private void mPersonSummaryLink(object sender, string linkName)
{
fController.SelectSummaryLink(linkName);
fController.SelectSummaryLink((IHyperView)sender, linkName);
}

private void miCopyContent_Click(object sender, EventArgs e)
Expand Down

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

21 changes: 15 additions & 6 deletions projects/GKv2/GEDKeeper2/GKUI/Forms/PersonsFilterDlg.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 All @@ -19,6 +19,7 @@
*/

using System;
using System.Windows.Forms;
using GKCore.Controllers;
using GKCore.Design.Controls;
using GKCore.Design.Views;
Expand Down Expand Up @@ -54,17 +55,17 @@ ICheckBox IPersonsFilterDlg.OnlyPatriarchsCheck

IComboBox IPersonsFilterDlg.EventValCombo
{
get { return GetControlHandler<IComboBox>(cmbEventVal); }
get { return GetControlHandler<IComboBox>(cmbEventVal); }
}

IComboBox IPersonsFilterDlg.ResidenceCombo
{
get { return GetControlHandler<IComboBox>(cmbResidence); }
get { return GetControlHandler<IComboBox>(cmbResidence); }
}

IComboBox IPersonsFilterDlg.NameCombo
{
get { return GetControlHandler<IComboBox>(txtName); }
get { return GetControlHandler<IComboBox>(txtName); }
}

void IPersonsFilterDlg.SetLifeRadio(int lifeSel)
Expand Down Expand Up @@ -136,9 +137,9 @@ public PersonsFilterDlg(IBaseWindow baseWin, IRecordsListModel listMan) : base(b
InitializeComponent();

// platform: in Mono tsSpecificFilter has 0 index, somehow
#if MONO
#if MONO
tabsFilters.Controls.SetChildIndex(pageSpecificFilter, 1);
#endif
#endif
tabsFilters.SelectedIndex = 1;

fPersonsFilterDlgController = new PersonsFilterDlgController(this, listMan);
Expand All @@ -161,5 +162,13 @@ public override void Reset()
base.Reset();
fPersonsFilterDlgController.UpdateView();
}

private void cmbFilter_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && e.Control) {
var combo = GetControlHandler<IComboBox>(sender);
fPersonsFilterDlgController.RemoveFilter(combo);
}
}
}
}
2 changes: 1 addition & 1 deletion projects/GKv3/GEDKeeper3/GKUI/Forms/BaseWinSDI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private void tabsRecords_SelectedIndexChanged(object sender, EventArgs e)

private void mPersonSummaryLink(object sender, string linkName)
{
fController.SelectSummaryLink(linkName);
fController.SelectSummaryLink((IHyperView)sender, linkName);
}

private void miCopyContent_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion projects/GKv3/GEDKeeper3/GKUI/Forms/PartialView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void List_SelectedIndexChanged(object sender, EventArgs e)

private void mPersonSummaryLink(object sender, string linkName)
{
fController.SelectSummaryLink(linkName);
fController.SelectSummaryLink((IHyperView)sender, linkName);
}

private void miCopyContent_Click(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit 852d81b

Please sign in to comment.