mu: calculate thread subjects
Calculate the thread subject, that is, the subject of the (sub)thread _or_ empty if it's the same as the previous subject. This is for the UI feature of _not_ showing the subject when it's just repeating from the previous.
This commit is contained in:
@ -91,11 +91,10 @@ struct QueryMatch {
|
||||
// (ignoring prefixes such as Re:)
|
||||
//
|
||||
// otherwise, it is empty.
|
||||
std::string subject;
|
||||
std::string thread_subject; /**< the thread subject for this message */
|
||||
std::string subject; /**< subject for this message */
|
||||
size_t thread_level{}; /**< The thread level */
|
||||
std::string thread_path; /**< The hex-numerial path in the thread, ie. '00:01:0a' */
|
||||
std::string thread_date{}; /**< date of newest message in thread */
|
||||
std::string thread_date; /**< date of newest message in thread */
|
||||
|
||||
bool operator<(const QueryMatch& rhs) const {
|
||||
return date_key < rhs.date_key;
|
||||
|
||||
@ -394,12 +394,21 @@ update_container (Container& container, bool descending,
|
||||
if (!container.children.empty())
|
||||
qmatch.flags |= QueryMatch::Flags::HasChild;
|
||||
|
||||
// calculate the "thread-subject", which is for UI
|
||||
// purposes (future use)
|
||||
// see whether this message has the has the thread
|
||||
// subject, ie.. the first message in this thread with the
|
||||
// given subject.
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Root) ||
|
||||
//qmatch.has_flag(QueryMatch::Flags::Orphan) ||
|
||||
prev_subject.empty() ||
|
||||
(qmatch.subject.find(prev_subject) > 5))
|
||||
qmatch.flags |= QueryMatch::Flags::ThreadSubject;
|
||||
|
||||
// g_debug ("%c%c: '%s' vs '%s'",
|
||||
// any_of(qmatch.flags & QueryMatch::Flags::Root) ? 'r' : 'c',
|
||||
// any_of(qmatch.flags & QueryMatch::Flags::ThreadSubject) ? 'y' : 'n',
|
||||
// qmatch.subject.c_str(),
|
||||
// prev_subject.c_str());
|
||||
|
||||
if (descending && container.parent) {
|
||||
// trick xapian by giving it "inverse" sorting key so our
|
||||
// ascending-date sorted threads stay in that order
|
||||
@ -422,13 +431,16 @@ update_containers (Containers& children, bool descending, ThreadPath& tpath,
|
||||
size_t seg_size)
|
||||
{
|
||||
size_t idx{0};
|
||||
std::string last_subject;
|
||||
|
||||
for (auto&& c: children) {
|
||||
tpath.emplace_back(idx++);
|
||||
|
||||
if (c->query_match)
|
||||
update_container(*c, descending, tpath, seg_size);
|
||||
|
||||
if (c->query_match) {
|
||||
update_container(*c, descending, tpath, seg_size,
|
||||
last_subject);
|
||||
last_subject = c->query_match->subject;
|
||||
}
|
||||
update_containers(c->children, descending, tpath, seg_size);
|
||||
tpath.pop_back();
|
||||
}
|
||||
|
||||
@ -146,21 +146,21 @@ add_thread_info (Sexp::List& items, const QueryMatch& qmatch)
|
||||
info.add_prop(":date-tstamp", Sexp::make_list(std::move(dlist)));
|
||||
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Root))
|
||||
info.add_prop( ":root", symbol_t());
|
||||
info.add_prop(":root", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Related))
|
||||
info.add_prop( ":related", symbol_t());
|
||||
info.add_prop(":related", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::First))
|
||||
info.add_prop( ":first-child", symbol_t());
|
||||
info.add_prop(":first-child", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Last))
|
||||
info.add_prop( ":last-child", symbol_t());
|
||||
info.add_prop(":last-child", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Orphan))
|
||||
info.add_prop( ":orphan", symbol_t());
|
||||
info.add_prop(":orphan", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::Duplicate))
|
||||
info.add_prop( ":duplicate", symbol_t());
|
||||
info.add_prop(":duplicate", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::HasChild))
|
||||
info.add_prop( ":has-child", symbol_t());
|
||||
info.add_prop(":has-child", symbol_t());
|
||||
if (qmatch.has_flag(QueryMatch::Flags::ThreadSubject))
|
||||
info.add_prop( ":thread_subject", symbol_t());
|
||||
info.add_prop(":thread-subject", symbol_t());
|
||||
|
||||
items.add_prop(":thread", Sexp::make_list(std::move(info)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user