-
Notifications
You must be signed in to change notification settings - Fork 1
/
_More_Decks_Stats.py
746 lines (596 loc) · 25.1 KB
/
_More_Decks_Stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# -*- mode: Python ; coding: utf-8 -*-
# • More decks overview stats
# -- tested with Anki 2.0.44 under Windows 7 SP1
# https://ankiweb.net/shared/info/1841403427
# https://github.com/ankitest/anki-musthave-addons-by-ankitest
# -- tested with Anki 2.0.44 under Windows 7 SP1
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
# Copyright (c) 2017 Dmitry Mikheev, http://finpapa.ucoz.ru/index.html
# No support. Use it AS IS on your own risk.
"""
Do not forget about _('To Review')
"""
from __future__ import division
from __future__ import unicode_literals
# Based on Decks Total https://ankiweb.net/shared/info/1421528223
# https://github.com/b50/anki-deck-stats
# Author of original addon: Calumks <[email protected]>
import os
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import anki
import aqt
from aqt.utils import tooltip
# Get language class
lang = anki.lang.getLang()
# --------------------------
# -- Show learn count -- deck_overview_tweaks.py --
# Show_learn_count.py by ospalh
# Show the learn count in the deck browser, too.
# 3 numbers vs 2 by default
# New, Learn, Due vs Learn+Due and New
# Show count of unseen and suspended cards in deck browser.
# -- Unseen and buried counts --
# https://ankiweb.net/shared/info/161964983
# Show count of unseen and buried cards in deck browser.
PARM = {
'STUDY_BUTTON': False,
'GEAR_AT_END_OF_LINE': True,
'BUTTON_TITLES': True,
'MORE_OVERVIEW_STATS': 3,
'HIDE_BIG_NUMBER': 999,
'HIDE_BIG_NUMBERS': False,
'queueLimit': 50, # important
'reportLimit': 9999, # not less than in deck options
'': ''
}
# --------------------------
_Buried = _('Suspended+Buried').split('+')
_Buried = _Buried[1] if len(_Buried) == 2 else _('Buried')
_Buried = _Buried.capitalize()
_Suspended = _('<small>Sus-<br>pen-<br>ded </small>') \
if lang == 'en' else _('Suspended')
titles = {
'en': (
_("More Decks Stats"),
_("Activate") + " " + _("More Decks Stats"),
"%s, %s, %s, %s" % (_('New'), _('Learn'), _('Review'), _('Due')),
"%s, %s, %s" % (_('Unseen'), _('Suspended'), _Buried),
_('&Gear at the end of line'),
_('&Hide big numbers ( > %s )') % (PARM['HIDE_BIG_NUMBER']),
_('&Study Deck Button'),
# 7
_("&View"),
_('Unseen'),
_Suspended,
_Buried,
_('New'),
_('Learn'),
_('Review'),
_('Due'),
''),
# Please, do not delete English!
# You can add your own languages in this dictionary
'ru': (
'Больше статистики колод',
"Настраивать панель колод",
"%s, %s, %s, %s" % (_('New'), _('Learn'), _('Review'), _('Due')),
'&Невиданные, исключённые и отложенные',
'&Шестерёнка в конце строки',
'&Спрятать числа больше %d' % (PARM['HIDE_BIG_NUMBER']),
'&Кнопка Учить колоду',
# 7
"&Вид",
'Неви-<br>данные',
'Исклю-<br>чённые',
'Отло-<br>женные',
"Новые",
"Учить",
"Про-<br>верить",
"Пора",
''),
'': ''
}
try:
titles[lang]
except KeyError:
lang = 'en'
__addon__ = "'" + __name__.replace('_', ' ')
__version__ = "2.0.44a"
# --------------------------
if True:
# Replace _renderStats method
def renderStats(self, _old):
# Get due and new cards
new = 0
lrn = 0
due = 0
for tree in self.mw.col.sched.deckDueTree():
new += tree[4]
lrn += tree[3]
due += tree[2]
total = new + lrn + due
# Get studdied cards
cards, thetime = self.mw.col.db.first(
"""select count(), sum(time)/1000 from revlog where id > ?""",
(self.mw.col.sched.dayCutoff - 86400) * 1000)
cards = cards or 0
thetime = thetime or 0
speed = cards * 60 / max(1, thetime)
minutes = int(total / max(1, speed))
msgp1 = anki.lang.ngettext("%d card", "%d cards", cards) % cards
buf = "<div style='display:table;padding-top:1.5em;'>" \
+ "<div style='display:table-cell;'> " \
+ _old(self) + "<hr>" \
+ _("New Cards") \
+ ": <font color=#00a> %(d)s</font>" % dict(d=new) \
+ " " + _("Learn") \
+ ": <font color=#a00>%(c)s</font>" % dict(c=lrn) \
+ " <span style='white-space:nowrap;'>" + _("To Review") \
+ ": <font color=#0a0>%(c)s</font>" % dict(c=due) \
+ "</span>" \
+ " <br><span style='white-space:nowrap;'>" + _("Due") \
+ ": <b style=color:#aaa>%(c)s</b> " % dict(c=(lrn+due)) \
+ "</span> " \
+ " <span style='white-space:nowrap;'>" + _("Total") \
+ ": <b style=color:#888>%(c)s</b>" % dict(c=(total)) \
+ "</span></div>" \
+ "<div style='display:table-cell;vertical-align:middle;" \
+ "padding-left:2em;'>" \
+ "<span style='white-space:nowrap;'>" + _("Average") \
+ ":<br> " + _("%.01f cards/minute") % (speed) \
+ "</span><br><br>" \
+ _("More") + " " + ngettext(
"%s minute.", "%s minutes.", minutes) % (minutes) \
+ "</div></div>"
return buf
aqt.deckbrowser.DeckBrowser._renderStats = anki.hooks.wrap(
aqt.deckbrowser.DeckBrowser._renderStats, renderStats, 'around')
##
def on_musthave_study():
global PARM
PARM['STUDY_BUTTON'] = musthave_study_action.isChecked()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
def on_gear_at_end_of_line():
global PARM
PARM['GEAR_AT_END_OF_LINE'] = gear_at_end_of_line_action.isChecked()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
def on_hide_big_numbers():
global PARM
PARM['HIDE_BIG_NUMBERS'] = hide_big_numbers_action.isChecked()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
if aqt.mw.state == "overview":
aqt.mw.moveToState("overview")
def Unseen_and_buried_counts():
global PARM
if PARM['MORE_OVERVIEW_STATS'] == 0:
return
if PARM['MORE_OVERVIEW_STATS'] == 3:
PARM['MORE_OVERVIEW_STATS'] = 2
else:
PARM['MORE_OVERVIEW_STATS'] = 3
musthave_setup_menu()
initDeckBro()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
if aqt.mw.state == "overview":
aqt.mw.moveToState("overview")
def on_checkers():
global PARM
if checkers_action.isChecked():
PARM['MORE_OVERVIEW_STATS'] = 3
else:
PARM['MORE_OVERVIEW_STATS'] = 0
musthave_setup_menu()
initDeckBro()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
if aqt.mw.state == "overview":
aqt.mw.moveToState("overview")
def new_and_due_counts():
global PARM
if PARM['MORE_OVERVIEW_STATS'] == 0:
return
if PARM['MORE_OVERVIEW_STATS'] > 1:
PARM['MORE_OVERVIEW_STATS'] = 1
else:
PARM['MORE_OVERVIEW_STATS'] = 3
musthave_setup_menu()
initDeckBro()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
if aqt.mw.state == "overview":
aqt.mw.moveToState("overview")
##
aqt.mw.musthave_submenu = QMenu(titles[lang][0], aqt.mw)
checkers_action = QAction(titles[lang][1], aqt.mw)
aqt.mw.connect(checkers_action, SIGNAL("triggered()"), on_checkers)
checkers_action.setCheckable(True)
new_and_due_action = QAction(titles[lang][2], aqt.mw)
aqt.mw.connect(
new_and_due_action, SIGNAL("triggered()"), new_and_due_counts)
new_and_due_action.setCheckable(True)
unseen_and_suspended_action = QAction(titles[lang][3], aqt.mw)
aqt.mw.connect(unseen_and_suspended_action, SIGNAL(
"triggered()"), Unseen_and_buried_counts)
unseen_and_suspended_action.setCheckable(True)
gear_at_end_of_line_action = QAction(titles[lang][4], aqt.mw)
aqt.mw.connect(gear_at_end_of_line_action, SIGNAL(
"triggered()"), on_gear_at_end_of_line)
gear_at_end_of_line_action.setCheckable(True)
hide_big_numbers_action = QAction(titles[lang][5], aqt.mw)
aqt.mw.connect(hide_big_numbers_action, SIGNAL(
"triggered()"), on_hide_big_numbers)
hide_big_numbers_action.setCheckable(True)
musthave_study_action = QAction(titles[lang][6], aqt.mw)
aqt.mw.connect(
musthave_study_action, SIGNAL("triggered()"), on_musthave_study)
musthave_study_action.setCheckable(True)
try:
aqt.mw.addon_view_menu
except AttributeError:
aqt.mw.addon_view_menu = QMenu(titles[lang][7], aqt.mw)
aqt.mw.form.menubar.insertMenu(
aqt.mw.form.menuTools.menuAction(), aqt.mw.addon_view_menu)
mw_addon_view_menu_exists = hasattr(aqt.mw, 'addon_view_menu')
if mw_addon_view_menu_exists:
aqt.mw.addon_view_menu.addSeparator()
aqt.mw.addon_view_menu.addMenu(aqt.mw.musthave_submenu)
aqt.mw.musthave_submenu.addAction(checkers_action)
aqt.mw.musthave_submenu.addSeparator()
aqt.mw.musthave_submenu.addAction(new_and_due_action)
aqt.mw.musthave_submenu.addAction(unseen_and_suspended_action)
aqt.mw.musthave_submenu.addAction(gear_at_end_of_line_action)
aqt.mw.musthave_submenu.addAction(hide_big_numbers_action)
aqt.mw.musthave_submenu.addSeparator()
aqt.mw.musthave_submenu.addAction(musthave_study_action)
aqt.mw.musthave_submenu.addSeparator()
def musthave_setup_menu():
checkers_action.setChecked(PARM['MORE_OVERVIEW_STATS'] > 0)
unseen_and_suspended_action.setChecked(
PARM['MORE_OVERVIEW_STATS'] > 2)
unseen_and_suspended_action.setEnabled(
PARM['MORE_OVERVIEW_STATS'] > 1)
musthave_study_action.setChecked(PARM['STUDY_BUTTON'])
musthave_study_action.setEnabled(PARM['MORE_OVERVIEW_STATS'] > 0)
hide_big_numbers_action.setChecked(PARM['HIDE_BIG_NUMBERS'])
hide_big_numbers_action.setEnabled(PARM['MORE_OVERVIEW_STATS'] > 1)
new_and_due_action.setChecked(PARM['MORE_OVERVIEW_STATS'] > 1)
new_and_due_action.setEnabled(PARM['MORE_OVERVIEW_STATS'] > 0)
gear_at_end_of_line_action.setChecked(PARM['GEAR_AT_END_OF_LINE'])
gear_at_end_of_line_action.setEnabled(
PARM['MORE_OVERVIEW_STATS'] > 2)
musthave_setup_menu()
# _____ ------ ========== *********** ========== -------- ______
th_Unseen = u"<span style='color:#DA70D6;'>" + titles[lang][8] + "</span>"
th_Suspended = u"<span style='color:#c90;'>" + titles[lang][9] + "</span>"
th_Buried = u"<span style='color:#960;'>" + titles[lang][10] + "</span>"
# --------------------------
# Copyright © 2012–2014 Roland Sieker <[email protected]>
# Show_learn_count.py
# License: GNU AGPL, version 3 or later;
# http://www.gnu.org/licenses/agpl.html
"""
Anki-2 add-on to show the learn count in the deck browser proper way
"""
def my_studyDeck(self, did):
self.scrollPos = self.web.page().mainFrame().scrollPosition()
self.mw.col.decks.select(did)
self.mw.col.startTimebox()
self.mw.moveToState("review")
if self.mw.state == "overview":
# more_tool_bar_off()
tooltip(_("No cards are due yet."))
# Event handlers
# Monkey patching
def my_studyHandler(self, url):
if ":" in url:
(cmd, arg) = url.split(":")
else:
cmd = url
arg = ''
if cmd == "study":
my_studyDeck(self, arg)
aqt.deckbrowser.DeckBrowser._linkHandler = anki.hooks.wrap(
aqt.deckbrowser.DeckBrowser._linkHandler, my_studyHandler)
# --------------------------
def nonzeroColour(acnt, colour, did):
if not acnt:
colour = "silver"
achk = PARM['HIDE_BIG_NUMBERS'] and acnt > PARM['HIDE_BIG_NUMBER']
if achk:
cnt = "%s+" % (PARM['HIDE_BIG_NUMBER'])
else:
cnt = str(acnt)
return ("""<a href="study:{}"
style="text-decoration:none;cursor:pointer;color:{};"
onmouseover="this.style.textDecoration='underline';"
onmouseout="this.style.textDecoration='none';"
> {} </a>""".format(
did, colour, cnt) if did and acnt else
"""<span style="color:{};{}> {} </span>""".format(
colour,
(('%s" title="%s"' % (
('cursor:help;' if achk else ''),
(acnt if achk else '')))
if PARM['BUTTON_TITLES'] else '"'),
cnt)) if acnt > 0 else \
"""<span style="color:{};"> {} </span>""".format(
colour, cnt)
# --------------------------
def deck_browser_render_deck_tree(self, nodes, depth=0):
if not nodes:
return ""
if depth == 0:
buf = """\n<tr>\n<th colspan=3
style='padding-right:.25em;color:default;'>%s</th>""" \
% ("<div style = padding-bottom:.25em; " +
(" title = Профиль " if PARM['BUTTON_TITLES'] else "") +
">" + (aqt.mw.pm.name if len(aqt.mw.pm.profiles()) > 1 and
aqt.mw.pm.name else "") +
"</div><div style = font-weight:400;><i>" + _("Decks") +
":</i></div>" +
"</th>\n<td style='text-align:right;'>%s</td>" %
("<i>" + _("Cards") + ":</i>"
if PARM['MORE_OVERVIEW_STATS'] > 1 else ""))
if PARM['MORE_OVERVIEW_STATS'] > 1:
buf += """\n
<td class=count style='padding-right:.25em;color:#33f;width:4em;'>%s</td>\
<td class=count style='padding-right:.25em;color:#c33;width:4em;'>%s</td>\
<td class=count style='color:#090;padding-right:.25em;width:4em;'>%s</td>\
<td class=count style='color:#999;padding-right:1em;width:4em;'>%s</td>\
\n""" % (titles[lang][11], titles[lang][12],
titles[lang][13], titles[lang][14])
if PARM['MORE_OVERVIEW_STATS'] > 2:
if not PARM['GEAR_AT_END_OF_LINE']:
buf += "<td></td>"
buf += """\n
<td style="padding-right:.25em;text-align:right;width:4em !important;">%s</td>\
<td style="padding-right:.25em;color:#c90;text-align:right;width:3em;">%s</td>\
<td style="padding-right:.25em;color:#960;text-align:right;width:3em;">%s</td>\
""" % (th_Unseen, th_Suspended, th_Buried)
buf += "\n</tr>\n" + self._topLevelDragRow()
else:
buf = ""
for node in nodes:
buf += deck_browser_deck_row(self, node, depth, len(nodes))
if depth == 0:
buf += self._topLevelDragRow()
# Get due and new cards
due = 0
new = 0
lrn = 0
for tree in self.mw.col.sched.deckDueTree():
# due += tree[2] + tree[3]
due += tree[2]
lrn += tree[3]
new += tree[4]
if PARM['MORE_OVERVIEW_STATS'] > 1:
buf += """\n
<tr style="vertical-align:top;">\
<th style="color:gray;text-align:left;">%s</th>\
<th align=left>%s</th><th align=left>%s</th>\
<th style='color:gray;text-align:right;'>%s:</th>\
<th class=count style='width:4em;'>%s</th>\
<th class=count style='width:4em;'>%s</th>\
<th class=count style='color:gray;width:4em;'> + %s</th>\
<th class=count style='color:gray;width:4em;padding-right:1em;'
> = %s</th>\n""" % (
anki.lang.getLang(), _("Total"),
nonzeroColour(aqt.mw.col.cardCount(), "default", False),
nonzeroColour(new + lrn + due, "gray", False),
nonzeroColour(new, "#33f", False),
nonzeroColour(lrn, "#c33", False),
nonzeroColour(due, "#090", False),
nonzeroColour(lrn + due, "#999", False))
# options
if not PARM['GEAR_AT_END_OF_LINE'] and \
PARM['MORE_OVERVIEW_STATS'] > 2:
buf += "<td> </td>\n"
if PARM['MORE_OVERVIEW_STATS'] > 2:
unseen = self.mw.col.db.scalar(
"select count(*) from cards where queue=0")
suspended = self.mw.col.db.scalar(
"select count(*) from cards where queue = -1")
buried = self.mw.col.db.scalar(
"select count(*) from cards where queue = -2")
buf += """\
<td style="padding-right:.25em;width:4em !important;"\
align=right>%s </td>\
<td style="padding-right:.25em;width:3em;" align=right>%s </td>\
<td style="padding-right:.5em;width:3em;" align=right>%s </td>\
""" % (
nonzeroColour(unseen, "#DA70D6", False),
nonzeroColour(suspended, "#c90", False),
nonzeroColour(buried, "#960", False)) # "#555500"))
buf += "\n</tr>\n"
return buf
# --------------------------
def deck_browser_deck_row(self, node, depth, cnt):
name, did, due, lrn, new, children = node
deck = self.mw.col.decks.get(did)
if PARM['MORE_OVERVIEW_STATS'] > 2:
unseen = self.mw.col.db.scalar(
"select count(*) from cards where did = %i and queue=0" % did)
suspended = self.mw.col.db.scalar(
"select count(*) from cards where did = %i and queue = -1" % did)
buried = self.mw.col.db.scalar(
"select count(*) from cards where did = %i and queue = -2" % did)
if did == 1 and cnt > 1 and not children:
# if the default deck is empty, hide it
if not self.mw.col.db.scalar(
"select 1 from cards where did = 1"):
return ""
# parent toggled for collapsing
for parent in self.mw.col.decks.parents(did):
if parent['collapsed']:
buff = ""
return buff
prefix = "<big><b>−</b></big>"
if self.mw.col.decks.get(did)['collapsed']:
prefix = "<big><b>+</b></big>"
def indent():
return " " * 6 * depth
if did == self.mw.col.conf['curDeck']:
klass = 'deck current'
else:
klass = 'deck'
buf = "\n<tr class='%s' id='%d' " % (klass, did)
if PARM['BUTTON_TITLES']:
buf += (' title = " ' + _('Today') + ': %s "') % (new + lrn + due)
buf += '>'
# deck link
if children:
collapse = """<a class=collapse href=#
onclick='py.link("collapse:%d");return false;' \
style="padding-left:.5em;padding-right:.1em;margin-right:.2em; \
border:solid 1px transparent;border-radius:5px;display:inline-block;" \
onmouseover="this.style.border='solid 1px silver';" \
onmouseout="this.style.border='solid 1px transparent';" \
title="%s">%s</a>""" % (
did, (' title=" Свернуть/развернуть вложенные колоды "'
if lang == 'ru' else ' title=" ' +
_(' Collapse/Downfall ') + ' "')
if PARM['BUTTON_TITLES'] else '', prefix)
else:
collapse = "<span class=collapse></span>"
if deck['dyn']:
extraclass = "filtered"
else:
extraclass = ""
studydid = ('''onclick="py.link('study:%d');"''' %
did) if (new + lrn + due) > 0 else ""
cursorPointer = ('''cursor:pointer''') if (new + lrn + due) > 0 else ""
buf += """<td class=decktd colspan=4 %s style="%s;"
>%s%s<a class="deck %s" href=%s>%s</a></td>""" % (
studydid, cursorPointer, indent(), collapse, extraclass,
('''# onclick="py.link('open:%d');return false;"''' % did)
if (new + lrn + due) > 0 else ("open:%d" % did),
"<b>" + name + "</b>" if new + lrn + due > 0 else name)
if PARM['MORE_OVERVIEW_STATS'] > 1:
buf += """\n\
<td align=right %s style="%s;">%s</td>\
<td align=right %s style="%s;">%s</td>\
<td align=right %s style="%s;">%s</td>\
<td align=right %s style="%s;padding-right:1em;">%s</td>\
\n""" % (
studydid, cursorPointer, nonzeroColour(new, "#33f", did),
studydid, cursorPointer, nonzeroColour(lrn, "#c33", did),
studydid, cursorPointer, nonzeroColour(due, "#090", did),
studydid, cursorPointer, nonzeroColour(lrn + due, "#999", did))
# options
if not PARM['GEAR_AT_END_OF_LINE'] and PARM['MORE_OVERVIEW_STATS'] > 2:
buf += """<td
align=right class=opts style='width:1.5em!important;'
onclick='return false;'> %s</td>""" % self.mw.button(
link="opts:%d" % did,
name="<img src='qrc:/icons/gears.png'>▾")
if PARM['MORE_OVERVIEW_STATS'] > 2:
buf += """\
<td %s style="%s;padding-right:.25em;width:3em!important;"\
align=right>%s </td>\
<td %s style="%s;padding-right:.25em;" align=right>%s </td>\
<td %s style="%s;padding-right:.5em;" align=right>%s </td>\
""" % (
studydid, cursorPointer, nonzeroColour(unseen, "#DA70D6", did),
studydid, cursorPointer, nonzeroColour(suspended, "#c90", did),
studydid, cursorPointer, nonzeroColour(buried, "#960", did))
# options
if PARM['GEAR_AT_END_OF_LINE'] or PARM['MORE_OVERVIEW_STATS'] < 3:
buf += """\n<td align=right class=opts
style='width:1.5em!important;'
onclick='return false;'> %s</td>""" % self.mw.button(
link="opts:%d" % did,
name="<img _valign=bottom src='qrc:/icons/gears.png'>▾")
if PARM['STUDY_BUTTON']:
buf += """\n<td align=right
style="font-size:smaller;"> %s</td>""" % self.mw.button(
link="study:%d" % (did),
name="<small style = color:dodgerblue; >►</small>")
buf += "\n</tr>\n"
# children
buf += deck_browser_render_deck_tree(self, children, depth + 1)
return buf
# Copyright: Juda Kaleta <[email protected]>
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
# Unseen and buried counts
# https://ankiweb.net/shared/info/161964983
# Show count of unseen and buried cards in deck browser.
org_DeckBrowser_renderDeckTree = aqt.deckbrowser.DeckBrowser._renderDeckTree
org_DeckBrowser_deckRow = aqt.deckbrowser.DeckBrowser._deckRow
def initDeckBro():
if PARM['MORE_OVERVIEW_STATS']:
aqt.deckbrowser.DeckBrowser._renderDeckTree = \
deck_browser_render_deck_tree
aqt.deckbrowser.DeckBrowser._deckRow = \
deck_browser_deck_row
else:
aqt.deckbrowser.DeckBrowser._renderDeckTree = \
org_DeckBrowser_renderDeckTree
aqt.deckbrowser.DeckBrowser._deckRow = \
org_DeckBrowser_deckRow
initDeckBro()
def maInit(self, col):
self.queueLimit = PARM['queueLimit']
self.reportLimit = PARM['reportLimit'] # not 1000!!!
# aqt.mw.col.sched.reportLimit = 5555 # not ready yet
anki.sched.Scheduler.__init__ = \
anki.hooks.wrap(anki.sched.Scheduler.__init__, maInit)
#
def save_more_decks_stats():
aqt.mw.pm.profile['ctb_more_overview_stats'] = (
PARM['MORE_OVERVIEW_STATS'])
aqt.mw.pm.profile['ctb_hide_big_number'] = (
PARM['HIDE_BIG_NUMBER'])
aqt.mw.pm.profile['ctb_hide_big_numbers'] = (
PARM['HIDE_BIG_NUMBERS'])
aqt.mw.pm.profile['ctb_gear_at_end_of_line'] = (
PARM['GEAR_AT_END_OF_LINE'])
aqt.mw.pm.profile['ctb_musthave_study'] = (
PARM['STUDY_BUTTON'])
aqt.mw.pm.profile['ctb_button_titles'] = (
PARM['BUTTON_TITLES'])
def load_more_decks_stats():
global PARM
try:
tmp = aqt.mw.pm.profile['ctb_more_overview_stats']
PARM['MORE_OVERVIEW_STATS'] = tmp
except KeyError:
pass
try:
tmp = aqt.mw.pm.profile['ctb_hide_big_number']
PARM['HIDE_BIG_NUMBER'] = tmp
except KeyError:
pass
try:
tmp = aqt.mw.pm.profile['ctb_hide_big_numbers']
PARM['HIDE_BIG_NUMBERS'] = tmp
except KeyError:
pass
try:
tmp = aqt.mw.pm.profile['ctb_gear_at_end_of_line']
PARM['GEAR_AT_END_OF_LINE'] = tmp
except KeyError:
pass
try:
tmp = aqt.mw.pm.profile['ctb_musthave_study']
PARM['STUDY_BUTTON'] = tmp
except KeyError:
pass
try:
tmp = aqt.mw.pm.profile['ctb_button_titles']
PARM['BUTTON_TITLES'] = tmp
except KeyError:
pass
musthave_setup_menu()
initDeckBro()
if aqt.mw.state == "deckBrowser":
aqt.mw.moveToState("deckBrowser")
if aqt.mw.state == "overview":
aqt.mw.moveToState("overview")
anki.hooks.addHook("unloadProfile", save_more_decks_stats)
anki.hooks.addHook("profileLoaded", load_more_decks_stats)
#