Initial progress dialog for history rebuild
This commit is contained in:
parent
c8be2d4f7e
commit
2109b2276e
@ -24,6 +24,7 @@ import time
|
|||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, QTimer, pyqtSignal
|
from PyQt5.QtCore import pyqtSlot, QUrl, QTimer, pyqtSignal
|
||||||
|
from PyQt5.QtWidgets import QProgressDialog, QApplication
|
||||||
|
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.commands import cmdutils, cmdexc
|
from qutebrowser.commands import cmdutils, cmdexc
|
||||||
@ -160,7 +161,23 @@ class WebHistory(sql.SqlTable):
|
|||||||
q = sql.Query('SELECT url, title, max(atime) AS atime FROM History '
|
q = sql.Query('SELECT url, title, max(atime) AS atime FROM History '
|
||||||
'WHERE NOT redirect and url NOT LIKE "qute://back%" '
|
'WHERE NOT redirect and url NOT LIKE "qute://back%" '
|
||||||
'GROUP BY url ORDER BY atime asc')
|
'GROUP BY url ORDER BY atime asc')
|
||||||
for entry in q.run():
|
entries = list(q.run())
|
||||||
|
|
||||||
|
if len(entries) > 1000:
|
||||||
|
progress = QProgressDialog()
|
||||||
|
progress.setLabelText("Rebuilding completion...")
|
||||||
|
progress.show()
|
||||||
|
progress.setMaximum(len(entries))
|
||||||
|
progress.setCancelButton(None)
|
||||||
|
QApplication.processEvents()
|
||||||
|
else:
|
||||||
|
progress = None
|
||||||
|
|
||||||
|
for i, entry in enumerate(entries):
|
||||||
|
if progress is not None:
|
||||||
|
progress.setValue(i)
|
||||||
|
QApplication.processEvents()
|
||||||
|
|
||||||
url = QUrl(entry.url)
|
url = QUrl(entry.url)
|
||||||
if self._is_excluded(url):
|
if self._is_excluded(url):
|
||||||
continue
|
continue
|
||||||
@ -168,6 +185,9 @@ class WebHistory(sql.SqlTable):
|
|||||||
data['title'].append(entry.title)
|
data['title'].append(entry.title)
|
||||||
data['last_atime'].append(entry.atime)
|
data['last_atime'].append(entry.atime)
|
||||||
|
|
||||||
|
if progress is not None:
|
||||||
|
progress.hide()
|
||||||
|
|
||||||
self.completion.insert_batch(data, replace=True)
|
self.completion.insert_batch(data, replace=True)
|
||||||
sql.Query('pragma user_version = {}'.format(_USER_VERSION)).run()
|
sql.Query('pragma user_version = {}'.format(_USER_VERSION)).run()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user