mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-01 00:06:19 +00:00
apol: Add workspace functions for save/load QComboBoxes.
For #97 and #98.
This commit is contained in:
parent
c012a2446f
commit
4b357379d8
@ -194,3 +194,41 @@ def load_listviews(tab, settings, listviews):
|
||||
|
||||
if item in selections:
|
||||
selectionmodel.select(index, QItemSelectionModel.Select)
|
||||
|
||||
|
||||
def save_comboboxes(tab, settings, comboboxes):
|
||||
"""
|
||||
Save settings from the QComboBox selection in the tab.
|
||||
|
||||
Parameters:
|
||||
tab The tab object.
|
||||
settings The dictionary of settings. This will be mutated.
|
||||
comboboxes A list of attribute names (str) of QListViews in the tab.
|
||||
"""
|
||||
|
||||
for entry in comboboxes:
|
||||
combobox = getattr(tab, entry)
|
||||
settings[entry] = combobox.currentData(Qt.DisplayRole)
|
||||
|
||||
|
||||
def load_comboboxes(tab, settings, comboboxes):
|
||||
"""
|
||||
Load settings into the QComboBox selection in the tab.
|
||||
|
||||
Parameters:
|
||||
tab The tab object.
|
||||
settings The dictionary of settings.
|
||||
comboboxes A list of attribute names (str) of QListViews in the tab.
|
||||
"""
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
for entry in comboboxes:
|
||||
try:
|
||||
selection = settings[entry]
|
||||
except KeyError:
|
||||
log.warning("{0} criteria missing from settings file.".format(entry))
|
||||
continue
|
||||
|
||||
combobox = getattr(tab, entry)
|
||||
combobox.setCurrentText(selection)
|
||||
|
Loading…
Reference in New Issue
Block a user