_basename to basename, since it's not private in use
This commit is contained in:
parent
5315b717c0
commit
bda2935de1
@ -126,7 +126,7 @@ class DeckManager:
|
|||||||
# child of an existing deck then it needs to be renamed
|
# child of an existing deck then it needs to be renamed
|
||||||
deck = self.get(did)
|
deck = self.get(did)
|
||||||
if "::" in deck["name"]:
|
if "::" in deck["name"]:
|
||||||
base = self._basename(deck["name"])
|
base = self.basename(deck["name"])
|
||||||
suffix = ""
|
suffix = ""
|
||||||
while True:
|
while True:
|
||||||
# find an unused name
|
# find an unused name
|
||||||
@ -261,14 +261,14 @@ class DeckManager:
|
|||||||
|
|
||||||
if ontoDeckDid is None or ontoDeckDid == "":
|
if ontoDeckDid is None or ontoDeckDid == "":
|
||||||
if len(self.path(draggedDeckName)) > 1:
|
if len(self.path(draggedDeckName)) > 1:
|
||||||
self.rename(draggedDeck, self._basename(draggedDeckName))
|
self.rename(draggedDeck, self.basename(draggedDeckName))
|
||||||
elif self._canDragAndDrop(draggedDeckName, ontoDeckName):
|
elif self._canDragAndDrop(draggedDeckName, ontoDeckName):
|
||||||
draggedDeck = self.get(draggedDeckDid)
|
draggedDeck = self.get(draggedDeckDid)
|
||||||
draggedDeckName = draggedDeck["name"]
|
draggedDeckName = draggedDeck["name"]
|
||||||
ontoDeckName = self.get(ontoDeckDid)["name"]
|
ontoDeckName = self.get(ontoDeckDid)["name"]
|
||||||
assert ontoDeckName.strip()
|
assert ontoDeckName.strip()
|
||||||
self.rename(
|
self.rename(
|
||||||
draggedDeck, ontoDeckName + "::" + self._basename(draggedDeckName)
|
draggedDeck, ontoDeckName + "::" + self.basename(draggedDeckName)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _canDragAndDrop(self, draggedDeckName: str, ontoDeckName: str) -> bool:
|
def _canDragAndDrop(self, draggedDeckName: str, ontoDeckName: str) -> bool:
|
||||||
@ -283,7 +283,7 @@ class DeckManager:
|
|||||||
|
|
||||||
def _isParent(self, parentDeckName: str, childDeckName: str) -> Any:
|
def _isParent(self, parentDeckName: str, childDeckName: str) -> Any:
|
||||||
return self.path(childDeckName) == self.path(parentDeckName) + [
|
return self.path(childDeckName) == self.path(parentDeckName) + [
|
||||||
self._basename(childDeckName)
|
self.basename(childDeckName)
|
||||||
]
|
]
|
||||||
|
|
||||||
def _isAncestor(self, ancestorDeckName: str, descendantDeckName: str) -> Any:
|
def _isAncestor(self, ancestorDeckName: str, descendantDeckName: str) -> Any:
|
||||||
@ -297,9 +297,11 @@ class DeckManager:
|
|||||||
_path = path
|
_path = path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _basename(cls, name: str) -> Any:
|
def basename(cls, name: str) -> Any:
|
||||||
return cls.path(name)[-1]
|
return cls.path(name)[-1]
|
||||||
|
|
||||||
|
_basename = basename
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def key(cls, deck: Dict[str, Any]) -> List[str]:
|
def key(cls, deck: Dict[str, Any]) -> List[str]:
|
||||||
return cls.path(deck["name"])
|
return cls.path(deck["name"])
|
||||||
|
@ -154,7 +154,7 @@ def fields_for_rendering(
|
|||||||
fields["Tags"] = note.stringTags().strip()
|
fields["Tags"] = note.stringTags().strip()
|
||||||
fields["Type"] = card.note_type()["name"]
|
fields["Type"] = card.note_type()["name"]
|
||||||
fields["Deck"] = col.decks.name(card.odid or card.did)
|
fields["Deck"] = col.decks.name(card.odid or card.did)
|
||||||
fields["Subdeck"] = DeckManager._basename(fields["Deck"])
|
fields["Subdeck"] = DeckManager.basename(fields["Deck"])
|
||||||
fields["Card"] = card.template()["name"]
|
fields["Card"] = card.template()["name"]
|
||||||
flag = card.userFlag()
|
flag = card.userFlag()
|
||||||
fields["CardFlag"] = flag and f"flag{flag}" or ""
|
fields["CardFlag"] = flag and f"flag{flag}" or ""
|
||||||
|
@ -1303,7 +1303,7 @@ QTableView {{ gridline-color: {grid} }}
|
|||||||
def addDecks(parent, decks):
|
def addDecks(parent, decks):
|
||||||
for head, did, rev, lrn, new, children in decks:
|
for head, did, rev, lrn, new, children in decks:
|
||||||
name = self.mw.col.decks.get(did)["name"]
|
name = self.mw.col.decks.get(did)["name"]
|
||||||
shortname = DeckManager._basename(name)
|
shortname = DeckManager.basename(name)
|
||||||
if children:
|
if children:
|
||||||
subm = parent.addMenu(shortname)
|
subm = parent.addMenu(shortname)
|
||||||
subm.addItem(_("Filter"), self._filterFunc("deck", name))
|
subm.addItem(_("Filter"), self._filterFunc("deck", name))
|
||||||
|
Loading…
Reference in New Issue
Block a user