Renamed new function on qt/aqt/utils.py to snake case

This commit is contained in:
evandrocoan 2020-06-04 22:39:53 -03:00
parent b23b404f68
commit 1d32873869
2 changed files with 26 additions and 26 deletions

View File

@ -36,18 +36,18 @@ from aqt.utils import (
getTag,
openHelp,
qtMenuShortcutWorkaround,
restoreComboHistory,
restoreComboIndex,
restore_combo_history,
restore_combo_index,
restore_is_checked,
restoreGeom,
restoreHeader,
restoreIsChecked,
restoreSplitter,
restoreState,
saveComboHistory,
saveComboIndex,
save_combo_history,
save_combo_index,
save_is_checked,
saveGeom,
saveHeader,
saveIsChecked,
saveSplitter,
saveState,
shortcut,
@ -1937,16 +1937,16 @@ update cards set usn=?, mod=?, did=? where id in """
d.setWindowModality(Qt.WindowModal)
combo = "BrowserFindAndReplace"
findhistory = restoreComboHistory(frm.find, combo + "Find")
replacehistory = restoreComboHistory(frm.replace, combo + "Replace")
findhistory = restore_combo_history(frm.find, combo + "Find")
replacehistory = restore_combo_history(frm.replace, combo + "Replace")
restoreIsChecked(frm.re, combo + "Regex")
restoreIsChecked(frm.ignoreCase, combo + "ignoreCase")
restore_is_checked(frm.re, combo + "Regex")
restore_is_checked(frm.ignoreCase, combo + "ignoreCase")
frm.find.setFocus()
allfields = [_("All Fields")] + fields
frm.field.addItems(allfields)
restoreComboIndex(frm.field, allfields, combo + "Field")
restore_combo_index(frm.field, allfields, combo + "Field")
qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp)
restoreGeom(d, "findreplace")
r = d.exec_()
@ -1954,20 +1954,20 @@ update cards set usn=?, mod=?, did=? where id in """
if not r:
return
saveComboIndex(frm.field, combo + "Field")
save_combo_index(frm.field, combo + "Field")
if frm.field.currentIndex() == 0:
field = None
else:
field = fields[frm.field.currentIndex() - 1]
search = saveComboHistory(frm.find, findhistory, combo + "Find")
replace = saveComboHistory(frm.replace, replacehistory, combo + "Replace")
search = save_combo_history(frm.find, findhistory, combo + "Find")
replace = save_combo_history(frm.replace, replacehistory, combo + "Replace")
regex = frm.re.isChecked()
nocase = frm.ignoreCase.isChecked()
saveIsChecked(frm.re, combo + "Regex")
saveIsChecked(frm.ignoreCase, combo + "ignoreCase")
save_is_checked(frm.re, combo + "Regex")
save_is_checked(frm.ignoreCase, combo + "ignoreCase")
self.mw.checkpoint(_("Find and Replace"))
# starts progress dialog as well
@ -2013,13 +2013,13 @@ update cards set usn=?, mod=?, did=? where id in """
frm = aqt.forms.finddupes.Ui_Dialog()
frm.setupUi(d)
restoreGeom(d, "findDupes")
searchHistory = restoreComboHistory(frm.search, "findDupesFind")
searchHistory = restore_combo_history(frm.search, "findDupesFind")
fields = sorted(
anki.find.fieldNames(self.col, downcase=False), key=lambda x: x.lower()
)
frm.fields.addItems(fields)
restoreComboIndex(frm.fields, fields, "findDupesFields")
restore_combo_index(frm.fields, fields, "findDupesFields")
self._dupesButton = None
# links
@ -2034,8 +2034,8 @@ update cards set usn=?, mod=?, did=? where id in """
qconnect(d.finished, onFin)
def onClick():
search_text = saveComboHistory(frm.search, searchHistory, "findDupesFind")
saveComboIndex(frm.fields, "findDupesFields")
search_text = save_combo_history(frm.search, searchHistory, "findDupesFind")
save_combo_index(frm.fields, "findDupesFields")
field = fields[frm.fields.currentIndex()]
self.duplicatesReport(frm.webView, field, search_text, frm, web_context)

View File

@ -470,25 +470,25 @@ def restoreState(widget, key: str):
widget.restoreState(aqt.mw.pm.profile[key])
def saveIsChecked(widget, key: str):
def save_is_checked(widget, key: str):
key += "IsChecked"
aqt.mw.pm.profile[key] = widget.isChecked()
def restoreIsChecked(widget, key: str):
def restore_is_checked(widget, key: str):
key += "IsChecked"
if aqt.mw.pm.profile.get(key) is not None:
widget.setChecked(aqt.mw.pm.profile[key])
def saveComboIndex(widget: QComboBox, key: str):
def save_combo_index(widget: QComboBox, key: str):
textKey = key + "ComboActiveText"
indexKey = key + "ComboActiveIndex"
aqt.mw.pm.session[textKey] = widget.currentText()
aqt.mw.pm.session[indexKey] = widget.currentIndex()
def restoreComboIndex(widget: QComboBox, history: List[str], key: str):
def restore_combo_index(widget: QComboBox, history: List[str], key: str):
textKey = key + "ComboActiveText"
indexKey = key + "ComboActiveIndex"
text = aqt.mw.pm.session.get(textKey)
@ -498,7 +498,7 @@ def restoreComboIndex(widget: QComboBox, history: List[str], key: str):
widget.setCurrentIndex(index)
def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
def save_combo_history(comboBox: QComboBox, history: List[str], name: str):
name += "BoxHistory"
text_input = comboBox.lineEdit().text()
if text_input in history:
@ -512,7 +512,7 @@ def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
return text_input
def restoreComboHistory(comboBox: QComboBox, name: str):
def restore_combo_history(comboBox: QComboBox, name: str):
name += "BoxHistory"
history = aqt.mw.pm.profile.get(name, [])
comboBox.addItems([""] + history)