Cleanup, remove maxResults
This commit is contained in:
parent
2e8734dd79
commit
3dfa077e08
@ -54,34 +54,17 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Max search results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinMaxResults">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Text scan length</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinScanLength">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
@ -1,20 +1,19 @@
|
||||
{
|
||||
"allowEditing": false,
|
||||
"bgColor": 4294967295,
|
||||
"checkForUpdates": true,
|
||||
"enableAnkiConnect": false,
|
||||
"fgColor": 4278190080,
|
||||
"firstRun": true,
|
||||
"fontFamily": "Arial",
|
||||
"fontSize": 12,
|
||||
"rememberTextContent": false,
|
||||
"loadRecentFile": false,
|
||||
"maxResults": 20,
|
||||
"profiles": {},
|
||||
"recentFiles": [],
|
||||
"textContent": "",
|
||||
"rememberTextContent": false,
|
||||
"scanLength": 16,
|
||||
"stripReadings": false,
|
||||
"tags": [],
|
||||
"wordWrap": false,
|
||||
"allowEditing": true,
|
||||
"enableAnkiConnect": false,
|
||||
"firstRun": true
|
||||
"textContent": "",
|
||||
"wordWrap": false
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import operator
|
||||
import sqlite3
|
||||
|
||||
|
||||
@ -31,15 +30,15 @@ class Dictionary:
|
||||
self.requireIndex('Terms', 'reading')
|
||||
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute('SELECT * FROM Terms WHERE expression {0} ? OR reading=? LIMIT 100'.format('LIKE' if wildcards else '='), (word, word))
|
||||
cursor.execute('SELECT * FROM Terms WHERE expression {0} ? OR reading=?'.format('LIKE' if wildcards else '='), (word, word))
|
||||
|
||||
results = list()
|
||||
results = []
|
||||
for expression, reading, glossary, tags in cursor.fetchall():
|
||||
results.append({
|
||||
'expression': expression,
|
||||
'reading': reading,
|
||||
'glossary': glossary,
|
||||
'tags': tags.split()
|
||||
'glossary': glossary,
|
||||
'reading': reading,
|
||||
'tags': tags.split()
|
||||
})
|
||||
|
||||
return results
|
||||
@ -57,9 +56,9 @@ class Dictionary:
|
||||
character, kunyomi, onyomi, glossary = query
|
||||
return {
|
||||
'character': character,
|
||||
'kunyomi': kunyomi,
|
||||
'onyomi': onyomi,
|
||||
'glossary': glossary
|
||||
'glossary': glossary,
|
||||
'kunyomi': kunyomi,
|
||||
'onyomi': onyomi
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,13 +24,13 @@ import util
|
||||
class Translator:
|
||||
def __init__(self, deinflector, dictionary):
|
||||
self.deinflector = deinflector
|
||||
self.dictionary = dictionary
|
||||
self.dictionary = dictionary
|
||||
|
||||
|
||||
def findTerm(self, text, wildcards=False):
|
||||
text = util.sanitize(text, wildcards=wildcards)
|
||||
text = util.sanitize(text, wildcards=wildcards)
|
||||
groups = {}
|
||||
|
||||
groups = dict()
|
||||
for i in xrange(len(text), 0, -1):
|
||||
term = text[:i]
|
||||
deinflections = self.deinflector.deinflect(term, self.validator)
|
||||
@ -52,10 +52,10 @@ class Translator:
|
||||
|
||||
|
||||
def findCharacters(self, text):
|
||||
text = util.sanitize(text, kana=False)
|
||||
results = list()
|
||||
text = util.sanitize(text, kana=False)
|
||||
processed = {}
|
||||
results = []
|
||||
|
||||
processed = dict()
|
||||
for c in text:
|
||||
if c not in processed:
|
||||
match = self.dictionary.findCharacter(c)
|
||||
@ -79,11 +79,11 @@ class Translator:
|
||||
(expression, reading, glossary), (tags, source, rules) = group
|
||||
return {
|
||||
'expression': expression,
|
||||
'reading': reading,
|
||||
'glossary': glossary,
|
||||
'rules': rules,
|
||||
'source': source,
|
||||
'tags': tags
|
||||
'glossary': glossary,
|
||||
'reading': reading,
|
||||
'rules': rules,
|
||||
'source': source,
|
||||
'tags': tags
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Preferences(object):
|
||||
def __init__(self):
|
||||
self.filename = os.path.expanduser('~/.yomichan.json')
|
||||
self.defaults = os.path.join(os.path.dirname(__file__), 'defaults.json')
|
||||
self.settings = dict()
|
||||
self.settings = {}
|
||||
|
||||
|
||||
def __getitem__(self, name):
|
||||
@ -75,4 +75,4 @@ class Preferences(object):
|
||||
|
||||
|
||||
def clearRecentFiles(self):
|
||||
self['recentFiles'] = list()
|
||||
self['recentFiles'] = []
|
||||
|
@ -49,7 +49,6 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
|
||||
self.checkAllowEditing.setChecked(self.preferences['allowEditing'])
|
||||
self.checkLoadRecentFile.setChecked(self.preferences['loadRecentFile'])
|
||||
self.checkStripReadings.setChecked(self.preferences['stripReadings'])
|
||||
self.spinMaxResults.setValue(self.preferences['maxResults'])
|
||||
self.spinScanLength.setValue(self.preferences['scanLength'])
|
||||
self.checkEnableAnkiConnect.setChecked(self.preferences['enableAnkiConnect'])
|
||||
|
||||
@ -69,7 +68,6 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
|
||||
self.preferences['rememberTextContent'] = self.checkRememberTextContent.isChecked()
|
||||
self.preferences['allowEditing'] = self.checkAllowEditing.isChecked()
|
||||
self.preferences['loadRecentFile'] = self.checkLoadRecentFile.isChecked()
|
||||
self.preferences['maxResults'] = self.spinMaxResults.value()
|
||||
self.preferences['scanLength'] = self.spinScanLength.value()
|
||||
self.preferences['stripReadings'] = self.checkStripReadings.isChecked()
|
||||
self.preferences['enableAnkiConnect'] = self.checkEnableAnkiConnect.isChecked()
|
||||
|
@ -31,11 +31,11 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
||||
class State:
|
||||
def __init__(self):
|
||||
self.filename = unicode()
|
||||
self.searchText = unicode()
|
||||
self.kanjiDefs = []
|
||||
self.vocabDefs = []
|
||||
self.scanPosition = 0
|
||||
self.searchPosition = 0
|
||||
self.searchText = unicode()
|
||||
self.vocabDefs = []
|
||||
|
||||
|
||||
def __init__(self, parent, preferences, language, filename=None, anki=None, closed=None):
|
||||
@ -110,7 +110,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
||||
QtGui.QMessageBox.information(
|
||||
self,
|
||||
'Yomichan',
|
||||
'This may be the first time you are running Yomichan.\nPlease take some time to configure this extension.'
|
||||
'This may be the first time you are running Yomichan.\n' \
|
||||
'Please take some time to configure this extension.'
|
||||
)
|
||||
|
||||
self.onActionPreferences()
|
||||
@ -557,9 +558,6 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
||||
|
||||
|
||||
def updateDefs(self, defs, builder, control, **options):
|
||||
if options.get('trim', True):
|
||||
defs = defs[:self.preferences['maxResults']]
|
||||
|
||||
scrollbar = control.verticalScrollBar()
|
||||
position = scrollbar.sliderPosition()
|
||||
|
||||
@ -599,8 +597,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
||||
if self.dockKanji.isVisible():
|
||||
self.state.kanjiDefs += self.language.findCharacters(word)
|
||||
|
||||
self.updateVocabDefs(trim=False, scroll=True)
|
||||
self.updateKanjiDefs(trim=False, scroll=True)
|
||||
self.updateVocabDefs(scroll=True)
|
||||
self.updateKanjiDefs(scroll=True)
|
||||
|
||||
|
||||
def setStatus(self, status):
|
||||
|
Loading…
Reference in New Issue
Block a user