if <c>...</c> in q/a format, limit display in card list to that

This commit is contained in:
Damien Elmes 2010-10-27 20:11:08 +09:00
parent f5a931bb07
commit 2329baa789

View file

@ -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("<br>", u" ")
s = s.replace("<br />", u" ")
s = s.replace("\n", u" ")
s = stripHTML(s)
s = re.sub("\[sound:[^]]+\]", "", s)
s = s.replace("&amp;", "&")
s = stripHTML(s)
s = s.strip()
return QVariant(s)
else:
return QVariant()
def limitContent(self, txt):
if "<c>" in txt:
matches = re.findall("(?s)<c>(.*?)</c>", txt)
return " ".join(matches)
else:
return txt
def headerData(self, section, orientation, role):
if orientation == Qt.Vertical:
return QVariant()