merge do_caps() and do_backends() into do() (optional keyword params 'backends' and 'caps')

This commit is contained in:
Romain Bignon 2010-07-17 13:33:27 +02:00
commit fc4badf88e
13 changed files with 53 additions and 103 deletions

View file

@ -76,7 +76,7 @@ class ContactThread(QWidget):
command = 'iter_messages'
self.process_msg = QtDo(self.weboob, self.gotMessage)
self.process_msg.do_backends(self.contact.backend, command, thread=self.contact.id)
self.process_msg.do(command, thread=self.contact.id, backends=self.contact.backend)
def gotMessage(self, backend, message):
if not message:
@ -101,7 +101,7 @@ class ContactThread(QWidget):
self.ui.textEdit.setEnabled(False)
self.ui.sendButton.setEnabled(False)
self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
self.process_reply.do_backends(self.contact.backend, 'post_reply', self.contact.id, 0, '', text)
self.process_reply.do('post_reply', self.contact.id, 0, '', text, backends=self.contact.backend)
def _postReply_cb(self, backend, ignored):
self.ui.textEdit.clear()
@ -128,6 +128,8 @@ class ContactProfile(QWidget):
self.contact = contact
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)
class IGroup(object):
def __init__(self, weboob, id, name):
@ -148,7 +150,7 @@ class MetaGroup(IGroup):
status = Contact.STATUS_ALL
self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
self.process.do_caps(ICapContact, 'iter_contacts', status)
self.process.do('iter_contacts', status, caps=ICapContact)
def cb(self, cb, backend, contact):
if contact:
@ -233,6 +235,9 @@ class ContactsWidget(QWidget):
self.contact = current.data(Qt.UserRole).toPyObject()
if not self.contact:
return
self.ui.tabWidget.addTab(ContactProfile(self.weboob, self.contact), self.tr('Profile'))
if self.contact.backend.has_caps(ICapMessages):
self.ui.tabWidget.addTab(ContactThread(self.weboob, self.contact), self.tr('Messages'))

View file

@ -48,6 +48,7 @@ class MainWindow(QtMainWindow):
self.ui.tabWidget.addTab(MessagesManager(self.weboob), self.tr('Messages'))
self.ui.tabWidget.addTab(ContactsWidget(self.weboob), self.tr('Contacts'))
self.ui.tabWidget.addTab(QWidget(), self.tr('Calendar'))
self.ui.tabWidget.addTab(QWidget(), self.tr('Optimizations'))
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.tabWidget, SIGNAL('currentChanged(int)'), self.tabChanged)

View file

@ -18,7 +18,6 @@
from __future__ import with_statement
from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, QFrame, QLabel, QImage, QPixmap
from PyQt4.QtCore import SIGNAL
from weboob.capabilities.dating import StatusField
from weboob.tools.application.qt import QtDo
@ -60,7 +59,7 @@ class Account(QFrame):
self.process = QtDo(self.weboob, self.updateStats_cb)
self.process.body = u''
self.process.in_p = False
self.process.do_backends(self.backend, 'get_status')
self.process.do('get_status', backends=self.backend)
def updateStats_cb(self, backend, field):
if not field:

View file

@ -43,7 +43,7 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<widget class="QFrame" name="headFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -78,7 +78,7 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<widget class="QFrame" name="bodyFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@ -87,7 +87,11 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
<widget class="QTextEdit" name="descriptionEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>