mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 17:26:36 -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
|
import html
|
||||||
from dataclasses import dataclass
|
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
|
||||||
import aqt.forms
|
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:
|
if not card_ids:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ class Table:
|
||||||
self.browser = browser
|
self.browser = browser
|
||||||
self.col: Collection = browser.col
|
self.col: Collection = browser.col
|
||||||
self._state: ItemState = (
|
self._state: ItemState = (
|
||||||
CardState(self.col)
|
NoteState(self.col)
|
||||||
if self.col.get_config_bool(Config.Bool.BROWSER_CARD_STATE)
|
if self.col.get_config_bool(Config.Bool.BROWSER_TABLE_SHOW_NOTES_MODE)
|
||||||
else NoteState(self.col)
|
else CardState(self.col)
|
||||||
)
|
)
|
||||||
self._model = DataModel(self.col, self._state)
|
self._model = DataModel(self.col, self._state)
|
||||||
self._view: Optional[QTableView] = None
|
self._view: Optional[QTableView] = None
|
||||||
|
@ -201,7 +201,9 @@ class Table:
|
||||||
self._state = self._model.toggle_state(
|
self._state = self._model.toggle_state(
|
||||||
SearchContext(search=last_search, browser=self.browser)
|
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_sort_indicator()
|
||||||
self._set_column_sizes()
|
self._set_column_sizes()
|
||||||
self._restore_selection(self._toggled_selection)
|
self._restore_selection(self._toggled_selection)
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ message SetDeckIn {
|
||||||
message Config {
|
message Config {
|
||||||
message Bool {
|
message Bool {
|
||||||
enum Key {
|
enum Key {
|
||||||
BROWSER_CARD_STATE = 0;
|
BROWSER_TABLE_SHOW_NOTES_MODE = 0;
|
||||||
BROWSER_SORT_BACKWARDS = 1;
|
BROWSER_SORT_BACKWARDS = 1;
|
||||||
BROWSER_NOTE_SORT_BACKWARDS = 2;
|
BROWSER_NOTE_SORT_BACKWARDS = 2;
|
||||||
PREVIEW_BOTH_SIDES = 3;
|
PREVIEW_BOTH_SIDES = 3;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use serde_json::Value;
|
||||||
impl From<BoolKeyProto> for BoolKey {
|
impl From<BoolKeyProto> for BoolKey {
|
||||||
fn from(k: BoolKeyProto) -> Self {
|
fn from(k: BoolKeyProto) -> Self {
|
||||||
match k {
|
match k {
|
||||||
BoolKeyProto::BrowserCardState => BoolKey::BrowserCardState,
|
BoolKeyProto::BrowserTableShowNotesMode => BoolKey::BrowserTableShowNotesMode,
|
||||||
BoolKeyProto::BrowserSortBackwards => BoolKey::BrowserSortBackwards,
|
BoolKeyProto::BrowserSortBackwards => BoolKey::BrowserSortBackwards,
|
||||||
BoolKeyProto::BrowserNoteSortBackwards => BoolKey::BrowserNoteSortBackwards,
|
BoolKeyProto::BrowserNoteSortBackwards => BoolKey::BrowserNoteSortBackwards,
|
||||||
BoolKeyProto::PreviewBothSides => BoolKey::PreviewBothSides,
|
BoolKeyProto::PreviewBothSides => BoolKey::PreviewBothSides,
|
||||||
|
|
|
@ -133,14 +133,14 @@ fn card_render_required(columns: &[String]) -> bool {
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
pub fn browser_row_for_id(&mut self, id: i64) -> Result<Row> {
|
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
|
// this is inefficient; we may want to use an enum in the future
|
||||||
let columns = self.get_desktop_browser_card_columns();
|
let columns = self.get_desktop_browser_card_columns();
|
||||||
CardRowContext::new(self, id, card_render_required(&columns))?
|
CardRowContext::new(self, id, card_render_required(&columns))?
|
||||||
.browser_row_for_id(&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)]
|
#[derive(Debug, Clone, Copy, IntoStaticStr)]
|
||||||
#[strum(serialize_all = "camelCase")]
|
#[strum(serialize_all = "camelCase")]
|
||||||
pub enum BoolKey {
|
pub enum BoolKey {
|
||||||
BrowserCardState,
|
BrowserTableShowNotesMode,
|
||||||
BrowserNoteSortBackwards,
|
BrowserNoteSortBackwards,
|
||||||
CardCountsSeparateInactive,
|
CardCountsSeparateInactive,
|
||||||
CollapseCardState,
|
CollapseCardState,
|
||||||
|
@ -62,8 +62,7 @@ impl Collection {
|
||||||
| BoolKey::FutureDueShowBacklog
|
| BoolKey::FutureDueShowBacklog
|
||||||
| BoolKey::ShowRemainingDueCountsInStudy
|
| BoolKey::ShowRemainingDueCountsInStudy
|
||||||
| BoolKey::CardCountsSeparateInactive
|
| BoolKey::CardCountsSeparateInactive
|
||||||
| BoolKey::NormalizeNoteText
|
| BoolKey::NormalizeNoteText => self.get_config_optional(key).unwrap_or(true),
|
||||||
| BoolKey::BrowserCardState => self.get_config_optional(key).unwrap_or(true),
|
|
||||||
|
|
||||||
// other options default to false
|
// other options default to false
|
||||||
other => self.get_config_default(other),
|
other => self.get_config_default(other),
|
||||||
|
|
Loading…
Reference in a new issue