mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Finally fix the random crash issue when adding books
This commit is contained in:
parent
f4eca6d724
commit
bbcb77ab24
@ -75,6 +75,13 @@ class TagTreeItem(object):
|
|||||||
elif self.type == self.TAG:
|
elif self.type == self.TAG:
|
||||||
self.tag, self.icon_map = data, list(map(QVariant, icon_map))
|
self.tag, self.icon_map = data, list(map(QVariant, icon_map))
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if self.type == self.ROOT:
|
||||||
|
return 'ROOT'
|
||||||
|
if self.type == self.CATEGORY:
|
||||||
|
return 'CATEGORY:'+self.name+':%d'%len(self.children)
|
||||||
|
return 'TAG:'+self.tag.name
|
||||||
|
|
||||||
def row(self):
|
def row(self):
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
return self.parent.children.index(self)
|
return self.parent.children.index(self)
|
||||||
@ -132,11 +139,12 @@ class TagsModel(QAbstractItemModel):
|
|||||||
for tag in data[r]:
|
for tag in data[r]:
|
||||||
t = TagTreeItem(parent=c, data=tag, icon_map=self.icon_map)
|
t = TagTreeItem(parent=c, data=tag, icon_map=self.icon_map)
|
||||||
|
|
||||||
self.refresh()
|
|
||||||
self.db.add_listener(self.database_changed)
|
self.db.add_listener(self.database_changed)
|
||||||
|
self.connect(self, SIGNAL('need_refresh()'), self.refresh,
|
||||||
|
Qt.QueuedConnection)
|
||||||
|
|
||||||
def database_changed(self, event, ids):
|
def database_changed(self, event, ids):
|
||||||
self.refresh()
|
self.emit(SIGNAL('need_refresh()'))
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
data = self.db.get_categories(config['sort_by_popularity'])
|
data = self.db.get_categories(config['sort_by_popularity'])
|
||||||
@ -147,7 +155,6 @@ class TagsModel(QAbstractItemModel):
|
|||||||
state_map = dict(izip(names, states))
|
state_map = dict(izip(names, states))
|
||||||
category_index = self.index(i, 0, QModelIndex())
|
category_index = self.index(i, 0, QModelIndex())
|
||||||
if len(category.children) > 0:
|
if len(category.children) > 0:
|
||||||
r, self.rowCount(category_index)
|
|
||||||
self.beginRemoveRows(category_index, 0,
|
self.beginRemoveRows(category_index, 0,
|
||||||
len(category.children)-1)
|
len(category.children)-1)
|
||||||
category.children = []
|
category.children = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user