diff --git a/qt/.pylintrc b/qt/.pylintrc index b4809e76d..fb0800e47 100644 --- a/qt/.pylintrc +++ b/qt/.pylintrc @@ -6,6 +6,7 @@ ignore = forms,hooks_gen.py [TYPECHECK] ignored-modules=win32file,pywintypes,socket,win32pipe,winrt,pyaudio ignored-classes= + BrowserColumns, BrowserRow, SearchNode, Config, diff --git a/qt/aqt/table.py b/qt/aqt/table.py index 99af64a7b..dc4be504b 100644 --- a/qt/aqt/table.py +++ b/qt/aqt/table.py @@ -1045,7 +1045,7 @@ class DataModel(QAbstractTableModel): return qfont if role == Qt.TextAlignmentRole: align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter - if self.column_at(index).aligns_centered: + if self.column_at(index).alignment == Columns.ALIGNMENT_CENTER: align |= Qt.AlignHCenter return align if role in (Qt.DisplayRole, Qt.ToolTipRole): @@ -1097,5 +1097,5 @@ def addon_column_fillin(key: str) -> Column: is_sortable=False, sorts_reversed=False, uses_cell_font=False, - aligns_centered=True, + alignment=Columns.ALIGNMENT_CENTER, ) diff --git a/rslib/backend.proto b/rslib/backend.proto index ddddb0175..8384ba864 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -1055,13 +1055,17 @@ message FindAndReplaceIn { } message BrowserColumns { + enum Alignment { + ALIGNMENT_START = 0; + ALIGNMENT_CENTER = 1; + } message Column { string key = 1; string label = 2; bool is_sortable = 3; bool sorts_reversed = 4; bool uses_cell_font = 5; - bool aligns_centered = 6; + Alignment alignment = 6; } repeated Column columns = 1; } diff --git a/rslib/src/backend/search/browser_table.rs b/rslib/src/backend/search/browser_table.rs index d500fcc9c..ca1b431ef 100644 --- a/rslib/src/backend/search/browser_table.rs +++ b/rslib/src/backend/search/browser_table.rs @@ -62,7 +62,7 @@ impl browser_table::Column { is_sortable: self.is_sortable(), sorts_reversed: self == browser_table::Column::NoteField, uses_cell_font: self.uses_cell_font(), - aligns_centered: self.aligns_centered(), + alignment: self.alignment() as i32, } } @@ -74,17 +74,17 @@ impl browser_table::Column { matches!(self, Self::Question | Self::Answer | Self::NoteField) } - fn aligns_centered(self) -> bool { - !matches!( - self, + fn alignment(self) -> pb::browser_columns::Alignment { + match self { Self::Question - | Self::Answer - | Self::CardTemplate - | Self::CardDeck - | Self::NoteField - | Self::Notetype - | Self::NoteTags - ) + | Self::Answer + | Self::CardTemplate + | Self::CardDeck + | Self::NoteField + | Self::Notetype + | Self::NoteTags => pb::browser_columns::Alignment::Start, + _ => pb::browser_columns::Alignment::Center, + } } fn localized_label(self, i18n: &I18n) -> String {