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
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import urllib2
|
|
||||||
import time
|
import time
|
||||||
import logging
|
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 PyQt4.QtCore import SIGNAL, Qt
|
||||||
|
|
||||||
from weboob.tools.application.qt import QtDo, HTMLDelegate
|
from weboob.tools.application.qt import QtDo, HTMLDelegate
|
||||||
|
|
@ -127,10 +128,9 @@ class ContactProfile(QWidget):
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
|
|
||||||
self.gotProfile(contact.backend, contact)
|
if self.gotProfile(contact.backend, contact):
|
||||||
|
self.process_contact = QtDo(self.weboob, self.gotProfile)
|
||||||
self.process_contact = QtDo(self.weboob, self.gotProfile)
|
self.process_contact.do('fillobj', self.contact, ['photos', 'profile'], backends=self.contact.backend)
|
||||||
self.process_contact.do('fillobj', self.contact, ['photos', 'profile'], backends=self.contact.backend)
|
|
||||||
|
|
||||||
def gotProfile(self, backend, contact):
|
def gotProfile(self, backend, contact):
|
||||||
if not backend:
|
if not backend:
|
||||||
|
|
@ -139,18 +139,65 @@ class ContactProfile(QWidget):
|
||||||
first = True
|
first = True
|
||||||
for photo in contact.photos.itervalues():
|
for photo in contact.photos.itervalues():
|
||||||
photo = contact.photos.values()[0]
|
photo = contact.photos.values()[0]
|
||||||
if first:
|
if first and photo.data:
|
||||||
img = QImage.fromData(photo.data)
|
img = QImage.fromData(photo.data)
|
||||||
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
|
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
|
||||||
|
first = False
|
||||||
else:
|
else:
|
||||||
# TODO display thumbnails
|
# TODO display thumbnails
|
||||||
pass
|
pass
|
||||||
first = False
|
|
||||||
|
|
||||||
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
||||||
self.ui.statusLabel.setText('%s' % contact.status_msg)
|
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>'))
|
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):
|
class IGroup(object):
|
||||||
def __init__(self, weboob, id, name):
|
def __init__(self, weboob, id, name):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
|
||||||
|
|
@ -13,87 +13,151 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="frameShape">
|
<property name="widgetResizable">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
<enum>QFrame::Raised</enum>
|
<property name="geometry">
|
||||||
</property>
|
<rect>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<x>0</x>
|
||||||
<item>
|
<y>0</y>
|
||||||
<widget class="QFrame" name="frame_4">
|
<width>456</width>
|
||||||
<property name="frameShape">
|
<height>316</height>
|
||||||
<enum>QFrame::StyledPanel</enum>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<enum>QFrame::Raised</enum>
|
<item>
|
||||||
</property>
|
<widget class="QFrame" name="frame">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
<widget class="QLabel" name="photoLabel">
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string><i>Receiving...</i></string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="frameShape">
|
||||||
</item>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</layout>
|
</property>
|
||||||
</widget>
|
<property name="frameShadow">
|
||||||
</item>
|
<enum>QFrame::Raised</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QFrame" name="headFrame">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<widget class="QFrame" name="frame_4">
|
||||||
<horstretch>0</horstretch>
|
<property name="frameShape">
|
||||||
<verstretch>0</verstretch>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</sizepolicy>
|
</property>
|
||||||
</property>
|
<property name="frameShadow">
|
||||||
<property name="frameShape">
|
<enum>QFrame::Raised</enum>
|
||||||
<enum>QFrame::StyledPanel</enum>
|
</property>
|
||||||
</property>
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="frameShadow">
|
<item>
|
||||||
<enum>QFrame::Raised</enum>
|
<widget class="QLabel" name="photoLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<string><i>Receiving...</i></string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLabel" name="nicknameLabel">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string><h1>Nickname</h1></string>
|
<item>
|
||||||
</property>
|
<spacer name="verticalSpacer_2">
|
||||||
</widget>
|
<property name="orientation">
|
||||||
</item>
|
<enum>Qt::Vertical</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLabel" name="statusLabel">
|
<property name="sizeHint" stdset="0">
|
||||||
<property name="text">
|
<size>
|
||||||
<string>status</string>
|
<width>0</width>
|
||||||
</property>
|
<height>0</height>
|
||||||
</widget>
|
</size>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
</spacer>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
</layout>
|
||||||
</layout>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QFrame" name="headFrame">
|
||||||
<widget class="QFrame" name="bodyFrame">
|
<property name="sizePolicy">
|
||||||
<property name="frameShape">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<enum>QFrame::NoFrame</enum>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="frameShadow">
|
</sizepolicy>
|
||||||
<enum>QFrame::Plain</enum>
|
</property>
|
||||||
</property>
|
<property name="frameShape">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<enum>QFrame::StyledPanel</enum>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QTextEdit" name="descriptionEdit">
|
<property name="frameShadow">
|
||||||
<property name="readOnly">
|
<enum>QFrame::Raised</enum>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<widget class="QLabel" name="nicknameLabel">
|
||||||
</layout>
|
<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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesReply, ICapDating, ICapC
|
||||||
s = ProfileNode(section, section.capitalize(), [], flags=ProfileNode.SECTION)
|
s = ProfileNode(section, section.capitalize(), [], flags=ProfileNode.SECTION)
|
||||||
for key, value in d.iteritems():
|
for key, value in d.iteritems():
|
||||||
s.value.append(ProfileNode(key, key.capitalize(), value))
|
s.value.append(ProfileNode(key, key.capitalize(), value))
|
||||||
|
contact.profile.append(s)
|
||||||
|
|
||||||
return contact
|
return contact
|
||||||
except BrowserUnavailable:
|
except BrowserUnavailable:
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class ProfileNode(object):
|
||||||
HEAD = 0x01
|
HEAD = 0x01
|
||||||
SECTION = 0x02
|
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.name = name
|
||||||
self.label = label
|
self.label = label
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue