mirror of
https://github.com/borgbase/vorta
synced 2024-12-21 23:33:13 +00:00
Retain source tab sort settings. By @jetchirag (#1649)
This commit is contained in:
parent
a64493d254
commit
6d5e738107
2 changed files with 29 additions and 2 deletions
|
@ -100,6 +100,18 @@ def get_misc_settings() -> List[Dict[str, str]]:
|
|||
'type': 'internal',
|
||||
'label': 'Previous window height',
|
||||
},
|
||||
{
|
||||
'key': 'sourcetab_sort_column',
|
||||
'str_value': '0',
|
||||
'type': 'internal',
|
||||
'label': 'Source Tab Sort Column',
|
||||
},
|
||||
{
|
||||
'key': 'sourcetab_sort_order',
|
||||
'str_value': '0',
|
||||
'type': 'internal',
|
||||
'label': 'Source Tab Sort Order',
|
||||
},
|
||||
]
|
||||
if sys.platform == 'darwin':
|
||||
settings += [
|
||||
|
|
|
@ -88,6 +88,7 @@ def __init__(self, parent=None):
|
|||
self.updateButton.clicked.connect(self.sources_update)
|
||||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
||||
header.sortIndicatorChanged.connect(self.update_sort_order)
|
||||
|
||||
# Connect to palette change
|
||||
QApplication.instance().paletteChanged.connect(lambda p: self.set_icons())
|
||||
|
@ -244,13 +245,27 @@ def populate_from_profile(self):
|
|||
for source in SourceFileModel.select().where(SourceFileModel.profile == profile):
|
||||
self.add_source_to_table(source, False)
|
||||
|
||||
# Initially, sort entries by path name in ascending order
|
||||
self.sourceFilesWidget.sortItems(SourceColumn.Path, QtCore.Qt.AscendingOrder)
|
||||
# Fetch the Sort by Column and order
|
||||
sourcetab_sort_column = int(SettingsModel.get(key='sourcetab_sort_column').str_value)
|
||||
sourcetab_sort_order = int(SettingsModel.get(key='sourcetab_sort_order').str_value)
|
||||
|
||||
# Sort items as per settings
|
||||
self.sourceFilesWidget.sortItems(sourcetab_sort_column, sourcetab_sort_order)
|
||||
|
||||
self.excludePatternsField.appendPlainText(profile.exclude_patterns)
|
||||
self.excludeIfPresentField.appendPlainText(profile.exclude_if_present)
|
||||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
||||
|
||||
def update_sort_order(self, column: int, order: int):
|
||||
"""Save selected sort by column and order to settings"""
|
||||
SettingsModel.update({SettingsModel.str_value: str(column)}).where(
|
||||
SettingsModel.key == 'sourcetab_sort_column'
|
||||
).execute()
|
||||
SettingsModel.update({SettingsModel.str_value: str(order)}).where(
|
||||
SettingsModel.key == 'sourcetab_sort_order'
|
||||
).execute()
|
||||
|
||||
def sources_update(self):
|
||||
"""
|
||||
Update each row in the sources table.
|
||||
|
|
Loading…
Reference in a new issue