add a messages refresh button, and better handler of contacts selection
This commit is contained in:
parent
487284fe5c
commit
28e57001bc
3 changed files with 98 additions and 39 deletions
|
|
@ -43,6 +43,9 @@ class ThreadMessage(QFrame):
|
||||||
self.ui = Ui_ThreadMessage()
|
self.ui = Ui_ThreadMessage()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
|
self.set_message(message)
|
||||||
|
|
||||||
|
def set_message(self, message):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
self.ui.nameLabel.setText(message.sender)
|
self.ui.nameLabel.setText(message.sender)
|
||||||
|
|
@ -58,6 +61,7 @@ class ThreadMessage(QFrame):
|
||||||
content = message.content.replace('&', '&').replace('<', '<').replace('>', '>').replace('\n', '<br />')
|
content = message.content.replace('&', '&').replace('<', '<').replace('>', '>').replace('\n', '<br />')
|
||||||
self.ui.contentLabel.setText(content)
|
self.ui.contentLabel.setText(content)
|
||||||
|
|
||||||
|
|
||||||
def __eq__(self, m):
|
def __eq__(self, m):
|
||||||
return self.message == m.message
|
return self.message == m.message
|
||||||
|
|
||||||
|
|
@ -76,6 +80,7 @@ class ContactThread(QWidget):
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.messages = []
|
self.messages = []
|
||||||
self.process_msg = None
|
self.process_msg = None
|
||||||
|
self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshMessages)
|
||||||
|
|
||||||
if support_reply:
|
if support_reply:
|
||||||
self.connect(self.ui.sendButton, SIGNAL('clicked()'), self.postReply)
|
self.connect(self.ui.sendButton, SIGNAL('clicked()'), self.postReply)
|
||||||
|
|
@ -84,12 +89,12 @@ class ContactThread(QWidget):
|
||||||
|
|
||||||
self.refreshMessages()
|
self.refreshMessages()
|
||||||
|
|
||||||
def refreshMessages(self):
|
def refreshMessages(self, fillobj=False):
|
||||||
if self.process_msg:
|
if self.process_msg:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError)
|
self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError)
|
||||||
if self.thread:
|
if fillobj and self.thread:
|
||||||
self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
|
self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
|
||||||
else:
|
else:
|
||||||
self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
|
self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
|
||||||
|
|
@ -120,6 +125,9 @@ class ContactThread(QWidget):
|
||||||
def _insert_message(self, message):
|
def _insert_message(self, message):
|
||||||
widget = ThreadMessage(message)
|
widget = ThreadMessage(message)
|
||||||
if widget in self.messages:
|
if widget in self.messages:
|
||||||
|
old_widget = self.messages[self.messages.index(widget)]
|
||||||
|
if old_widget.message.flags != widget.message.flags:
|
||||||
|
old_widget.set_message(widget.message)
|
||||||
return
|
return
|
||||||
|
|
||||||
for i, m in enumerate(self.messages):
|
for i, m in enumerate(self.messages):
|
||||||
|
|
@ -148,7 +156,7 @@ class ContactThread(QWidget):
|
||||||
button.hide()
|
button.hide()
|
||||||
button.deleteLater()
|
button.deleteLater()
|
||||||
|
|
||||||
self.refreshMessages()
|
self.refreshMessages(fillobj=True)
|
||||||
|
|
||||||
def postReply(self):
|
def postReply(self):
|
||||||
text = unicode(self.ui.textEdit.toPlainText())
|
text = unicode(self.ui.textEdit.toPlainText())
|
||||||
|
|
@ -306,7 +314,7 @@ class ContactsWidget(QWidget):
|
||||||
self.ui.groupBox.setCurrentIndex(1)
|
self.ui.groupBox.setCurrentIndex(1)
|
||||||
|
|
||||||
self.connect(self.ui.groupBox, SIGNAL('currentIndexChanged(int)'), self.groupChanged)
|
self.connect(self.ui.groupBox, SIGNAL('currentIndexChanged(int)'), self.groupChanged)
|
||||||
self.connect(self.ui.contactList, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.contactChanged)
|
self.connect(self.ui.contactList, SIGNAL('itemClicked(QListWidgetItem*)'), self.contactChanged)
|
||||||
self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshContactList)
|
self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshContactList)
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
|
@ -369,18 +377,17 @@ class ContactsWidget(QWidget):
|
||||||
|
|
||||||
self.ui.contactList.addItem(item)
|
self.ui.contactList.addItem(item)
|
||||||
|
|
||||||
def contactChanged(self, current, previous):
|
def contactChanged(self, current):
|
||||||
self.ui.tabWidget.clear()
|
|
||||||
self.contact = None
|
|
||||||
|
|
||||||
if not current:
|
if not current:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.contact = current.data(Qt.UserRole).toPyObject()
|
contact = current.data(Qt.UserRole).toPyObject()
|
||||||
|
|
||||||
if not self.contact:
|
if not contact or contact == self.contact:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.ui.tabWidget.clear()
|
||||||
|
self.contact = contact
|
||||||
backend = self.weboob.get_backend(self.contact.backend)
|
backend = self.weboob.get_backend(self.contact.backend)
|
||||||
|
|
||||||
self.ui.tabWidget.addTab(ContactProfile(self.weboob, self.contact), self.tr('Profile'))
|
self.ui.tabWidget.addTab(ContactProfile(self.weboob, self.contact), self.tr('Profile'))
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,19 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -52,41 +58,81 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>1</verstretch>
|
<verstretch>5</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<string notr="true"/>
|
<property name="margin">
|
||||||
</property>
|
<number>0</number>
|
||||||
<property name="horizontalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
|
||||||
</property>
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaContent">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>556</width>
|
|
||||||
<height>187</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<item>
|
||||||
<string notr="true">QWidget#scrollAreaContent {
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="refreshButton">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png</normaloff>../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaContent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>556</width>
|
||||||
|
<height>154</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QWidget#scrollAreaContent {
|
||||||
background-color: rgb(255, 255, 255);
|
background-color: rgb(255, 255, 255);
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,12 @@ class CapBaseObject(object):
|
||||||
for attrstr in self.FIELDS:
|
for attrstr in self.FIELDS:
|
||||||
yield attrstr, getattr(self, attrstr)
|
yield attrstr, getattr(self, attrstr)
|
||||||
|
|
||||||
|
def __eq__(self, obj):
|
||||||
|
if isinstance(obj, CapBaseObject):
|
||||||
|
return self.backend == obj.backend and self.id == obj.id
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
class _AttribValue(object):
|
class _AttribValue(object):
|
||||||
def __init__(self, type, value):
|
def __init__(self, type, value):
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue