From 2329baa78997b0d3df87934626879b0b327bcb00 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 27 Oct 2010 20:11:08 +0900 Subject: [PATCH] if ... in q/a format, limit display in card list to that --- ankiqt/ui/cardlist.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 5f8c34392..55ba824c1 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -88,17 +88,24 @@ class DeckModel(QAbstractTableModel): # not cached yet self.updateCard(index) s = self.columns[index.column()][1](index) + s = self.limitContent(s) s = s.replace("
", u" ") s = s.replace("
", u" ") - s = s.replace("\n", u" ") - s = stripHTML(s) + s = s.replace("\n", u" ") s = re.sub("\[sound:[^]]+\]", "", s) - s = s.replace("&", "&") + s = stripHTML(s) s = s.strip() return QVariant(s) else: return QVariant() + def limitContent(self, txt): + if "" in txt: + matches = re.findall("(?s)(.*?)", txt) + return " ".join(matches) + else: + return txt + def headerData(self, section, orientation, role): if orientation == Qt.Vertical: return QVariant()