Cleanup
Former-commit-id: 9810f65c42e33af17c2db976c5859a60654e2ded
This commit is contained in:
parent
395e4e489f
commit
9e5cddea50
@ -244,21 +244,18 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
markup = reader_util.markupVocabReading(definition)
|
markup = reader_util.markupVocabReading(definition)
|
||||||
self.ankiAddFact('vocab', markup)
|
self.ankiAddFact('vocab', markup)
|
||||||
elif command == 'copyVocabDef':
|
elif command == 'copyVocabDef':
|
||||||
reader_util.copyVocabDefs([definition])
|
reader_util.copyVocabDef(definition)
|
||||||
|
|
||||||
|
|
||||||
def onKanjiDefsAnchorClicked(self, url):
|
def onKanjiDefsAnchorClicked(self, url):
|
||||||
command, index = unicode(url.toString()).split(':')
|
command, index = unicode(url.toString()).split(':')
|
||||||
definition = self.state.kanjiDefs[int(index)]
|
definition = self.state.kanjiDefs[int(index)]
|
||||||
|
|
||||||
if command == 'addVocabExp':
|
if command == 'addKanji':
|
||||||
markup = reader_util.markupVocabExp(definition)
|
markup = reader_util.markupKanji(definition)
|
||||||
self.ankiAddFact('vocab', markup)
|
self.ankiAddFact('kanji', markup)
|
||||||
if command == 'addVocabReading':
|
elif command == 'copyKanjiDef':
|
||||||
markup = reader_util.markupVocabReading(definition)
|
reader_util.copyKanjiDef(definition)
|
||||||
self.ankiAddFact('vocab', markup)
|
|
||||||
elif command == 'copyVocabDef':
|
|
||||||
reader_util.copyVocabDefs([definition])
|
|
||||||
|
|
||||||
|
|
||||||
def onVocabDefSearchReturn(self):
|
def onVocabDefSearchReturn(self):
|
||||||
@ -280,7 +277,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
|
|
||||||
def onDefinitionDoubleClicked(self, item):
|
def onDefinitionDoubleClicked(self, item):
|
||||||
if self.anki is not None:
|
if self.anki is not None:
|
||||||
row = self.istDefinitions.row(item)
|
row = self.listDefinitions.row(item)
|
||||||
self.anki.browseNote(self.addedFacts[row])
|
self.anki.browseNote(self.addedFacts[row])
|
||||||
|
|
||||||
|
|
||||||
@ -454,18 +451,10 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
if factId is None:
|
if factId is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if profile == 'vocab':
|
|
||||||
if markup['reading']:
|
|
||||||
summary = u'{expression} [{reading}]'.format(**markup)
|
|
||||||
else:
|
|
||||||
summary = markup['expression']
|
|
||||||
else:
|
|
||||||
summary = markup['character']
|
|
||||||
|
|
||||||
self.addedFacts.append(factId)
|
self.addedFacts.append(factId)
|
||||||
self.listDefinitions.addItem(summary)
|
self.listDefinitions.addItem(markup['summary'])
|
||||||
self.listDefinitions.setCurrentRow(self.listDefinitions.count() - 1)
|
self.listDefinitions.setCurrentRow(self.listDefinitions.count() - 1)
|
||||||
self.setStatus(u'Added expression {0}; {1} new fact(s) total'.format(markup['expression'], len(self.addedFacts)))
|
self.setStatus(u'Added fact {0}; {1} new fact(s) total'.format(markup['summary'], len(self.addedFacts)))
|
||||||
|
|
||||||
self.updateVocabDefs()
|
self.updateVocabDefs()
|
||||||
self.updateKanjiDefs()
|
self.updateKanjiDefs()
|
||||||
|
@ -97,7 +97,8 @@ def markupVocabExp(definition):
|
|||||||
'expression': definition['expression'],
|
'expression': definition['expression'],
|
||||||
'reading': definition['reading'],
|
'reading': definition['reading'],
|
||||||
'glossary': definition['glossary'],
|
'glossary': definition['glossary'],
|
||||||
'sentence': definition.get('sentence')
|
'sentence': definition.get('sentence'),
|
||||||
|
'summary': u'{expression} [{reading}]'.format(**definition)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,20 +107,28 @@ def markupVocabReading(definition):
|
|||||||
'expression': definition['reading'],
|
'expression': definition['reading'],
|
||||||
'reading': unicode(),
|
'reading': unicode(),
|
||||||
'glossary': definition['glossary'],
|
'glossary': definition['glossary'],
|
||||||
'sentence': definition.get('sentence')
|
'sentence': definition.get('sentence'),
|
||||||
|
'summary': definition['reading']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def copyVocabDefs(definitions):
|
def copyVocabDef(definition):
|
||||||
text = unicode()
|
if definition['reading']:
|
||||||
|
result = u'{expression}\t{reading}\t{glossary}\n'.format(**definition)
|
||||||
|
else:
|
||||||
|
result = u'{expression}\t{meanings}\n'.format(**definition)
|
||||||
|
|
||||||
for definition in definitions:
|
QtGui.QApplication.clipboard().setText(result)
|
||||||
if definition['reading']:
|
|
||||||
text += u'{expression}\t{reading}\t{glossary}\n'.format(**definition)
|
|
||||||
else:
|
|
||||||
text += u'{expression}\t{meanings}\n'.format(**definition)
|
|
||||||
|
|
||||||
QtGui.QApplication.clipboard().setText(text)
|
|
||||||
|
def markupKanji(definition):
|
||||||
|
return {
|
||||||
|
'character': definition['character'],
|
||||||
|
'onyomi': definition['onyomi'],
|
||||||
|
'kunyomi': definition['kunyomi'],
|
||||||
|
'glossary': definition['glossary'],
|
||||||
|
'summary': definition['character']
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def buildDefHeader():
|
def buildDefHeader():
|
||||||
@ -181,7 +190,7 @@ def buildVocabDefs(definitions, query):
|
|||||||
|
|
||||||
def buildKanjiDef(definition, index, query):
|
def buildKanjiDef(definition, index, query):
|
||||||
links = '<a href = "copyKanjiDef:{0}"><img src = "://img/img/icon_copy_definition.png" align = "right"/></a>'.format(index)
|
links = '<a href = "copyKanjiDef:{0}"><img src = "://img/img/icon_copy_definition.png" align = "right"/></a>'.format(index)
|
||||||
if query and query('kanji', definition):
|
if query and query('kanji', markupKanji(definition)):
|
||||||
links += '<a href = "addKanji:{0}"><img src = "://img/img/icon_add_expression.png" align = "right"/></a>'.format(index)
|
links += '<a href = "addKanji:{0}"><img src = "://img/img/icon_add_expression.png" align = "right"/></a>'.format(index)
|
||||||
|
|
||||||
html = u"""
|
html = u"""
|
||||||
|
Loading…
Reference in New Issue
Block a user