don't bother extracing graph libs from resources; they're provided in block

This commit is contained in:
Damien Elmes 2011-03-25 17:37:28 +09:00
parent f20d730f3c
commit c5a109dca0

View file

@ -63,12 +63,11 @@ class CardStats(object):
class PrintableReport(QDialog): class PrintableReport(QDialog):
def __init__(self, mw, type, title, func, css, extra): def __init__(self, mw, type, title, func, css):
self.mw = mw self.mw = mw
QDialog.__init__(self, mw) QDialog.__init__(self, mw)
restoreGeom(self, type) restoreGeom(self, type)
self.type = type self.type = type
self.extra = extra
self.setWindowTitle(title) self.setWindowTitle(title)
self.setModal(True) self.setModal(True)
self.mw.progress.start() self.mw.progress.start()
@ -100,8 +99,8 @@ class PrintableReport(QDialog):
tmpdir = tempfile.mkdtemp(prefix="anki") tmpdir = tempfile.mkdtemp(prefix="anki")
path = os.path.join(tmpdir, "report.html") path = os.path.join(tmpdir, "report.html")
open(path, "w").write(""" open(path, "w").write("""
<html><head><style>%s</style>%s</head><body>%s</body></html>""" % ( <html><head><style>%s</style></head><body>%s</body></html>""" % (
self.css, self.extra, self.report)) self.css, self.report))
QDesktopServices.openUrl(QUrl("file://" + path)) QDesktopServices.openUrl(QUrl("file://" + path))
# Deck stats # Deck stats
@ -133,17 +132,9 @@ h1 { font-size: 18px; border-bottom: 1px solid #000; margin-top: 1em;
.info {float:right; padding: 10px; max-width: 300px; border-radius: 5px; .info {float:right; padding: 10px; max-width: 300px; border-radius: 5px;
background: #ddd; font-size: 14px; } background: #ddd; font-size: 14px; }
""" """
buf = "<script>"
for n in ("jquery", "jquery.flot"):
f = QFile(":/%s.min.js" % n)
f.open(QIODevice.ReadOnly)
buf += f.readAll()
f.close()
buf += "</script>"
return PrintableReport( return PrintableReport(
mw, mw,
"graphs", "graphs",
_("Graphs"), _("Graphs"),
lambda: mw.deck.graphs().report(), lambda: mw.deck.graphs().report(),
css, css)
buf)