mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -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]
|
[TYPECHECK]
|
||||||
ignored-modules=win32file,pywintypes,socket,win32pipe,winrt,pyaudio
|
ignored-modules=win32file,pywintypes,socket,win32pipe,winrt,pyaudio
|
||||||
ignored-classes=
|
ignored-classes=
|
||||||
|
BrowserColumns,
|
||||||
BrowserRow,
|
BrowserRow,
|
||||||
SearchNode,
|
SearchNode,
|
||||||
Config,
|
Config,
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ class DataModel(QAbstractTableModel):
|
||||||
return qfont
|
return qfont
|
||||||
if role == Qt.TextAlignmentRole:
|
if role == Qt.TextAlignmentRole:
|
||||||
align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter
|
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
|
align |= Qt.AlignHCenter
|
||||||
return align
|
return align
|
||||||
if role in (Qt.DisplayRole, Qt.ToolTipRole):
|
if role in (Qt.DisplayRole, Qt.ToolTipRole):
|
||||||
|
@ -1097,5 +1097,5 @@ def addon_column_fillin(key: str) -> Column:
|
||||||
is_sortable=False,
|
is_sortable=False,
|
||||||
sorts_reversed=False,
|
sorts_reversed=False,
|
||||||
uses_cell_font=False,
|
uses_cell_font=False,
|
||||||
aligns_centered=True,
|
alignment=Columns.ALIGNMENT_CENTER,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1055,13 +1055,17 @@ message FindAndReplaceIn {
|
||||||
}
|
}
|
||||||
|
|
||||||
message BrowserColumns {
|
message BrowserColumns {
|
||||||
|
enum Alignment {
|
||||||
|
ALIGNMENT_START = 0;
|
||||||
|
ALIGNMENT_CENTER = 1;
|
||||||
|
}
|
||||||
message Column {
|
message Column {
|
||||||
string key = 1;
|
string key = 1;
|
||||||
string label = 2;
|
string label = 2;
|
||||||
bool is_sortable = 3;
|
bool is_sortable = 3;
|
||||||
bool sorts_reversed = 4;
|
bool sorts_reversed = 4;
|
||||||
bool uses_cell_font = 5;
|
bool uses_cell_font = 5;
|
||||||
bool aligns_centered = 6;
|
Alignment alignment = 6;
|
||||||
}
|
}
|
||||||
repeated Column columns = 1;
|
repeated Column columns = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl browser_table::Column {
|
||||||
is_sortable: self.is_sortable(),
|
is_sortable: self.is_sortable(),
|
||||||
sorts_reversed: self == browser_table::Column::NoteField,
|
sorts_reversed: self == browser_table::Column::NoteField,
|
||||||
uses_cell_font: self.uses_cell_font(),
|
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)
|
matches!(self, Self::Question | Self::Answer | Self::NoteField)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aligns_centered(self) -> bool {
|
fn alignment(self) -> pb::browser_columns::Alignment {
|
||||||
!matches!(
|
match self {
|
||||||
self,
|
|
||||||
Self::Question
|
Self::Question
|
||||||
| Self::Answer
|
| Self::Answer
|
||||||
| Self::CardTemplate
|
| Self::CardTemplate
|
||||||
| Self::CardDeck
|
| Self::CardDeck
|
||||||
| Self::NoteField
|
| Self::NoteField
|
||||||
| Self::Notetype
|
| Self::Notetype
|
||||||
| Self::NoteTags
|
| Self::NoteTags => pb::browser_columns::Alignment::Start,
|
||||||
)
|
_ => pb::browser_columns::Alignment::Center,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn localized_label(self, i18n: &I18n) -> String {
|
fn localized_label(self, i18n: &I18n) -> String {
|
||||||
|
|
Loading…
Reference in a new issue