Searching by character tags honors category selection now
This commit is contained in:
parent
75b2758797
commit
4ce3213b1a
@ -555,7 +555,7 @@ wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
|
||||
// Search by tags: Get tags with given names. Then, get characters of found tags.
|
||||
std::map<ZRCola::tagid_t, unsigned __int16> hits_tag;
|
||||
if (!app->m_tn_db.Search(m_search.c_str(), m_parent->m_locale, hits_tag, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
if (!app->m_ct_db.Search(hits_tag, hits, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
if (!app->m_ct_db.Search(hits_tag, app->m_chr_db, m_cats, hits, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -185,11 +185,13 @@ namespace ZRCola {
|
||||
/// Search for characters by tags
|
||||
///
|
||||
/// \param[in ] tags Search tags
|
||||
/// \param[in ] ch_db Character database
|
||||
/// \param[in ] cats Set of categories from \p ch_db, character must be a part of
|
||||
/// \param[inout] hits (character, count) map to append hits to
|
||||
/// \param[in ] fn_abort Pointer to function to periodically test for search cancellation
|
||||
/// \param[in ] cookie Cookie for \p fn_abort call
|
||||
///
|
||||
bool Search(_In_ const std::map<tagid_t, unsigned __int16> &tags, _Inout_ std::map<wchar_t, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
|
||||
bool Search(_In_ const std::map<tagid_t, unsigned __int16> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &tags, _Inout_ std::map<wchar_t, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const
|
||||
bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const
|
||||
{
|
||||
for (auto tag = tags.cbegin(), tag_end = tags.cend(); tag != tag_end; ++tag) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
@ -32,6 +32,7 @@ bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &t
|
||||
for (size_t i = start; i < end; i++) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
const chrtag &ct = idxTag[i];
|
||||
if (cats.find(ch_db.GetCharCat(ct.chr)) != cats.end()) {
|
||||
auto idx = hits.find(ct.chr);
|
||||
if (idx == hits.end()) {
|
||||
// New character.
|
||||
@ -43,6 +44,7 @@ bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user