fix #34
This commit is contained in:
parent
ea09a11c3d
commit
6c38349cc3
@ -96,11 +96,11 @@ def customize_addcards():
|
||||
if isinstance(e, QMouseEvent):
|
||||
if e.buttons() & Qt.LeftButton:
|
||||
menu = QMenu(self)
|
||||
menu.addAction(_("Query"), lambda: query_from_editor_all_fields(self.editor), QKeySequence(my_shortcut))
|
||||
menu.addAction(_("Query"), lambda: query_from_editor_all_fields(self.editor, False), QKeySequence(my_shortcut))
|
||||
menu.addAction(_("Options"), lambda: show_options(self, self.editor.note.model()['id']))
|
||||
menu.exec_(fastwqBtn.mapToGlobal(QPoint(0, fastwqBtn.height())))
|
||||
else:
|
||||
query_from_editor_all_fields(self.editor)
|
||||
query_from_editor_all_fields(self.editor, False)
|
||||
|
||||
fastwqBtn.mousePressEvent = onQuery
|
||||
fastwqBtn.clicked.connect(onQuery)
|
||||
|
||||
@ -58,7 +58,7 @@ def query_from_browser(browser):
|
||||
# browser.model.reset()
|
||||
|
||||
|
||||
def query_from_editor_all_fields(editor):
|
||||
def query_from_editor_all_fields(editor, flush=True):
|
||||
"""
|
||||
Query word fileds from Editor
|
||||
"""
|
||||
@ -84,12 +84,12 @@ def query_from_editor_all_fields(editor):
|
||||
editor
|
||||
)
|
||||
else:
|
||||
query_all([editor.note])
|
||||
query_all([editor.note], flush)
|
||||
editor.setNote(editor.note, focus=True)
|
||||
editor.saveNow()
|
||||
|
||||
|
||||
def query_all(notes):
|
||||
def query_all(notes, flush=True):
|
||||
"""
|
||||
Query maps word fileds
|
||||
"""
|
||||
@ -100,6 +100,7 @@ def query_all(notes):
|
||||
work_manager = QueryWorkerManager()
|
||||
#work_manager.reset()
|
||||
#progress.start(max=len(notes), min=0, immediate=True)
|
||||
work_manager.flush = flush
|
||||
queue = work_manager.queue
|
||||
|
||||
for note in notes:
|
||||
|
||||
@ -91,6 +91,7 @@ class QueryWorkerManager(object):
|
||||
self.fields = 0
|
||||
self.skips = 0
|
||||
self.missed_css = list()
|
||||
self.flush = True
|
||||
|
||||
def get_worker(self):
|
||||
worker = QueryThread(self)
|
||||
@ -155,5 +156,5 @@ class QueryWorkerManager(object):
|
||||
|
||||
@QtCore.pyqtSlot(object)
|
||||
def handle_flush(self, note):
|
||||
if note:
|
||||
if self.flush and note:
|
||||
note.flush()
|
||||
|
||||
@ -96,11 +96,11 @@ def customize_addcards():
|
||||
if isinstance(e, QMouseEvent):
|
||||
if e.buttons() & Qt.LeftButton:
|
||||
menu = QMenu(self)
|
||||
menu.addAction(_("Query"), lambda: query_from_editor_all_fields(self.editor), QKeySequence(my_shortcut))
|
||||
menu.addAction(_("Query"), lambda: query_from_editor_all_fields(self.editor, False), QKeySequence(my_shortcut))
|
||||
menu.addAction(_("Options"), lambda: show_options(self, self.editor.note.model()['id']))
|
||||
menu.exec_(fastwqBtn.mapToGlobal(QPoint(0, fastwqBtn.height())))
|
||||
else:
|
||||
query_from_editor_all_fields(self.editor)
|
||||
query_from_editor_all_fields(self.editor, False)
|
||||
|
||||
fastwqBtn.mousePressEvent = onQuery
|
||||
fastwqBtn.clicked.connect(onQuery)
|
||||
|
||||
@ -58,7 +58,7 @@ def query_from_browser(browser):
|
||||
# browser.model.reset()
|
||||
|
||||
|
||||
def query_from_editor_all_fields(editor):
|
||||
def query_from_editor_all_fields(editor, flush=True):
|
||||
"""
|
||||
Query word fileds from Editor
|
||||
"""
|
||||
@ -85,12 +85,12 @@ def query_from_editor_all_fields(editor):
|
||||
)
|
||||
else:
|
||||
editor.setNote(editor.note)
|
||||
query_all([editor.note])
|
||||
query_all([editor.note], flush)
|
||||
editor.setNote(editor.note, focusTo=0)
|
||||
editor.saveNow(lambda:None)
|
||||
|
||||
|
||||
def query_all(notes):
|
||||
def query_all(notes, flush=True):
|
||||
"""
|
||||
Query maps word fileds
|
||||
"""
|
||||
@ -101,6 +101,7 @@ def query_all(notes):
|
||||
work_manager = QueryWorkerManager()
|
||||
#work_manager.reset()
|
||||
#progress.start(max=len(notes), min=0, immediate=True)
|
||||
work_manager.flush = flush
|
||||
queue = work_manager.queue
|
||||
|
||||
for note in notes:
|
||||
|
||||
@ -92,6 +92,7 @@ class QueryWorkerManager(object):
|
||||
self.fields = 0
|
||||
self.skips = 0
|
||||
self.missed_css = list()
|
||||
self.flush = True
|
||||
|
||||
def get_worker(self):
|
||||
worker = QueryThread(self)
|
||||
@ -155,5 +156,5 @@ class QueryWorkerManager(object):
|
||||
self.progress.finish()
|
||||
|
||||
def handle_flush(self, note):
|
||||
if note:
|
||||
if self.flush and note:
|
||||
note.flush()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user