mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
rename BrowserCardState
Use a more verbose name, and use 'note' rather than 'card', so we can rely on the default of False
This commit is contained in:
parent
0269a4a8f4
commit
3383f1742a
7 changed files with 18 additions and 15 deletions
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
|
||||
import html
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence
|
||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
import aqt
|
||||
import aqt.forms
|
||||
|
|
|
@ -54,7 +54,9 @@ def set_due_date_dialog(
|
|||
)
|
||||
|
||||
|
||||
def forget_cards(*, mw: aqt.AnkiQt, parent: QWidget, card_ids: Sequence[CardId]) -> None:
|
||||
def forget_cards(
|
||||
*, mw: aqt.AnkiQt, parent: QWidget, card_ids: Sequence[CardId]
|
||||
) -> None:
|
||||
if not card_ids:
|
||||
return
|
||||
|
||||
|
|
|
@ -60,9 +60,9 @@ class Table:
|
|||
self.browser = browser
|
||||
self.col: Collection = browser.col
|
||||
self._state: ItemState = (
|
||||
CardState(self.col)
|
||||
if self.col.get_config_bool(Config.Bool.BROWSER_CARD_STATE)
|
||||
else NoteState(self.col)
|
||||
NoteState(self.col)
|
||||
if self.col.get_config_bool(Config.Bool.BROWSER_TABLE_SHOW_NOTES_MODE)
|
||||
else CardState(self.col)
|
||||
)
|
||||
self._model = DataModel(self.col, self._state)
|
||||
self._view: Optional[QTableView] = None
|
||||
|
@ -201,7 +201,9 @@ class Table:
|
|||
self._state = self._model.toggle_state(
|
||||
SearchContext(search=last_search, browser=self.browser)
|
||||
)
|
||||
self.col.set_config_bool(Config.Bool.BROWSER_CARD_STATE, self.is_card_state())
|
||||
self.col.set_config_bool(
|
||||
Config.Bool.BROWSER_TABLE_SHOW_NOTES_MODE, not self.is_card_state()
|
||||
)
|
||||
self._set_sort_indicator()
|
||||
self._set_column_sizes()
|
||||
self._restore_selection(self._toggled_selection)
|
||||
|
|
|
@ -1345,7 +1345,7 @@ message SetDeckIn {
|
|||
message Config {
|
||||
message Bool {
|
||||
enum Key {
|
||||
BROWSER_CARD_STATE = 0;
|
||||
BROWSER_TABLE_SHOW_NOTES_MODE = 0;
|
||||
BROWSER_SORT_BACKWARDS = 1;
|
||||
BROWSER_NOTE_SORT_BACKWARDS = 2;
|
||||
PREVIEW_BOTH_SIDES = 3;
|
||||
|
|
|
@ -15,7 +15,7 @@ use serde_json::Value;
|
|||
impl From<BoolKeyProto> for BoolKey {
|
||||
fn from(k: BoolKeyProto) -> Self {
|
||||
match k {
|
||||
BoolKeyProto::BrowserCardState => BoolKey::BrowserCardState,
|
||||
BoolKeyProto::BrowserTableShowNotesMode => BoolKey::BrowserTableShowNotesMode,
|
||||
BoolKeyProto::BrowserSortBackwards => BoolKey::BrowserSortBackwards,
|
||||
BoolKeyProto::BrowserNoteSortBackwards => BoolKey::BrowserNoteSortBackwards,
|
||||
BoolKeyProto::PreviewBothSides => BoolKey::PreviewBothSides,
|
||||
|
|
|
@ -133,14 +133,14 @@ fn card_render_required(columns: &[String]) -> bool {
|
|||
|
||||
impl Collection {
|
||||
pub fn browser_row_for_id(&mut self, id: i64) -> Result<Row> {
|
||||
if self.get_bool(BoolKey::BrowserCardState) {
|
||||
if self.get_bool(BoolKey::BrowserTableShowNotesMode) {
|
||||
let columns = self.get_desktop_browser_note_columns();
|
||||
NoteRowContext::new(self, id)?.browser_row_for_id(&columns)
|
||||
} else {
|
||||
// this is inefficient; we may want to use an enum in the future
|
||||
let columns = self.get_desktop_browser_card_columns();
|
||||
CardRowContext::new(self, id, card_render_required(&columns))?
|
||||
.browser_row_for_id(&columns)
|
||||
} else {
|
||||
let columns = self.get_desktop_browser_note_columns();
|
||||
NoteRowContext::new(self, id)?.browser_row_for_id(&columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use strum::IntoStaticStr;
|
|||
#[derive(Debug, Clone, Copy, IntoStaticStr)]
|
||||
#[strum(serialize_all = "camelCase")]
|
||||
pub enum BoolKey {
|
||||
BrowserCardState,
|
||||
BrowserTableShowNotesMode,
|
||||
BrowserNoteSortBackwards,
|
||||
CardCountsSeparateInactive,
|
||||
CollapseCardState,
|
||||
|
@ -62,8 +62,7 @@ impl Collection {
|
|||
| BoolKey::FutureDueShowBacklog
|
||||
| BoolKey::ShowRemainingDueCountsInStudy
|
||||
| BoolKey::CardCountsSeparateInactive
|
||||
| BoolKey::NormalizeNoteText
|
||||
| BoolKey::BrowserCardState => self.get_config_optional(key).unwrap_or(true),
|
||||
| BoolKey::NormalizeNoteText => self.get_config_optional(key).unwrap_or(true),
|
||||
|
||||
// other options default to false
|
||||
other => self.get_config_default(other),
|
||||
|
|
Loading…
Reference in a new issue