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
144d018b91
@ -49,7 +49,7 @@ class Book(object):
|
||||
@property
|
||||
def db_id(self):
|
||||
'''The database id in the application database that this file corresponds to'''
|
||||
match = re.search(r'_(\d+)$', self.rpath.rpartition('.')[0])
|
||||
match = re.search(r'_(\d+)$', self.path.rpartition('.')[0])
|
||||
if match:
|
||||
return int(match.group(1))
|
||||
|
||||
|
@ -788,6 +788,12 @@ class BooksModel(QAbstractTableModel):
|
||||
return self.bool_blank_icon
|
||||
return self.bool_no_icon
|
||||
|
||||
def ondevice_decorator(r, idx=-1):
|
||||
text = self.db.data[r][idx]
|
||||
if text:
|
||||
return self.bool_yes_icon
|
||||
return self.bool_blank_icon
|
||||
|
||||
def text_type(r, mult=False, idx=-1):
|
||||
text = self.db.data[r][idx]
|
||||
if text and mult:
|
||||
@ -820,7 +826,11 @@ class BooksModel(QAbstractTableModel):
|
||||
'ondevice' : functools.partial(text_type,
|
||||
idx=self.db.FIELD_MAP['ondevice'], mult=False),
|
||||
}
|
||||
self.dc_decorator = {}
|
||||
|
||||
self.dc_decorator = {
|
||||
'ondevice':functools.partial(ondevice_decorator,
|
||||
idx=self.db.FIELD_MAP['ondevice']),
|
||||
}
|
||||
|
||||
# Add the custom columns to the data converters
|
||||
for col in self.custom_columns:
|
||||
@ -1420,11 +1430,11 @@ class DeviceBooksModel(BooksModel):
|
||||
'''
|
||||
Return indices into underlying database from rows
|
||||
'''
|
||||
return [ self.map[r.row()] for r in rows]
|
||||
return [self.map[r.row()] for r in rows]
|
||||
|
||||
def data(self, index, role):
|
||||
if role == Qt.DisplayRole or role == Qt.EditRole:
|
||||
row, col = index.row(), index.column()
|
||||
if role == Qt.DisplayRole or role == Qt.EditRole:
|
||||
if col == 0:
|
||||
text = self.db[self.map[row]].title
|
||||
if not text:
|
||||
@ -1449,9 +1459,6 @@ class DeviceBooksModel(BooksModel):
|
||||
tags = self.db[self.map[row]].tags
|
||||
if tags:
|
||||
return QVariant(', '.join(tags))
|
||||
elif col == 5:
|
||||
return QVariant(_('Yes')) \
|
||||
if self.db[self.map[row]].in_library else QVariant(_('No'))
|
||||
elif role == Qt.TextAlignmentRole and index.column() in [2, 3]:
|
||||
return QVariant(Qt.AlignRight | Qt.AlignVCenter)
|
||||
elif role == Qt.ToolTipRole and index.isValid():
|
||||
@ -1460,6 +1467,10 @@ class DeviceBooksModel(BooksModel):
|
||||
col = index.column()
|
||||
if col in [0, 1] or (col == 4 and self.db.supports_tags()):
|
||||
return QVariant(_("Double click to <b>edit</b> me<br><br>"))
|
||||
elif role == Qt.DecorationRole and col == 5:
|
||||
if self.db[self.map[row]].in_library:
|
||||
return QVariant(self.bool_yes_icon)
|
||||
|
||||
return NONE
|
||||
|
||||
def headerData(self, section, orientation, role):
|
||||
|
Loading…
x
Reference in New Issue
Block a user