mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Make Browser root nodes use "_*" uniformly
This commit is contained in:
parent
51de0fdcd1
commit
c5faf39d7c
3 changed files with 12 additions and 11 deletions
|
@ -711,12 +711,12 @@ class SidebarTreeView(QTreeView):
|
|||
collapse_key=Config.Bool.COLLAPSE_TAGS,
|
||||
type=SidebarItemType.TAG_ROOT,
|
||||
)
|
||||
root.search_node = SearchNode(negated=SearchNode(tag="none"))
|
||||
root.search_node = SearchNode(tag="_*")
|
||||
root.add_simple(
|
||||
name=tr.browsing_sidebar_untagged(),
|
||||
icon=icon,
|
||||
type=SidebarItemType.TAG_NONE,
|
||||
search_node=SearchNode(tag="none"),
|
||||
search_node=SearchNode(negated=SearchNode(tag="_*")),
|
||||
)
|
||||
|
||||
render(root, tree.children)
|
||||
|
@ -763,7 +763,7 @@ class SidebarTreeView(QTreeView):
|
|||
collapse_key=Config.Bool.COLLAPSE_DECKS,
|
||||
type=SidebarItemType.DECK_ROOT,
|
||||
)
|
||||
root.search_node = SearchNode(deck="*")
|
||||
root.search_node = SearchNode(deck="_*")
|
||||
current = root.add_simple(
|
||||
name=tr.browsing_current_deck(),
|
||||
icon=icon,
|
||||
|
@ -786,6 +786,7 @@ class SidebarTreeView(QTreeView):
|
|||
collapse_key=Config.Bool.COLLAPSE_NOTETYPES,
|
||||
type=SidebarItemType.NOTETYPE_ROOT,
|
||||
)
|
||||
root.search_node = SearchNode(note="_*")
|
||||
|
||||
for nt in sorted(self.col.models.all(), key=lambda nt: nt["name"].lower()):
|
||||
item = SidebarItem(
|
||||
|
|
|
@ -23,11 +23,7 @@ impl TryFrom<pb::SearchNode> for Node {
|
|||
Ok(if let Some(filter) = msg.filter {
|
||||
match filter {
|
||||
Filter::Tag(s) => Node::Search(SearchNode::Tag(escape_anki_wildcards(&s))),
|
||||
Filter::Deck(s) => Node::Search(SearchNode::Deck(if s == "*" {
|
||||
s
|
||||
} else {
|
||||
escape_anki_wildcards(&s)
|
||||
})),
|
||||
Filter::Deck(s) => Node::Search(SearchNode::Deck(escape_anki_wildcards(&s))),
|
||||
Filter::Note(s) => Node::Search(SearchNode::Notetype(escape_anki_wildcards(&s))),
|
||||
Filter::Template(u) => {
|
||||
Node::Search(SearchNode::CardTemplate(TemplateKind::Ordinal(u as u16)))
|
||||
|
|
|
@ -399,10 +399,14 @@ pub(crate) fn to_text(txt: &str) -> Cow<str> {
|
|||
|
||||
/// Escape Anki wildcards and the backslash for escaping them: \*_
|
||||
pub(crate) fn escape_anki_wildcards(txt: &str) -> String {
|
||||
lazy_static! {
|
||||
static ref RE: Regex = Regex::new(r"[\\*_]").unwrap();
|
||||
if txt == "_*" {
|
||||
txt.to_string()
|
||||
} else {
|
||||
lazy_static! {
|
||||
static ref RE: Regex = Regex::new(r"[\\*_]").unwrap();
|
||||
}
|
||||
RE.replace_all(&txt, r"\$0").into()
|
||||
}
|
||||
RE.replace_all(&txt, r"\$0").into()
|
||||
}
|
||||
|
||||
/// Compare text with a possible glob, folding case.
|
||||
|
|
Loading…
Reference in a new issue