mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
Add enum for column alignment
This commit is contained in:
parent
f78401619a
commit
d8a0aa922c
4 changed files with 19 additions and 14 deletions
|
@ -6,6 +6,7 @@ ignore = forms,hooks_gen.py
|
|||
[TYPECHECK]
|
||||
ignored-modules=win32file,pywintypes,socket,win32pipe,winrt,pyaudio
|
||||
ignored-classes=
|
||||
BrowserColumns,
|
||||
BrowserRow,
|
||||
SearchNode,
|
||||
Config,
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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::NoteTags => pb::browser_columns::Alignment::Start,
|
||||
_ => pb::browser_columns::Alignment::Center,
|
||||
}
|
||||
}
|
||||
|
||||
fn localized_label(self, i18n: &I18n) -> String {
|
||||
|
|
Loading…
Reference in a new issue