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, getTag,
openHelp, openHelp,
qtMenuShortcutWorkaround, qtMenuShortcutWorkaround,
restoreComboHistory, restore_combo_history,
restoreComboIndex, restore_combo_index,
restore_is_checked,
restoreGeom, restoreGeom,
restoreHeader, restoreHeader,
restoreIsChecked,
restoreSplitter, restoreSplitter,
restoreState, restoreState,
saveComboHistory, save_combo_history,
saveComboIndex, save_combo_index,
save_is_checked,
saveGeom, saveGeom,
saveHeader, saveHeader,
saveIsChecked,
saveSplitter, saveSplitter,
saveState, saveState,
shortcut, shortcut,
@ -1937,16 +1937,16 @@ update cards set usn=?, mod=?, did=? where id in """
d.setWindowModality(Qt.WindowModal) d.setWindowModality(Qt.WindowModal)
combo = "BrowserFindAndReplace" combo = "BrowserFindAndReplace"
findhistory = restoreComboHistory(frm.find, combo + "Find") findhistory = restore_combo_history(frm.find, combo + "Find")
replacehistory = restoreComboHistory(frm.replace, combo + "Replace") replacehistory = restore_combo_history(frm.replace, combo + "Replace")
restoreIsChecked(frm.re, combo + "Regex") restore_is_checked(frm.re, combo + "Regex")
restoreIsChecked(frm.ignoreCase, combo + "ignoreCase") restore_is_checked(frm.ignoreCase, combo + "ignoreCase")
frm.find.setFocus() frm.find.setFocus()
allfields = [_("All Fields")] + fields allfields = [_("All Fields")] + fields
frm.field.addItems(allfields) frm.field.addItems(allfields)
restoreComboIndex(frm.field, allfields, combo + "Field") restore_combo_index(frm.field, allfields, combo + "Field")
qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp) qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp)
restoreGeom(d, "findreplace") restoreGeom(d, "findreplace")
r = d.exec_() r = d.exec_()
@ -1954,20 +1954,20 @@ update cards set usn=?, mod=?, did=? where id in """
if not r: if not r:
return return
saveComboIndex(frm.field, combo + "Field") save_combo_index(frm.field, combo + "Field")
if frm.field.currentIndex() == 0: if frm.field.currentIndex() == 0:
field = None field = None
else: else:
field = fields[frm.field.currentIndex() - 1] field = fields[frm.field.currentIndex() - 1]
search = saveComboHistory(frm.find, findhistory, combo + "Find") search = save_combo_history(frm.find, findhistory, combo + "Find")
replace = saveComboHistory(frm.replace, replacehistory, combo + "Replace") replace = save_combo_history(frm.replace, replacehistory, combo + "Replace")
regex = frm.re.isChecked() regex = frm.re.isChecked()
nocase = frm.ignoreCase.isChecked() nocase = frm.ignoreCase.isChecked()
saveIsChecked(frm.re, combo + "Regex") save_is_checked(frm.re, combo + "Regex")
saveIsChecked(frm.ignoreCase, combo + "ignoreCase") save_is_checked(frm.ignoreCase, combo + "ignoreCase")
self.mw.checkpoint(_("Find and Replace")) self.mw.checkpoint(_("Find and Replace"))
# starts progress dialog as well # 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 = aqt.forms.finddupes.Ui_Dialog()
frm.setupUi(d) frm.setupUi(d)
restoreGeom(d, "findDupes") restoreGeom(d, "findDupes")
searchHistory = restoreComboHistory(frm.search, "findDupesFind") searchHistory = restore_combo_history(frm.search, "findDupesFind")
fields = sorted( fields = sorted(
anki.find.fieldNames(self.col, downcase=False), key=lambda x: x.lower() anki.find.fieldNames(self.col, downcase=False), key=lambda x: x.lower()
) )
frm.fields.addItems(fields) frm.fields.addItems(fields)
restoreComboIndex(frm.fields, fields, "findDupesFields") restore_combo_index(frm.fields, fields, "findDupesFields")
self._dupesButton = None self._dupesButton = None
# links # links
@ -2034,8 +2034,8 @@ update cards set usn=?, mod=?, did=? where id in """
qconnect(d.finished, onFin) qconnect(d.finished, onFin)
def onClick(): def onClick():
search_text = saveComboHistory(frm.search, searchHistory, "findDupesFind") search_text = save_combo_history(frm.search, searchHistory, "findDupesFind")
saveComboIndex(frm.fields, "findDupesFields") save_combo_index(frm.fields, "findDupesFields")
field = fields[frm.fields.currentIndex()] field = fields[frm.fields.currentIndex()]
self.duplicatesReport(frm.webView, field, search_text, frm, web_context) 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]) widget.restoreState(aqt.mw.pm.profile[key])
def saveIsChecked(widget, key: str): def save_is_checked(widget, key: str):
key += "IsChecked" key += "IsChecked"
aqt.mw.pm.profile[key] = widget.isChecked() aqt.mw.pm.profile[key] = widget.isChecked()
def restoreIsChecked(widget, key: str): def restore_is_checked(widget, key: str):
key += "IsChecked" key += "IsChecked"
if aqt.mw.pm.profile.get(key) is not None: if aqt.mw.pm.profile.get(key) is not None:
widget.setChecked(aqt.mw.pm.profile[key]) widget.setChecked(aqt.mw.pm.profile[key])
def saveComboIndex(widget: QComboBox, key: str): def save_combo_index(widget: QComboBox, key: str):
textKey = key + "ComboActiveText" textKey = key + "ComboActiveText"
indexKey = key + "ComboActiveIndex" indexKey = key + "ComboActiveIndex"
aqt.mw.pm.session[textKey] = widget.currentText() aqt.mw.pm.session[textKey] = widget.currentText()
aqt.mw.pm.session[indexKey] = widget.currentIndex() 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" textKey = key + "ComboActiveText"
indexKey = key + "ComboActiveIndex" indexKey = key + "ComboActiveIndex"
text = aqt.mw.pm.session.get(textKey) text = aqt.mw.pm.session.get(textKey)
@ -498,7 +498,7 @@ def restoreComboIndex(widget: QComboBox, history: List[str], key: str):
widget.setCurrentIndex(index) 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" name += "BoxHistory"
text_input = comboBox.lineEdit().text() text_input = comboBox.lineEdit().text()
if text_input in history: if text_input in history:
@ -512,7 +512,7 @@ def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
return text_input return text_input
def restoreComboHistory(comboBox: QComboBox, name: str): def restore_combo_history(comboBox: QComboBox, name: str):
name += "BoxHistory" name += "BoxHistory"
history = aqt.mw.pm.profile.get(name, []) history = aqt.mw.pm.profile.get(name, [])
comboBox.addItems([""] + history) comboBox.addItems([""] + history)