mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Rescan all files when indexing is enabled
This commit is contained in:
parent
d4e85f06c5
commit
0199dd15ba
@ -438,10 +438,12 @@ class Cache:
|
||||
return self.backend.fts_enabled
|
||||
|
||||
@write_api
|
||||
def enable_fts(self, enabled=True, start_pool=True):
|
||||
def enable_fts(self, enabled=True, start_pool=True, mark_all_dirty=False):
|
||||
fts = self.backend.enable_fts(weakref.ref(self) if enabled else None)
|
||||
if fts and start_pool: # used in the tests
|
||||
from threading import Thread
|
||||
if mark_all_dirty:
|
||||
fts.dirty_existing()
|
||||
self.fts_queue_thread = Thread(name='FTSQueue', target=Cache.dispatch_fts_jobs, args=(self.fts_job_queue, weakref.ref(self)), daemon=True)
|
||||
self.fts_queue_thread.start()
|
||||
fts.pool.initialize()
|
||||
|
@ -3,7 +3,7 @@
|
||||
# License: GPL v3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
from qt.core import QCheckBox, QVBoxLayout, QWidget
|
||||
from qt.core import QCheckBox, QLabel, QVBoxLayout, QWidget
|
||||
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.fts.utils import get_db
|
||||
@ -14,26 +14,36 @@ class ScanStatus(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.l = l = QVBoxLayout(self)
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
self.enable_fts = b = QCheckBox(self)
|
||||
b.setText(_('Index books in this library to allow searching their full text'))
|
||||
b.setText(_('&Index books in this library to allow searching their full text'))
|
||||
l.addWidget(b)
|
||||
self.enable_msg = la = QLabel('<p>' + _(
|
||||
'In order to search the full text of books, the text must first be <i>indexed</i>. Once enabled, indexing is done'
|
||||
' automatically, in the background, whenever new books are added to this calibre library.'))
|
||||
la.setWordWrap(True)
|
||||
l.addWidget(la)
|
||||
|
||||
l.addStretch(10)
|
||||
self.apply_fts_state()
|
||||
b.toggled.connect(self.change_fts_state)
|
||||
self.enable_fts.toggled.connect(self.change_fts_state)
|
||||
|
||||
def change_fts_state(self):
|
||||
if not self.enable_fts.isChecked():
|
||||
if not confirm(_('Disabling indexing will mean that all books will have to be re-scanned when re-enabling indexing.'
|
||||
' Are you sure?'), 'disable-fts-indexing', self):
|
||||
return
|
||||
self.db.enable_fts(enabled=self.enable_fts.isChecked())
|
||||
if not self.enable_fts.isChecked() and not confirm(_(
|
||||
'Disabling indexing will mean that all books will have to be re-checked when re-enabling indexing. Are you sure?'
|
||||
), 'disable-fts-indexing', self):
|
||||
return
|
||||
self.db.enable_fts(enabled=self.enable_fts.isChecked(), mark_all_dirty=True)
|
||||
self.apply_fts_state()
|
||||
|
||||
def apply_fts_state(self):
|
||||
b = self.enable_fts
|
||||
f = b.font()
|
||||
f.setBold(not b.isChecked())
|
||||
indexing_enabled = b.isChecked()
|
||||
f.setBold(not indexing_enabled)
|
||||
b.setFont(f)
|
||||
self.enable_msg.setVisible(not indexing_enabled)
|
||||
|
||||
@property
|
||||
def db(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user