diff --git a/src/fastwq/lang.py b/src/fastwq/lang.py
index 4513c63..01612b0 100644
--- a/src/fastwq/lang.py
+++ b/src/fastwq/lang.py
@@ -58,6 +58,7 @@ arr = [
['FORCE_UPDATE', u'强制更新字段', u'Force Update Fields'],
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
['SKIP_VALUED', u'跳过有值项', u'Skip Valued'],
+ ['SKIPED', u'略过', 'Skip'],
['SETTINGS', u'参数', u'Settings'],
['THREAD_NUMBER', u'线程数', u'Thread Number'],
['INITLIZING_DICT', u'初始化词典...', u'Initlizing Dictionary...'],
diff --git a/src/fastwq/progress.py b/src/fastwq/progress.py
index e52eced..a299aa5 100644
--- a/src/fastwq/progress.py
+++ b/src/fastwq/progress.py
@@ -21,10 +21,19 @@
import time
from collections import defaultdict
-from aqt.qt import *
+from PyQt4 import QtCore, QtGui
from .lang import _
+INFO_TEMPLATE = u''.join([
+ _('QUERIED') + u'
' + 45 * u'-' + u'
',
+ _('SUCCESS') + u' {} ' + _('WORDS') + u'
',
+ _('SKIPED') + u' {} ' + _('WORDS') + u'
',
+ _('UPDATE') + u' {} ' + _('FIELDS') + u'
',
+ _('FAILURE') + u' {} ' + _('WORDS') + u'
'
+])
+
+
class ProgressWindow(object):
"""
Query progress window
@@ -32,7 +41,7 @@ class ProgressWindow(object):
def __init__(self, mw):
self.mw = mw
- self.app = QApplication.instance()
+ self.app = QtGui.QApplication.instance()
self._win = None
self._msg_count = defaultdict(int)
@@ -45,22 +54,20 @@ class ProgressWindow(object):
else:
return
- number_info = ''
- words_number, fields_number, fails_number = (
- self._msg_count['words_number'],
- self._msg_count['fields_number'],
- self._msg_count['fails_number']
+ words_number, fields_number, fails_number, skips_number = (
+ self._msg_count.get('words_number', 0),
+ self._msg_count.get('fields_number', 0),
+ self._msg_count.get('fails_number', 0),
+ self._msg_count.get('skips_number', 0)
+ )
+ number_info = INFO_TEMPLATE.format(
+ words_number,
+ skips_number,
+ fields_number,
+ fails_number
)
- if words_number or fields_number:
- number_info += _('QUERIED') + u'
' + 45 * u'-'
- number_info += u'
{0}: {1} {2}'.format(
- _('SUCCESS'), words_number, _('WORDS'))
- number_info += u'
{0}: {1} {2}'.format(
- _('UPDATE'), fields_number, _('FIELDS'))
- number_info += u'
{0}: {1} {2}'.format(
- _('FAILURE'), fails_number, _('WORDS'))
- self._update(label=number_info, value=words_number)
+ self._update(label=number_info, value=words_number+skips_number+fails_number)
self._win.adjustSize()
def update_title(self, title):
@@ -73,8 +80,8 @@ class ProgressWindow(object):
# setup window
label = label or _("Processing...")
parent = parent or self.app.activeWindow() or self.mw
- self._win = QProgressDialog(label, '', min, max, parent)
- self._win.setWindowModality(Qt.ApplicationModal)
+ self._win = QtGui.QProgressDialog(label, '', min, max, parent)
+ self._win.setWindowModality(QtCore.Qt.ApplicationModal)
self._win.setCancelButton(None)
self._win.canceled.connect(self.finish)
self._win.setWindowTitle("Querying...")
@@ -107,12 +114,12 @@ class ProgressWindow(object):
self._counter = value or (self._counter + 1)
self._win.setValue(self._counter)
if process and elapsed >= 0.2:
- self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
+ self.app.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
self._lastUpdate = time.time()
def _setBusy(self):
self._disabled = True
- self.mw.app.setOverrideCursor(QCursor(Qt.WaitCursor))
+ self.mw.app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
def _unsetBusy(self):
self._disabled = False
diff --git a/src/fastwq/query.py b/src/fastwq/query.py
index 1775b11..a07b180 100644
--- a/src/fastwq/query.py
+++ b/src/fastwq/query.py
@@ -118,6 +118,7 @@ class QueryWorkerManager(object):
self.counter = 0
self.fails = 0
self.fields = 0
+ self.skips = 0
self.missed_css = list()
def get_worker(self):
@@ -143,8 +144,10 @@ class QueryWorkerManager(object):
self.mutex.lock()
if success_num > 0:
self.counter += 1
- else:
+ elif success_num == 0:
self.fails += 1
+ else:
+ self.skips += 1
val = update_note_fields(note, results)
self.fields += val
self.missed_css += missed_css
@@ -165,6 +168,7 @@ class QueryWorkerManager(object):
self.progress.update_labels(MapDict(
type='count',
words_number = self.counter,
+ skips_number = self.skips,
fails_number = self.fails,
fields_number = self.fields))
mw.app.processEvents()
@@ -370,7 +374,7 @@ def query_all_flds(note):
continue
#skip valued
skip = each.get('skip_valued', False)
- if skip and not note.fields[i]:
+ if skip and len(note.fields[i]) != 0:
continue
#normal
dict_name = each.get('dict', '').strip()
@@ -397,7 +401,7 @@ def query_all_flds(note):
#except:
# showInfo(_("NO_QUERY_WORD"))
# pass
-
+
missed_css = list()
for service in services.values():
if isinstance(service, LocalService):
@@ -409,4 +413,4 @@ def query_all_flds(note):
})
service_pool.put(service)
- return result, success_num, missed_css
+ return result, -1 if len(tasks) == 0 else success_num, missed_css