Commit 80bd2578 authored by Dan Pascu's avatar Dan Pascu

Simplified model reset when loading contacts

parent 4092127d
...@@ -410,6 +410,10 @@ class ContactModel(QAbstractListModel): ...@@ -410,6 +410,10 @@ class ContactModel(QAbstractListModel):
self.items = [] self.items = []
self.deleted_items = [] self.deleted_items = []
self.contact_list = parent.contact_list self.contact_list = parent.contact_list
if not hasattr(self, 'beginResetModel'):
# emulate beginResetModel/endResetModel for QT < 4.6
self.beginResetModel = Null # or use self.modelAboutToBeReset.emit (it'll be emited twice though in that case)
self.endResetModel = self.reset
self.save_queue = EventQueue(self.store_contacts, name='ContactsSavingThread') self.save_queue = EventQueue(self.store_contacts, name='ContactsSavingThread')
self.save_queue.start() self.save_queue.start()
...@@ -646,14 +650,9 @@ class ContactModel(QAbstractListModel): ...@@ -646,14 +650,9 @@ class ContactModel(QAbstractListModel):
Contact(group, 'VUC Conference', '200901@login.zipdx.com', 'icons/200901@login.zipdx.com.png')] Contact(group, 'VUC Conference', '200901@login.zipdx.com', 'icons/200901@login.zipdx.com.png')]
contacts.sort(key=attrgetter('name')) contacts.sort(key=attrgetter('name'))
items = [group] + contacts items = [group] + contacts
if self.items: self.beginResetModel()
self.beginRemoveRows(QModelIndex(), 0, len(self.items)-1) self.items = items
del self.items[:] self.endResetModel()
self.endRemoveRows()
if items:
self.beginInsertRows(QModelIndex(), 0, len(items)-1)
self.items = items
self.endInsertRows()
for position, item in enumerate(self.items): for position, item in enumerate(self.items):
if type(item) is ContactGroup: if type(item) is ContactGroup:
self.contact_list.openPersistentEditor(self.index(position)) self.contact_list.openPersistentEditor(self.index(position))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment