bug fixes and history export
This commit is contained in:
parent
ae50efa2e6
commit
44e5e7d0a6
5 changed files with 20 additions and 2 deletions
|
@ -21,6 +21,15 @@ class History(object):
|
|||
')')
|
||||
db.close()
|
||||
|
||||
def export(self, directory):
|
||||
path = Settings.get_default_path() + self._name + '.hstr'
|
||||
new_path = directory + self._name + '.hstr'
|
||||
with open(path, 'rb') as fin:
|
||||
data = fin.read()
|
||||
with open(new_path, 'wb') as fout:
|
||||
fout.write(data)
|
||||
print 'History exported to: {}'.format(new_path)
|
||||
|
||||
def add_friend_to_db(self, tox_id):
|
||||
chdir(Settings.get_default_path())
|
||||
db = connect(self._name + '.hstr')
|
||||
|
|
|
@ -41,11 +41,11 @@ class MessageItem(QtGui.QListWidget):
|
|||
def __init__(self, text, time, user='', message_type=TOX_MESSAGE_TYPE['NORMAL'], parent=None):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.name = QtGui.QLabel(self)
|
||||
self.name.setGeometry(QtCore.QRect(0, 0, 95, 40))
|
||||
self.name.setGeometry(QtCore.QRect(0, 0, 95, 20))
|
||||
self.name.setTextFormat(QtCore.Qt.PlainText)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(12)
|
||||
font.setPointSize(11)
|
||||
font.setBold(True)
|
||||
self.name.setFont(font)
|
||||
self.name.setObjectName("name")
|
||||
|
|
|
@ -73,8 +73,10 @@ class Toxygen(object):
|
|||
self.mainloop.start()
|
||||
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
||||
app.exec_()
|
||||
self.init.stop = True
|
||||
self.mainloop.stop = True
|
||||
self.mainloop.wait()
|
||||
self.init.wait()
|
||||
data = self.tox.get_savedata()
|
||||
ProfileHelper.save_profile(data)
|
||||
del self.tox
|
||||
|
|
|
@ -178,6 +178,8 @@ class ProfileSettings(CenteredWidget):
|
|||
ProfileHelper.export_profile(directory)
|
||||
settings = Settings.get_instance()
|
||||
settings.export(directory)
|
||||
profile = Profile.get_instance()
|
||||
profile.export_history(directory)
|
||||
|
||||
def closeEvent(self, event):
|
||||
profile = Profile.get_instance()
|
||||
|
|
|
@ -186,6 +186,7 @@ class Friend(Contact):
|
|||
def __del__(self):
|
||||
self.set_visibility(False)
|
||||
del self._widget
|
||||
del self._message_getter
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# History support
|
||||
|
@ -210,6 +211,7 @@ class Friend(Contact):
|
|||
Get data to save in db
|
||||
:return: list of unsaved messages or []
|
||||
"""
|
||||
del self._message_getter
|
||||
return self._corr[-self._unsaved_messages:] if self._unsaved_messages else []
|
||||
|
||||
def get_corr(self):
|
||||
|
@ -513,6 +515,9 @@ class Profile(Contact, Singleton):
|
|||
if num is None or num == self.get_active_number():
|
||||
self._messages.clear()
|
||||
|
||||
def export_history(self, directory):
|
||||
self.history.export(directory)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Factories for friend and message items
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue