Commit 9dbf8c4e authored by Dan Pascu's avatar Dan Pascu

Made method private as it is only used internally

parent d59cef51
...@@ -484,7 +484,7 @@ class ContactModel(QAbstractListModel): ...@@ -484,7 +484,7 @@ class ContactModel(QAbstractListModel):
# emulate beginResetModel/endResetModel for QT < 4.6 # 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.beginResetModel = Null # or use self.modelAboutToBeReset.emit (it'll be emited twice though in that case)
self.endResetModel = self.reset 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()
self.bonjour_group = None self.bonjour_group = None
...@@ -690,6 +690,21 @@ class ContactModel(QAbstractListModel): ...@@ -690,6 +690,21 @@ class ContactModel(QAbstractListModel):
self.endRemoveRows() self.endRemoveRows()
return items return items
def _store_contacts(self, data):
makedirs(ApplicationData.directory)
filename = ApplicationData.get('contacts')
tmp_filename = ApplicationData.get('contacts.tmp')
bak_filename = ApplicationData.get('contacts.bak')
file = open(tmp_filename, 'wb')
file.write(data)
file.close()
try:
os.rename(filename, bak_filename)
except OSError, e:
if e.errno != errno.ENOENT:
raise
os.rename(tmp_filename, filename)
@updates_contacts_db @updates_contacts_db
def addContact(self, contact): def addContact(self, contact):
if contact in self.items: if contact in self.items:
...@@ -809,21 +824,6 @@ class ContactModel(QAbstractListModel): ...@@ -809,21 +824,6 @@ class ContactModel(QAbstractListModel):
items.insert(position, group) items.insert(position, group)
self.save_queue.put(pickle.dumps(items)) self.save_queue.put(pickle.dumps(items))
def store_contacts(self, data):
makedirs(ApplicationData.directory)
filename = ApplicationData.get('contacts')
tmp_filename = ApplicationData.get('contacts.tmp')
bak_filename = ApplicationData.get('contacts.bak')
file = open(tmp_filename, 'wb')
file.write(data)
file.close()
try:
os.rename(filename, bak_filename)
except OSError, e:
if e.errno != errno.ENOENT:
raise
os.rename(tmp_filename, filename)
@run_in_gui_thread @run_in_gui_thread
def handle_notification(self, notification): def handle_notification(self, notification):
handler = getattr(self, '_NH_%s' % notification.name, Null) handler = getattr(self, '_NH_%s' % notification.name, Null)
......
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