Skip to content

Commit

Permalink
Merge pull request #274 from Ordisoftware/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ordisoftware committed Aug 27, 2022
2 parents 0d094e7 + b1b8e88 commit 21b53ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
20 changes: 9 additions & 11 deletions Project/Source/Forms/Boxes/SelectVersesByDateUpdatedForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void UpdateQuery(bool focusGrid = true)
BindingSource.DataSource = null;
// Create query
string filterTranslation = EditFilterVerse.Text;
bool filterOnTranslation = filterTranslation.Length == 0;
bool filterTranslationOff = filterTranslation.Length == 0;
bool partiallyTranslated = EditOnlyPartiallyTranslated.Checked;
bool onlyFull = EditOnlyFullyTranslated.Checked;
var query = from verse in ApplicationDatabase.Instance.Verses
Expand All @@ -236,8 +236,11 @@ private void UpdateQuery(bool focusGrid = true)
? verse.IsFullyTranslated
: partiallyTranslated
? verse.IsPartiallyTranslated
: verse.HasTranslation )
&& ( filterOnTranslation
: verse.HasTranslation
|| verse.Title.Length != 0
|| verse.Concept.Length != 0
|| verse.Comment.Length != 0 )
&& ( filterTranslationOff
|| verse.Title.RawContains(filterTranslation)
|| verse.Translation.RawContains(filterTranslation)
|| verse.Comment.RawContains(filterTranslation) )
Expand Down Expand Up @@ -265,21 +268,16 @@ private void UpdateQuery(bool focusGrid = true)
var dateEnd = EditDateEnd.Value.Date;
query = query.Where(v => v.DateModified.Date <= dateEnd);
}
// Create list
// Create list and update UI
var list = query.Take((int)EditDisplayCount.Value).ToList();
int countToDisplay = list.Count;
if ( countToDisplay == 0 )
{
ActionOK.Enabled = false;
}
else
ActionOK.Enabled = countToDisplay > 0;
if ( ActionOK.Enabled )
{
int index = 0;
foreach ( var item in list ) item.Id = ++index;
BindingSource.DataSource = list;
ActionOK.Enabled = countToDisplay > 0;
}
// Update UI
Text = AppTranslations.SelectVersesByDateUpdatedFormTitle.GetLang(countToDisplay, countAll);
if ( focusGrid ) ActiveControl = DataGridView;
}
Expand Down
28 changes: 20 additions & 8 deletions Project/Source/Forms/MainForm/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ private void CreateFilterDataSource()
{
string filterVerse = EditFilterVerse.Text;
books = books.Where(b => b.Chapters.Any(c => c.Verses.Any(v => v.Title.RawContains(filterVerse)
|| v.Concept.RawContains(filterVerse)
|| v.Translation.RawContains(filterVerse)
|| v.Comment.RawContains(filterVerse))));
}
Expand Down Expand Up @@ -1851,12 +1852,19 @@ private void SelectFilterBook_SelectedIndexChanged(object sender, EventArgs e)
if ( EditFilterVersesTranslated.Checked )
chapters = chapters.Where(c => c.Verses.Any(v => v.HasTranslation));
if ( EditFilterChapter.Text.Length != 0 )
chapters = chapters.Where(c => c.Title.RawContains(EditFilterChapter.Text)
|| c.Memo.RawContains(EditFilterChapter.Text));
{
string filterChapter = EditFilterChapter.Text;
chapters = chapters.Where(c => c.Title.RawContains(filterChapter)
|| c.Memo.RawContains(filterChapter));
}
if ( EditFilterVerse.Text.Length != 0 )
chapters = chapters.Where(c => c.Verses.Any(v => v.Title.RawContains(EditFilterVerse.Text)
|| v.Translation.RawContains(EditFilterVerse.Text)
|| v.Comment.RawContains(EditFilterVerse.Text)));
{
string filterVerse = EditFilterVerse.Text;
chapters = chapters.Where(c => c.Verses.Any(v => v.Title.RawContains(filterVerse)
|| v.Concept.RawContains(filterVerse)
|| v.Translation.RawContains(filterVerse)
|| v.Comment.RawContains(filterVerse)));
}
var list = chapters.ToList();
SelectFilterChapter.DataSource = new BindingList<ChapterRow>(list);
if ( list.Count == 0 )
Expand All @@ -1880,9 +1888,13 @@ private void SelectFilterChapter_SelectedIndexChanged(object sender, EventArgs e
if ( EditFilterVersesTranslated.Checked )
verses = verses.Where(v => v.HasTranslation);
if ( EditFilterVerse.Text.Length != 0 )
verses = verses.Where(v => v.Title.RawContains(EditFilterVerse.Text)
|| v.Translation.RawContains(EditFilterVerse.Text)
|| v.Comment.RawContains(EditFilterVerse.Text));
{
string filterVerse = EditFilterVerse.Text;
verses = verses.Where(v => v.Title.RawContains(filterVerse)
|| v.Concept.RawContains(filterVerse)
|| v.Translation.RawContains(filterVerse)
|| v.Comment.RawContains(filterVerse));
}
SelectFilterVerse.DataSource = new BindingList<VerseRow>(verses.ToList());
}

Expand Down

0 comments on commit 21b53ce

Please sign in to comment.