messages selection
This commit is contained in:
parent
e970fbed80
commit
9e410254bf
@ -257,7 +257,7 @@ class MainWindow(QtGui.QMainWindow, Singleton):
|
|||||||
self.messages.setSpacing(1)
|
self.messages.setSpacing(1)
|
||||||
self.messages.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
self.messages.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
||||||
self.messages.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
self.messages.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
self.messages.setFocusPolicy(QtCore.Qt.NoFocus)
|
# self.messages.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||||
|
|
||||||
def load(pos):
|
def load(pos):
|
||||||
if not pos:
|
if not pos:
|
||||||
@ -353,6 +353,14 @@ class MainWindow(QtGui.QMainWindow, Singleton):
|
|||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if event.key() == QtCore.Qt.Key_Escape:
|
if event.key() == QtCore.Qt.Key_Escape:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
elif event.key() == QtCore.Qt.Key_C and event.modifiers() & QtCore.Qt.ControlModifier and self.messages.selectedIndexes():
|
||||||
|
rows = list(map(lambda x: self.messages.row(x), self.messages.selectedItems()))
|
||||||
|
indexes = (rows[0] - self.messages.count(), rows[-1] - self.messages.count())
|
||||||
|
s = self.profile.export_history(self.profile.active_friend, True, indexes)
|
||||||
|
clipboard = QtGui.QApplication.clipboard()
|
||||||
|
clipboard.setText(s)
|
||||||
|
elif event.key() == QtCore.Qt.Key_Z and event.modifiers() & QtCore.Qt.ControlModifier and self.messages.selectedIndexes():
|
||||||
|
self.messages.clearSelection()
|
||||||
else:
|
else:
|
||||||
super(MainWindow, self).keyPressEvent(event)
|
super(MainWindow, self).keyPressEvent(event)
|
||||||
|
|
||||||
@ -548,9 +556,9 @@ class MainWindow(QtGui.QMainWindow, Singleton):
|
|||||||
self.connect(notes_item, QtCore.SIGNAL("triggered()"), lambda: self.show_note(friend))
|
self.connect(notes_item, QtCore.SIGNAL("triggered()"), lambda: self.show_note(friend))
|
||||||
self.connect(copy_name_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_name(friend))
|
self.connect(copy_name_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_name(friend))
|
||||||
self.connect(copy_status_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_status(friend))
|
self.connect(copy_status_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_status(friend))
|
||||||
self.connect(export_to_text_item, QtCore.SIGNAL("triggered()"), lambda: self.profile.export_history(num))
|
self.connect(export_to_text_item, QtCore.SIGNAL("triggered()"), lambda: self.export_history(num))
|
||||||
self.connect(export_to_html_item, QtCore.SIGNAL("triggered()"),
|
self.connect(export_to_html_item, QtCore.SIGNAL("triggered()"),
|
||||||
lambda: self.profile.export_history(num, False))
|
lambda: self.export_history(num, False))
|
||||||
parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0))
|
parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0))
|
||||||
self.listMenu.move(parent_position + pos)
|
self.listMenu.move(parent_position + pos)
|
||||||
self.listMenu.show()
|
self.listMenu.show()
|
||||||
@ -570,6 +578,20 @@ class MainWindow(QtGui.QMainWindow, Singleton):
|
|||||||
self.note = MultilineEdit(user, note, save_note)
|
self.note = MultilineEdit(user, note, save_note)
|
||||||
self.note.show()
|
self.note.show()
|
||||||
|
|
||||||
|
def export_history(self, num, as_text=True):
|
||||||
|
s = self.profile.export_history(num, as_text)
|
||||||
|
directory = QtGui.QFileDialog.getExistingDirectory(None,
|
||||||
|
QtGui.QApplication.translate("MainWindow", 'Choose folder',
|
||||||
|
None,
|
||||||
|
QtGui.QApplication.UnicodeUTF8),
|
||||||
|
curr_directory(),
|
||||||
|
QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
|
if directory:
|
||||||
|
name = 'exported_history_{}.{}'.format(convert_time(time.time()), 'txt' if as_text else 'html')
|
||||||
|
with open(directory + '/' + name, 'wt') as fl:
|
||||||
|
fl.write(s)
|
||||||
|
|
||||||
def set_alias(self, num):
|
def set_alias(self, num):
|
||||||
self.profile.set_alias(num)
|
self.profile.set_alias(num)
|
||||||
|
|
||||||
|
@ -521,7 +521,12 @@ class Profile(contact.Contact, Singleton):
|
|||||||
friend = self._friends[num]
|
friend = self._friends[num]
|
||||||
if _range is None:
|
if _range is None:
|
||||||
friend.load_all_corr()
|
friend.load_all_corr()
|
||||||
corr = friend.get_corr() if _range is None else friend.get_corr()[_range[0]:_range[1]]
|
if _range is None:
|
||||||
|
corr = friend.get_corr()
|
||||||
|
elif _range[1] + 1:
|
||||||
|
corr = friend.get_corr()[_range[0]:_range[1] + 1]
|
||||||
|
else:
|
||||||
|
corr = friend.get_corr()[_range[0]:]
|
||||||
arr = []
|
arr = []
|
||||||
new_line = '\n' if as_text else '<br>'
|
new_line = '\n' if as_text else '<br>'
|
||||||
for message in corr:
|
for message in corr:
|
||||||
@ -535,14 +540,7 @@ class Profile(contact.Contact, Singleton):
|
|||||||
friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self.name,
|
friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self.name,
|
||||||
data[0]))
|
data[0]))
|
||||||
s = new_line.join(arr)
|
s = new_line.join(arr)
|
||||||
directory = QtGui.QFileDialog.getExistingDirectory(None,
|
return s
|
||||||
QtGui.QApplication.translate("MainWindow", 'Choose folder', None, QtGui.QApplication.UnicodeUTF8),
|
|
||||||
curr_directory(),
|
|
||||||
QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog)
|
|
||||||
if directory:
|
|
||||||
name = 'exported_history_{}.{}'.format(convert_time(time.time()), 'txt' if as_text else 'html')
|
|
||||||
with open(directory + '/' + name, 'wt') as fl:
|
|
||||||
fl.write(s)
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
# Factories for friend, message and file transfer items
|
# Factories for friend, message and file transfer items
|
||||||
@ -818,6 +816,7 @@ class Profile(contact.Contact, Singleton):
|
|||||||
self._call.stop()
|
self._call.stop()
|
||||||
del self._tox
|
del self._tox
|
||||||
self._tox = restart()
|
self._tox = restart()
|
||||||
|
self._call = calls.AV(self._tox.AV)
|
||||||
self.status = None
|
self.status = None
|
||||||
for friend in self._friends:
|
for friend in self._friends:
|
||||||
friend.status = None
|
friend.status = None
|
||||||
|
Loading…
Reference in New Issue
Block a user