display all of the profile
This commit is contained in:
parent
c4d8f7de2e
commit
f95aab9096
4 changed files with 200 additions and 88 deletions
|
|
@ -15,10 +15,11 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
import urllib2
|
||||
import time
|
||||
import logging
|
||||
from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap, QFrame, QMessageBox
|
||||
from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap, \
|
||||
QFrame, QMessageBox, QTabWidget, QVBoxLayout, \
|
||||
QFormLayout, QLabel
|
||||
from PyQt4.QtCore import SIGNAL, Qt
|
||||
|
||||
from weboob.tools.application.qt import QtDo, HTMLDelegate
|
||||
|
|
@ -127,10 +128,9 @@ class ContactProfile(QWidget):
|
|||
self.weboob = weboob
|
||||
self.contact = contact
|
||||
|
||||
self.gotProfile(contact.backend, contact)
|
||||
|
||||
self.process_contact = QtDo(self.weboob, self.gotProfile)
|
||||
self.process_contact.do('fillobj', self.contact, ['photos', 'profile'], backends=self.contact.backend)
|
||||
if self.gotProfile(contact.backend, contact):
|
||||
self.process_contact = QtDo(self.weboob, self.gotProfile)
|
||||
self.process_contact.do('fillobj', self.contact, ['photos', 'profile'], backends=self.contact.backend)
|
||||
|
||||
def gotProfile(self, backend, contact):
|
||||
if not backend:
|
||||
|
|
@ -139,18 +139,65 @@ class ContactProfile(QWidget):
|
|||
first = True
|
||||
for photo in contact.photos.itervalues():
|
||||
photo = contact.photos.values()[0]
|
||||
if first:
|
||||
if first and photo.data:
|
||||
img = QImage.fromData(photo.data)
|
||||
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
|
||||
first = False
|
||||
else:
|
||||
# TODO display thumbnails
|
||||
pass
|
||||
first = False
|
||||
|
||||
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
||||
self.ui.statusLabel.setText('%s' % contact.status_msg)
|
||||
self.ui.descriptionEdit.setText('<h1>Description</h1><p>%s</p>' % (contact.summary.replace('\n', '<br />') or '<i>Receiving...</i>'))
|
||||
|
||||
if not contact.profile:
|
||||
return True
|
||||
|
||||
for head in contact.profile:
|
||||
if head.flags & head.HEAD:
|
||||
widget = self.ui.headFrame
|
||||
else:
|
||||
widget = self.ui.profileTab
|
||||
self.process_node(head, widget)
|
||||
|
||||
return False
|
||||
|
||||
def process_node(self, node, widget):
|
||||
# Set the value widget
|
||||
value = None
|
||||
if node.flags & node.SECTION:
|
||||
value = QWidget()
|
||||
value.setLayout(QFormLayout())
|
||||
for sub in node.value:
|
||||
self.process_node(sub, value)
|
||||
elif isinstance(node.value, list):
|
||||
value = QLabel('<br />'.join([unicode(s) for s in node.value]))
|
||||
value.setWordWrap(True)
|
||||
elif isinstance(node.value, tuple):
|
||||
value = QLabel(', '.join([unicode(s) for s in node.value]))
|
||||
value.setWordWrap(True)
|
||||
elif isinstance(node.value, (str,unicode,int)):
|
||||
print '[%s]' % node.value
|
||||
value = QLabel(unicode(node.value))
|
||||
|
||||
if not value:
|
||||
print 'no value :('
|
||||
return
|
||||
|
||||
# Insert the value widget into the parent widget, depending
|
||||
# of its type.
|
||||
if isinstance(widget, QTabWidget):
|
||||
widget.addTab(value, node.label)
|
||||
elif isinstance(widget.layout(), QFormLayout):
|
||||
label = QLabel(u'<b>%s:</b> ' % node.label)
|
||||
widget.layout().addRow(label, value)
|
||||
elif isinstance(widget.layout(), QVBoxLayout):
|
||||
widget.layout().addWidget(value)
|
||||
else:
|
||||
print 'TODO'
|
||||
return
|
||||
|
||||
class IGroup(object):
|
||||
def __init__(self, weboob, id, name):
|
||||
self.id = id
|
||||
|
|
|
|||
|
|
@ -13,87 +13,151 @@
|
|||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="photoLabel">
|
||||
<property name="text">
|
||||
<string><i>Receiving...</i></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="headFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="nicknameLabel">
|
||||
<property name="text">
|
||||
<string><h1>Nickname</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="text">
|
||||
<string>status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="bodyFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="descriptionEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>456</width>
|
||||
<height>316</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="QFrame" name="frame_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="photoLabel">
|
||||
<property name="text">
|
||||
<string><i>Receiving...</i></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="headFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="nicknameLabel">
|
||||
<property name="text">
|
||||
<string><h1>Nickname</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="text">
|
||||
<string>status</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>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="descriptionEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="profileTab">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
|||
s = ProfileNode(section, section.capitalize(), [], flags=ProfileNode.SECTION)
|
||||
for key, value in d.iteritems():
|
||||
s.value.append(ProfileNode(key, key.capitalize(), value))
|
||||
contact.profile.append(s)
|
||||
|
||||
return contact
|
||||
except BrowserUnavailable:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ProfileNode(object):
|
|||
HEAD = 0x01
|
||||
SECTION = 0x02
|
||||
|
||||
def __init__(self, name, label, value, sufix=None, flags=None):
|
||||
def __init__(self, name, label, value, sufix=None, flags=0):
|
||||
self.name = name
|
||||
self.label = label
|
||||
self.value = value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue