Remove protobuf filters whole_col and current_deck

This commit is contained in:
RumovZ 2021-01-31 11:12:49 +01:00
parent 5d810dd799
commit 13c6921da1
4 changed files with 57 additions and 55 deletions

View file

@ -609,7 +609,7 @@ class Browser(QMainWindow):
tr(TR.BROWSING_SEARCH_BAR_HINT)
)
self.form.searchEdit.addItems(self.mw.pm.profile["searchHistory"])
self.search_for(self.col.build_search_string(SearchTerm(current_deck=True)), "")
self.search_for(self.col.build_search_string(SearchTerm(deck="current")), "")
self.form.searchEdit.setFocus()
# search triggered by user

View file

@ -462,14 +462,14 @@ class SidebarTreeView(QTreeView):
item = SidebarItem(
tr(TR.BROWSING_WHOLE_COLLECTION),
":/icons/collection.svg",
self._filter_func(SearchTerm(whole_collection=True)),
self._filter_func(),
item_type=SidebarItemType.COLLECTION,
)
root.addChild(item)
item = SidebarItem(
tr(TR.BROWSING_CURRENT_DECK),
":/icons/deck.svg",
self._filter_func(SearchTerm(current_deck=True)),
self._filter_func(SearchTerm(deck="current")),
item_type=SidebarItemType.CURRENT_DECK,
)
root.addChild(item)

View file

@ -811,11 +811,9 @@ message SearchTerm {
Rated rated = 8;
uint32 added_in_days = 9;
int32 due_in_days = 10;
bool whole_collection = 11;
bool current_deck = 12;
Flag flag = 13;
CardState card_state = 14;
IdList nids = 15;
Flag flag = 11;
CardState card_state = 12;
IdList nids = 13;
}
}

View file

@ -294,7 +294,8 @@ impl From<pb::SearchTerm> for Node<'_> {
fn from(msg: pb::SearchTerm) -> Self {
use pb::search_term::Filter;
use pb::search_term::Flag;
match msg.filter.unwrap_or(Filter::WholeCollection(true)) {
if let Some(filter) = msg.filter {
match filter {
Filter::Tag(s) => Node::Search(SearchNode::Tag(
escape_anki_wildcards(&s).into_owned().into(),
)),
@ -308,7 +309,9 @@ impl From<pb::SearchTerm> for Node<'_> {
Node::Search(SearchNode::CardTemplate(TemplateKind::Ordinal(u as u16)))
}
Filter::Nid(nid) => Node::Search(SearchNode::NoteIDs(nid.to_string().into())),
Filter::Nids(nids) => Node::Search(SearchNode::NoteIDs(nids.into_id_string().into())),
Filter::Nids(nids) => {
Node::Search(SearchNode::NoteIDs(nids.into_id_string().into()))
}
Filter::Dupe(dupe) => Node::Search(SearchNode::Duplicates {
note_type_id: dupe.notetype_id.into(),
text: dupe.first_field.into(),
@ -327,8 +330,6 @@ impl From<pb::SearchTerm> for Node<'_> {
operator: "<=".to_string(),
kind: PropertyKind::Due(i),
}),
Filter::WholeCollection(_) => Node::Search(SearchNode::WholeCollection),
Filter::CurrentDeck(_) => Node::Search(SearchNode::Deck("current".into())),
Filter::CardState(state) => Node::Search(SearchNode::State(
pb::search_term::CardState::from_i32(state)
.unwrap_or_default()
@ -343,6 +344,9 @@ impl From<pb::SearchTerm> for Node<'_> {
Flag::Blue => Node::Search(SearchNode::Flag(4)),
},
}
} else {
Node::Search(SearchNode::WholeCollection)
}
}
}