Commit Graph

84 Commits

Author SHA1 Message Date
Damien Elmes
bf72773531 fix IndexError when switching notetypes
Closes #780
https://github.com/ankitects/anki/pull/780
2020-10-05 13:33:54 +10:00
Henrik Giesel
7f503895d7 Create ResetReason enum 2020-08-16 18:56:32 +02:00
Henrik Giesel
db0a18106f Reorder + make all parameters optional 2020-08-16 18:56:32 +02:00
Henrik Giesel
ccc56d4355 Satisfy formatter 2020-08-16 18:56:32 +02:00
Henrik Giesel
dd515e65e7 Add new use of requireReset 2020-08-16 18:56:32 +02:00
Arthur Milchior
c81a9b3d61 hook: history_line
I expect to use this hook to create an add-on which will simply remove
the ",,". By ignoring empty fields I expect to make this easier to
use.
2020-06-08 20:47:01 +02:00
Damien Elmes
6ae55a7a77 deprecate removeTempNote() 2020-05-20 15:01:05 +10:00
Damien Elmes
f1c5c88c10 no longer need to check addNote's return value 2020-05-14 21:59:42 +10:00
Damien Elmes
24ffb6ab76 check for empty cloze cards when rendering as well 2020-05-14 21:56:45 +10:00
Damien Elmes
08f894735a
Merge pull request #607 from Arthur-Milchior/remove_a_try
Simplify the copying of field contents when resetting
2020-05-05 11:36:17 +10:00
Damien Elmes
9502fe790f
Merge pull request #584 from Arthur-Milchior/onModelchangeUsed
On modelchange used
2020-05-04 14:06:35 +10:00
Damien Elmes
eec3fcf87a use qconnect everywhere, and fix some typing issues
a step towards check_untyped_defs in aqt, but there's still 100+
issues to resolve
2020-05-04 13:23:08 +10:00
Arthur Milchior
f2fbf667cd onModelChange: replacing try by if 2020-05-03 01:53:00 +02:00
Arthur Milchior
d427e1028b single try in onModelChange 2020-05-03 01:53:00 +02:00
Arthur Milchior
936bb31997 onModelChange save note
I like the way onModelChange is done. Except that you forget to use
the note you computed.
2020-05-03 01:53:00 +02:00
Arthur Milchior
3378daeca3 remove an useless asignment
Because fields of new notes are empty by default
2020-04-28 00:31:30 +02:00
Arthur Milchior
93d83e760b remove a try, for code clarity 2020-04-28 00:31:24 +02:00
Damien Elmes
0c8f6ced09 Revert "Merge pull request #583 from Arthur-Milchior/remove_a_try"
This reverts commit e9ca61d1eb, reversing
changes made to abb80231a5.
2020-04-28 07:38:23 +10:00
Arthur Milchior
e4a0ccc059 remove an useless asignment
Because fields of new notes are empty by default
2020-04-26 14:49:16 +02:00
Arthur Milchior
1771be8f1e remove a try, for code clarity 2020-04-26 14:49:11 +02:00
BlueGreenMagick
aa86bc8088 use model type to detect cloze notes 2020-04-07 14:02:53 +09:00
Arthur Milchior
657fa9758b hook add_card_did_init 2020-04-03 11:03:08 +02:00
Arthur Milchior
0b633dbf40 Ensuring "setNote" is called only once during changing of note type
Initially, I wanted to solve the bug reported on
https://github.com/Arthur-Milchior/anki-html-src-in-field/issues/1

After some research, I finally discovered that the trouble was that,
when we change the note type in add card, the method
`aqt.editor.Editor.loadNote` is called twice. In itself, it would not
be a problem, but given the way callback works, its call back is
called twice on the last version of the webview. Which means that
`gui_hooks.editor_did_load_note` is called twice, which breaks this
add-on.

The reason why loadNote is called twice is because `setNote` is called
twice in `aqt.modelchooser.onModelChange`. The first time through
`gui_hooks.current_note_type_did_change` which calls
`addcards.AddCards.onModelChange` which calls `loadNote`, the second
time through `self.mw.reset()` which calls
`gui_hooks.state_did_reset()` which calls `addcards.AddCards.onReset`
which calls `setAndFocusNote` which calls `setNote`.

I should note furthermore that currently,
`gui_hooks.current_note_type_did_change` is called only when the model
chooser change a model. And `addCards.onModelChange` is never called,
only added to the hook `gui_hooks.current_note_type_did_change`. So
removing the line of code removed in this commit will have no side
effect in Anki itself. It will only affect the fact that this method
is called twice.

I do not know of any add-on calling `onModelChange` or
`gui_hooks.current_note_type_did_change`, but it means little, so of
course, it may always mean an add-on will break because of this
change. No way of being sure.
2020-03-26 21:26:13 +01:00
Damien Elmes
0d43e9dca3 tweak add-on wording 2020-03-20 21:00:21 +10:00
Arthur Milchior
e4ae41340f Hook to decide whether a note should be added. 2020-03-19 03:39:53 +01:00
Arthur Milchior
66e1f876d7 "unused" variable become optional.
Adding this parameter broke one of my add-on, see
https://github.com/Arthur-Milchior/anki-keep-model-in-add-cards/issues/1

Since those parameters are not used, setting them to None by default,
as was done in some other method, seems acceptable
2020-01-23 21:46:42 -08:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
8310cb7a0e add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
89fce1f6b7 migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
660685375f migrate most of the remaining runHook() calls 2020-01-15 12:46:53 +10:00
Glutanimate
cda296748d Add hook for AddCards.addNote 2020-01-08 21:29:28 +01:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00