Commit Graph

63 Commits

Author SHA1 Message Date
Damien Elmes
f1a1b0891e make mark toggling undoable
- note.flush() behaves like before, as otherwise actions or add-ons
that perform bulk flushing would end up creating an undo entry for
each note
- added col.update_note() to opt in to the new behaviour
- tidy up the names of some related routines
2021-03-10 11:53:27 +10:00
Damien Elmes
57d7e3e2ab commit immediately when there's no active checkpoint
Reviews and operations on the backend that support undoing can now be
committed immediately, so they will not be lost in the event of a crash.

This required tweaks to a few places:

- don't set collection mtime on save() unless changes were made in
Python, as otherwise we end up accidentally clearing the backend undo
queue
- autosave() is now run on every reset()
- garbage collection now runs in a timer, instead of relying on
autosave() to be run periodically
2021-03-10 11:47:53 +10:00
Damien Elmes
40aff4447a undo support for note adding 2021-03-10 11:47:53 +10:00
Damien Elmes
b466f0ce90 rework undo
- use dataclasses for the review/checkpoint undo cases, instead of the
nasty ad-hoc list structure
- expose backend review undo to Python, and hook it into GUI
- redo is not currently exposed on the GUI, and the backend can only
cope with reviews done by the new scheduler at the moment
- the initial undo prototype code was bumping mtime/usn on undo, but
that was not ideal, as it was breaking the queue handling which expected
the mtime to match. The original rationale for bumping mtime/usn was
to avoid problems with syncing, but various operations like removing
a revlog can't be synced anyway - so we just need to ensure we clear the
undo queue prior to syncing
2021-03-10 11:47:53 +10:00
Damien Elmes
35840221bb tweak search wording and tidy up API
- SearchTerm -> SearchNode
- Operator -> Joiner; share between messages
- build_search_string() supports specifying AND/OR as a convenience
- group_searches() makes it easier to negate
2021-02-11 19:57:19 +10:00
Damien Elmes
88c002f4eb convert qt strings to f-strings with flynt
Also revealed an incorrect type def in editor.py that mypy wasn't
noticing before :-(
2021-02-11 10:09:06 +10:00
Damien Elmes
bb29ce88f3 minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
4a5ef69068 add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
RumovZ
c18af2a0a9 Merge branch 'master' into dyn-deckconf 2021-02-01 23:33:41 +01:00
Damien Elmes
a56b09b987 add a bunch of return types 2021-02-01 23:53:23 +10:00
Damien Elmes
f15715fb07 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
RumovZ
6de6e5f339 Make browser accept optional args and add reopen
That way, the caller doesn't have to hold a reference to the browser and
explicitly call it again, if it wants to search for something specific.
Also, if the browser was closed and opened for a single-card-search, it
now won't perform a redundant current-deck-search first.
2021-02-01 11:54:28 +01:00
RumovZ
5425b00d2b Import SearchTerm from collection in aqt 2021-01-30 12:51:24 +01:00
Damien Elmes
cb6b88da0f simplify nid/nids searches, and ditch helper function
- IdList could be re-used for a cids: search in the future if required.
- Embedding the message means it's easy to access from Python as
an attribute of SearchTerm.
2021-01-30 11:37:00 +10:00
RumovZ
c299e271e8 Refactor search_string() and FilterToSearchIn
See #955.
2021-01-29 18:27:33 +01:00
RumovZ
f04228990d Add browser_search helper in mw 2021-01-28 20:51:32 +01:00
RumovZ
251fe50660 Fix search calls in addcards 2021-01-28 20:01:20 +01:00
RumovZ
a930aa41f0 Use backend nid filter in addcards and mediacheck 2021-01-28 18:59:20 +01:00
Arthur Milchior
e0a2d90a68 NF: HelpPage in an enum
Hopefully, this can help with updating on next manual update and maybe even linking to manual translation
2021-01-26 02:16:37 +01:00
Damien Elmes
94064b8230 convert setWindowFlags call into helper, and fix invalid variables
"type: ignore" was masking the invalid references to self in places
like showText()
2021-01-07 14:24:49 +10:00
Damien Elmes
5c08bd8fb8
Merge pull request #899 from BlueGreenMagick/remove-context-help-btn
remove context help button
2021-01-07 09:52:12 +10:00
wallgrenen
78601d29ba replace broken link 2021-01-06 17:03:39 +01:00
BlueGreenMagick
6224658c0d remove context help button 2021-01-06 22:15:48 +09:00
Damien Elmes
ffa26fe4bc fix remaining _() references; remove unused imports 2020-11-18 12:43:46 +10:00
Damien Elmes
ba336d5de3 update multi-line _() references 2020-11-18 11:32:22 +10:00
Damien Elmes
2453e5c488 update temporary val="%s" references to standard ftl 2020-11-17 22:00:44 +10:00
Damien Elmes
6418993840 merge bulk of qt/ - designer files still to do 2020-11-17 17:42:43 +10:00
RumovZ
aaf5770db9 Work around Qt's focus bug (fix help-wanted#22)
Manually hide the editor's completer popup before accepting a short cut which changes the focus widget. Thus, work around the bug in PyQt 5.15 where a QLineEdit with open QCompleter popup won't get notified about focus changes handled by the Main Window, leading to inconsistent focus.
2020-10-24 10:47:25 +02:00
johan456789
06f1aeb052 fix help url paths 2020-10-10 00:38:07 +08:00
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