mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from custcol trunk
This commit is contained in:
commit
0e13648ba7
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__appname__ = 'calibre'
|
||||
__version__ = '0.6.91'
|
||||
__version__ = '0.6.92'
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
||||
import re
|
||||
|
@ -24,8 +24,8 @@ gprefs = JSONConfig('gui')
|
||||
NONE = QVariant() #: Null value to return from the data function of item models
|
||||
UNDEFINED_QDATE = QDate(UNDEFINED_DATE)
|
||||
|
||||
ALL_COLUMNS = ['title', 'authors', 'size', 'timestamp', 'rating', 'publisher',
|
||||
'tags', 'series', 'pubdate', 'ondevice']
|
||||
ALL_COLUMNS = ['title', 'ondevice', 'authors', 'size', 'timestamp', 'rating', 'publisher',
|
||||
'tags', 'series', 'pubdate']
|
||||
|
||||
def _config():
|
||||
c = Config('gui', 'preferences for the calibre GUI')
|
||||
|
@ -971,13 +971,29 @@ class DeviceGUI(object):
|
||||
|
||||
self.upload_booklists()
|
||||
|
||||
books_to_be_deleted = []
|
||||
if memory and memory[1]:
|
||||
books_to_be_deleted = memory[1]
|
||||
self.library_view.model().delete_books_by_id(books_to_be_deleted)
|
||||
|
||||
self.set_books_in_library(self.booklists(),
|
||||
reset=bool(books_to_be_deleted))
|
||||
|
||||
view = self.card_a_view if on_card == 'carda' else self.card_b_view if on_card == 'cardb' else self.memory_view
|
||||
view.model().resort(reset=False)
|
||||
view.model().research()
|
||||
for f in files:
|
||||
getattr(f, 'close', lambda : True)()
|
||||
if memory and memory[1]:
|
||||
self.library_view.model().delete_books_by_id(memory[1])
|
||||
|
||||
self.book_on_device(None, reset=True)
|
||||
if metadata:
|
||||
changed = set([])
|
||||
for mi in metadata:
|
||||
id_ = getattr(mi, 'application_id', None)
|
||||
if id_ is not None:
|
||||
changed.add(id_)
|
||||
if changed:
|
||||
self.library_view.model().refresh_ids(list(changed))
|
||||
|
||||
def book_on_device(self, index, format=None, reset=False):
|
||||
loc = [None, None, None]
|
||||
@ -1013,11 +1029,8 @@ class DeviceGUI(object):
|
||||
break
|
||||
return loc
|
||||
|
||||
def set_books_in_library(self, booklist, reset = False):
|
||||
def set_books_in_library(self, booklists, reset=False):
|
||||
if reset:
|
||||
self.book_in_library_cache = None
|
||||
return
|
||||
|
||||
# First build a self.book_in_library_cache of the library, so the search isn't On**2
|
||||
self.book_in_library_cache = {}
|
||||
for id, title in self.library_view.model().db.all_titles():
|
||||
@ -1031,6 +1044,7 @@ class DeviceGUI(object):
|
||||
self.book_in_library_cache[title]['db_ids'].add(id)
|
||||
|
||||
# Now iterate through all the books on the device, setting the in_library field
|
||||
for booklist in booklists:
|
||||
for book in booklist:
|
||||
book_title = book.title.lower() if book.title else ''
|
||||
book_title = re.sub('(?u)\W|[_]', '', book_title)
|
||||
|
@ -400,8 +400,8 @@ class BooksModel(QAbstractTableModel):
|
||||
if row == current_row:
|
||||
self.emit(SIGNAL('new_bookdisplay_data(PyQt_PyObject)'),
|
||||
self.get_book_display_info(row))
|
||||
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'),
|
||||
self.index(row, 0), self.index(row, self.columnCount(QModelIndex())-1))
|
||||
self.dataChanged.emit(self.index(row, 0), self.index(row,
|
||||
self.columnCount(QModelIndex())-1))
|
||||
|
||||
def close(self):
|
||||
self.db.close()
|
||||
@ -734,6 +734,7 @@ class BooksModel(QAbstractTableModel):
|
||||
img = self.default_image
|
||||
return img
|
||||
|
||||
|
||||
def build_data_convertors(self):
|
||||
def authors(r, idx=-1):
|
||||
au = self.db.data[r][idx]
|
||||
|
@ -993,16 +993,13 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
else:
|
||||
self.device_job_exception(job)
|
||||
return
|
||||
self.set_books_in_library(None, reset=True)
|
||||
self.set_books_in_library(job.result, reset=True)
|
||||
mainlist, cardalist, cardblist = job.result
|
||||
self.memory_view.set_database(mainlist)
|
||||
self.set_books_in_library(mainlist)
|
||||
self.memory_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
self.card_a_view.set_database(cardalist)
|
||||
self.set_books_in_library(cardalist)
|
||||
self.card_a_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
self.card_b_view.set_database(cardblist)
|
||||
self.set_books_in_library(cardblist)
|
||||
self.card_b_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
for view in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||
view.sortByColumn(3, Qt.DescendingOrder)
|
||||
|
Loading…
x
Reference in New Issue
Block a user