display messages of the selected contact
This commit is contained in:
parent
7d8a127dd8
commit
f70b937236
4 changed files with 268 additions and 8 deletions
|
|
@ -16,7 +16,8 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
import urllib2
|
||||
from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap
|
||||
import time
|
||||
from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap, QFrame
|
||||
from PyQt4.QtCore import SIGNAL, Qt
|
||||
|
||||
from weboob.tools.application.qt import QtDo
|
||||
|
|
@ -25,6 +26,55 @@ from weboob.capabilities.chat import ICapChat
|
|||
from weboob.capabilities.messages import ICapMessages
|
||||
|
||||
from .ui.contacts_ui import Ui_Contacts
|
||||
from .ui.contact_thread_ui import Ui_ContactThread
|
||||
from .ui.thread_message_ui import Ui_ThreadMessage
|
||||
|
||||
class ThreadMessage(QFrame):
|
||||
def __init__(self, message, parent=None):
|
||||
QFrame.__init__(self, parent)
|
||||
self.ui = Ui_ThreadMessage()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.date = message.get_date()
|
||||
|
||||
self.ui.nameLabel.setText(message.sender)
|
||||
self.ui.headerLabel.setText(time.strftime('%Y-%m-%d %H:%M:%S', message.get_date().timetuple()))
|
||||
if message.is_html:
|
||||
content = message.content
|
||||
else:
|
||||
content = message.content.replace('&', '&').replace('<', '<').replace('>', '>').replace('\n', '<br />')
|
||||
self.ui.contentLabel.setText(content)
|
||||
|
||||
class ContactThread(QWidget):
|
||||
def __init__(self, weboob, contact, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.ui = Ui_ContactThread()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.weboob = weboob
|
||||
self.contact = contact
|
||||
self.messages = []
|
||||
|
||||
self.process = QtDo(self.weboob, self.gotMessage)
|
||||
self.process.do('iter_messages', thread=self.contact.id)
|
||||
print self.contact.id
|
||||
|
||||
def gotMessage(self, backend, message):
|
||||
if not message:
|
||||
v = self.ui.scrollArea.verticalScrollBar()
|
||||
print v.minimum(), v.value(), v.maximum(), v.sliderPosition()
|
||||
self.ui.scrollArea.verticalScrollBar().setValue(self.ui.scrollArea.verticalScrollBar().maximum())
|
||||
return
|
||||
|
||||
widget = ThreadMessage(message)
|
||||
for i, m in enumerate(self.messages):
|
||||
if widget.date < m.date:
|
||||
self.ui.scrollAreaContent.layout().insertWidget(i, widget)
|
||||
self.messages.insert(i, widget)
|
||||
return
|
||||
|
||||
self.ui.scrollAreaContent.layout().addWidget(widget)
|
||||
self.messages.append(widget)
|
||||
|
||||
class IGroup(object):
|
||||
def __init__(self, weboob, id, name):
|
||||
|
|
@ -67,12 +117,17 @@ class ContactsWidget(QWidget):
|
|||
|
||||
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.refreshButton, SIGNAL('clicked()'), self.refreshContactList)
|
||||
|
||||
def load(self):
|
||||
self.ui.groupBox.setCurrentIndex(1)
|
||||
|
||||
def groupChanged(self, i):
|
||||
self.refreshContactList()
|
||||
|
||||
def refreshContactList(self):
|
||||
self.ui.contactList.clear()
|
||||
i = self.ui.groupBox.currentIndex()
|
||||
group = self.ui.groupBox.itemData(i).toPyObject()
|
||||
group.iter_contacts(self.addContact)
|
||||
|
||||
|
|
@ -97,15 +152,18 @@ class ContactsWidget(QWidget):
|
|||
self.ui.contactList.addItem(item)
|
||||
|
||||
def contactChanged(self, current, previous):
|
||||
contact = current.data(Qt.UserRole).toPyObject()
|
||||
|
||||
self.ui.tabWidget.clear()
|
||||
self.contact = None
|
||||
|
||||
if not current:
|
||||
return
|
||||
|
||||
self.contact = current.data(Qt.UserRole).toPyObject()
|
||||
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Profile'))
|
||||
if contact.backend.has_caps(ICapMessages):
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Messages'))
|
||||
if contact.backend.has_caps(ICapChat):
|
||||
if self.contact.backend.has_caps(ICapMessages):
|
||||
self.ui.tabWidget.addTab(ContactThread(self.weboob, self.contact), self.tr('Messages'))
|
||||
if self.contact.backend.has_caps(ICapChat):
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Chat'))
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Calendar'))
|
||||
self.ui.tabWidget.addTab(QWidget(), self.tr('Notes'))
|
||||
print contact.backend
|
||||
|
|
|
|||
84
weboob/frontends/qhavesex/ui/contact_thread.ui
Normal file
84
weboob/frontends/qhavesex/ui/contact_thread.ui
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ContactThread</class>
|
||||
<widget class="QWidget" name="ContactThread">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>578</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<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>187</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget#scrollAreaContent {
|
||||
background-color: rgb(255, 255, 255);
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sendButton">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -34,7 +34,22 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="groupBox"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="groupBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="refreshButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<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="QListWidget" name="contactList">
|
||||
|
|
|
|||
103
weboob/frontends/qhavesex/ui/thread_message.ui
Normal file
103
weboob/frontends/qhavesex/ui/thread_message.ui
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ThreadMessage</class>
|
||||
<widget class="QFrame" name="ThreadMessage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>552</width>
|
||||
<height>173</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="headerLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="contentLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>92</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue