bug fixes and history export

This commit is contained in:
ingvar1995 2016-03-15 23:35:15 +03:00
parent ae50efa2e6
commit 44e5e7d0a6
5 changed files with 20 additions and 2 deletions

View File

@ -21,6 +21,15 @@ class History(object):
')') ')')
db.close() 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): def add_friend_to_db(self, tox_id):
chdir(Settings.get_default_path()) chdir(Settings.get_default_path())
db = connect(self._name + '.hstr') db = connect(self._name + '.hstr')

View File

@ -41,11 +41,11 @@ class MessageItem(QtGui.QListWidget):
def __init__(self, text, time, user='', message_type=TOX_MESSAGE_TYPE['NORMAL'], parent=None): def __init__(self, text, time, user='', message_type=TOX_MESSAGE_TYPE['NORMAL'], parent=None):
QtGui.QListWidget.__init__(self, parent) QtGui.QListWidget.__init__(self, parent)
self.name = QtGui.QLabel(self) 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) self.name.setTextFormat(QtCore.Qt.PlainText)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily("Times New Roman")
font.setPointSize(12) font.setPointSize(11)
font.setBold(True) font.setBold(True)
self.name.setFont(font) self.name.setFont(font)
self.name.setObjectName("name") self.name.setObjectName("name")

View File

@ -73,8 +73,10 @@ class Toxygen(object):
self.mainloop.start() self.mainloop.start()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()")) app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
app.exec_() app.exec_()
self.init.stop = True
self.mainloop.stop = True self.mainloop.stop = True
self.mainloop.wait() self.mainloop.wait()
self.init.wait()
data = self.tox.get_savedata() data = self.tox.get_savedata()
ProfileHelper.save_profile(data) ProfileHelper.save_profile(data)
del self.tox del self.tox

View File

@ -178,6 +178,8 @@ class ProfileSettings(CenteredWidget):
ProfileHelper.export_profile(directory) ProfileHelper.export_profile(directory)
settings = Settings.get_instance() settings = Settings.get_instance()
settings.export(directory) settings.export(directory)
profile = Profile.get_instance()
profile.export_history(directory)
def closeEvent(self, event): def closeEvent(self, event):
profile = Profile.get_instance() profile = Profile.get_instance()

View File

@ -186,6 +186,7 @@ class Friend(Contact):
def __del__(self): def __del__(self):
self.set_visibility(False) self.set_visibility(False)
del self._widget del self._widget
del self._message_getter
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# History support # History support
@ -210,6 +211,7 @@ class Friend(Contact):
Get data to save in db Get data to save in db
:return: list of unsaved messages or [] :return: list of unsaved messages or []
""" """
del self._message_getter
return self._corr[-self._unsaved_messages:] if self._unsaved_messages else [] return self._corr[-self._unsaved_messages:] if self._unsaved_messages else []
def get_corr(self): def get_corr(self):
@ -513,6 +515,9 @@ class Profile(Contact, Singleton):
if num is None or num == self.get_active_number(): if num is None or num == self.get_active_number():
self._messages.clear() self._messages.clear()
def export_history(self, directory):
self.history.export(directory)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Factories for friend and message items # Factories for friend and message items
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------