def loadHistory(self):
        """ Loads the page's log into the 'History' tab """
        if self.backend is None:
            return

        self.ui.loadHistoryButton.setEnabled(False)
        self.ui.loadHistoryButton.setText("Loading...")

        self.ui.historyTable.clear()
        self.ui.historyTable.setRowCount(0)

        self.ui.historyTable.setHorizontalHeaderLabels(
            ["Revision", "Time", "Author", "Summary"])
        self.ui.historyTable.setColumnWidth(3, 1000)

        def finished():
            self.process = None
            self.ui.loadHistoryButton.setEnabled(True)
            self.ui.loadHistoryButton.setText("Reload")

        self.process = QtDo(self.weboob, self._gotRevision, self._errorHistory,
                            finished)
        self.process.do(self.app._do_complete,
                        self.ui.nbRevBox.value(), (),
                        'iter_revisions',
                        self.content.id,
                        backends=(self.backend, ))
    def savePage(self):
        """ Saves the current page to the remote site """
        if self.backend is None:
            return
        new_content = unicode(self.ui.contentEdit.toPlainText())
        minor = self.ui.minorBox.isChecked()
        if new_content != self.content.content:
            self.ui.saveButton.setEnabled(False)
            self.ui.saveButton.setText('Saving...')
            self.ui.contentEdit.setReadOnly(True)
            self.content.content = new_content
            message = unicode(self.ui.descriptionEdit.text())

            def finished():
                self.process = None
                self.ui.saveButton.setText('Saved')
                self.ui.descriptionEdit.clear()
                self.ui.contentEdit.setReadOnly(False)

            self.process = QtDo(self.weboob, None, self._errorSavePage,
                                finished)
            self.process.do('push_content',
                            self.content,
                            message,
                            minor=minor,
                            backends=self.backend)
Exemple #3
0
class ContactNotes(QWidget):
    """ Widget for storing notes about a contact """

    def __init__(self, weboob, contact, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Notes()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.contact = contact

        self.ui.textEdit.setEnabled(False)
        self.ui.saveButton.setEnabled(False)
        self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb)
        self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,))

        self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes)

    def _getNotes_cb(self, backend, data):
        if not backend or not data:
            self.process = None
            self.ui.textEdit.setEnabled(True)
            self.ui.saveButton.setEnabled(True)
            return

        self.ui.textEdit.setText(data)

    def _getNotes_eb(self, backend, error, backtrace):
        if isinstance(error, NotImplementedError):
            return

        self.ui.textEdit.setEnabled(True)
        self.ui.saveButton.setEnabled(True)
        content = unicode(self.tr('Unable to load notes:\n%s\n')) % to_unicode(error)
        if logging.root.level == logging.DEBUG:
            content += '\n%s\n' % to_unicode(backtrace)
            QMessageBox.critical(self, self.tr('Error while loading notes'),
            content, QMessageBox.Ok)

    def saveNotes(self):
        text = unicode(self.ui.textEdit.toPlainText())
        self.ui.saveButton.setEnabled(False)
        self.ui.textEdit.setEnabled(False)

        self.process = QtDo(self.weboob, self._saveNotes_cb, self._saveNotes_eb)
        self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))

    def _saveNotes_cb(self, backend, data):
        self.ui.saveButton.setEnabled(True)
        self.ui.textEdit.setEnabled(True)
        pass

    def _saveNotes_eb(self, backend, error, backtrace):
        self.ui.saveButton.setEnabled(True)
        self.ui.textEdit.setEnabled(True)
        content = unicode(self.tr('Unable to save notes:\n%s\n')) % to_unicode(error)
        if logging.root.level == logging.DEBUG:
            content += '\n%s\n' % to_unicode(backtrace)
            QMessageBox.critical(self, self.tr('Error while saving notes'),
            content, QMessageBox.Ok)
Exemple #4
0
    def searchSubtitleAction(self, lang, pattern):
        self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
        for mini in self.minis:
            self.ui.list_content.layout().removeWidget(mini)
            mini.hide()
            mini.deleteLater()

        self.minis = []
        self.parent.ui.searchEdit.setEnabled(False)
        QApplication.setOverrideCursor(Qt.WaitCursor)

        backend_name = str(
            self.parent.ui.backendEdit.itemData(
                self.parent.ui.backendEdit.currentIndex()).toString())

        self.process = QtDo(self.weboob, self.addSubtitle)
        #self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=ICapSubtitle)
        self.process.do(self.app._do_complete,
                        self.parent.getCount(), ('name'),
                        'iter_subtitles',
                        lang,
                        pattern,
                        backends=backend_name,
                        caps=ICapSubtitle)
        self.parent.ui.stopButton.show()
Exemple #5
0
    def _sendPressed(self):
        if not self.ui.replyWidget.isVisible():
            return

        text = unicode(self.ui.replyEdit.toPlainText())
        title = unicode(self.ui.titleEdit.text())

        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)
        self.ui.messagesTree.setEnabled(False)
        self.ui.replyButton.setEnabled(False)
        self.ui.replyWidget.setEnabled(False)
        self.ui.sendButton.setText(self.tr('Sending...'))
        flags = 0
        if self.ui.htmlBox.currentIndex() == 0:
            flags = Message.IS_HTML
        m = Message(thread=self.thread,
                    id=0,
                    title=title,
                    sender=None,
                    receivers=None,
                    content=text,
                    parent=self.message,
                    flags=flags)
        self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
        self.process_reply.do('post_message', m, backends=self.thread.backend)
Exemple #6
0
    def search(self):
        pattern = unicode(self.ui.searchEdit.text())
        if not pattern:
            return

        for minivideo in self.minivideos:
            self.ui.scrollAreaContent.layout().removeWidget(minivideo)
            minivideo.hide()
            minivideo.deleteLater()

        self.minivideos = []
        self.ui.searchEdit.setEnabled(False)

        backend_name = str(
            self.ui.backendEdit.itemData(
                self.ui.backendEdit.currentIndex()).toString())

        self.process = QtDo(self.weboob, self.addVideo)
        self.process.do(self.app._do_complete,
                        20, (),
                        'search_videos',
                        pattern,
                        self.ui.sortbyEdit.currentIndex(),
                        nsfw=True,
                        backends=backend_name)
Exemple #7
0
    def saveNotes(self):
        text = unicode(self.ui.textEdit.toPlainText())
        self.ui.saveButton.setEnabled(False)
        self.ui.textEdit.setEnabled(False)

        self.process = QtDo(self.weboob, self._saveNotes_cb, self._saveNotes_eb)
        self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))
Exemple #8
0
    def refreshHousingsList(self):
        name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex()))
        q = self.config.get('queries', name)

        if q is None:
            return q

        self.ui.housingsList.clear()
        self.ui.queriesList.setEnabled(False)
        self.ui.bookmarksButton.setEnabled(False)

        query = Query()
        query.type = int(q.get('type', 0))
        query.cities = []
        for c in q['cities']:
            city = City(c['id'])
            city.backend = c['backend']
            city.name = c['name']
            query.cities.append(city)

        query.area_min = int(q['area_min']) or None
        query.area_max = int(q['area_max']) or None
        query.cost_min = int(q['cost_min']) or None
        query.cost_max = int(q['cost_max']) or None
        query.nb_rooms = int(q['nb_rooms']) or None

        self.process = QtDo(self.weboob, self.addHousing)
        self.process.do('search_housings', query)
Exemple #9
0
    def searchCity(self):
        pattern = unicode(self.ui.cityEdit.text())
        self.ui.resultsList.clear()
        self.ui.cityEdit.clear()
        self.ui.cityEdit.setEnabled(False)

        self.search_process = QtDo(self.weboob, self.addResult)
        self.search_process.do('search_city', pattern)
Exemple #10
0
class ContactNotes(QWidget):
    """ Widget for storing notes about a contact """

    def __init__(self, weboob, contact, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Notes()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.contact = contact

        self.ui.textEdit.setEnabled(False)
        self.ui.saveButton.setEnabled(False)

        def finished():
            self.process = None
            self.ui.textEdit.setEnabled(True)
            self.ui.saveButton.setEnabled(True)

        self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb, finished)
        self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,))

        self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes)

    def _getNotes_cb(self, data):
        if data:
            self.ui.textEdit.setText(data)

    def _getNotes_eb(self, backend, error, backtrace):
        if isinstance(error, NotImplementedError):
            return

        self.ui.textEdit.setEnabled(True)
        self.ui.saveButton.setEnabled(True)
        content = unicode(self.tr('Unable to load notes:\n%s\n')) % to_unicode(error)
        if logging.root.level <= logging.DEBUG:
            content += '\n%s\n' % to_unicode(backtrace)
            QMessageBox.critical(self, self.tr('Error while loading notes'),
            content, QMessageBox.Ok)

    def saveNotes(self):
        text = unicode(self.ui.textEdit.toPlainText())
        self.ui.saveButton.setEnabled(False)
        self.ui.textEdit.setEnabled(False)

        self.process = QtDo(self.weboob, None, self._saveNotes_eb, self._saveNotes_fb)
        self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))

    def _saveNotes_fb(self):
        self.ui.saveButton.setEnabled(True)
        self.ui.textEdit.setEnabled(True)

    def _saveNotes_eb(self, backend, error, backtrace):
        content = unicode(self.tr('Unable to save notes:\n%s\n')) % to_unicode(error)
        if logging.root.level <= logging.DEBUG:
            content += '\n%s\n' % to_unicode(backtrace)
            QMessageBox.critical(self, self.tr('Error while saving notes'),
            content, QMessageBox.Ok)
Exemple #11
0
    def refreshMessages(self, fillobj=False):
        if self.process_msg:
            return

        self.ui.refreshButton.setEnabled(False)
        self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError)
        if fillobj and self.thread:
            self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
        else:
            self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
Exemple #12
0
    def iter_contacts(self, cb):
        if self.id == 'online':
            status = Contact.STATUS_ONLINE | Contact.STATUS_AWAY
        elif self.id == 'offline':
            status = Contact.STATUS_OFFLINE
        else:
            status = Contact.STATUS_ALL

        self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
        self.process.do('iter_contacts', status, caps=ICapContact)
Exemple #13
0
    def retrieveContact(self, url):
        backend_name = unicode(self.ui.backendsList.currentText())
        self.ui.urlButton.setEnabled(False)

        def finished():
            self.url_process = None
            self.ui.urlButton.setEnabled(True)

        self.url_process = QtDo(self.weboob, self.retrieveContact_cb, self.retrieveContact_eb, finished)
        self.url_process.do('get_contact', url, backends=backend_name)
Exemple #14
0
    def refreshThreadMessages(self, backend, id):
        self.ui.messagesTree.clear()
        self.ui.messageBody.clear()
        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)
        self.ui.replyButton.setEnabled(False)
        self.ui.profileButton.hide()
        self.hideReply()

        self.process = QtDo(self.weboob, self._gotThreadMessages)
        self.process.do('get_thread', id, backends=backend)
Exemple #15
0
    def refreshThreads(self):
        self.ui.messagesTree.clear()
        self.ui.threadsList.clear()

        self.hideReply()
        self.ui.profileButton.hide()
        self.ui.replyButton.setEnabled(False)
        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)

        self.process_threads = QtDo(self.weboob, self._gotThread)
        self.process_threads.do('iter_threads', backends=self.backend, caps=ICapMessages)
Exemple #16
0
    def loadPage(self):
        """ Loads a page's source into the 'content' QPlainTextEdit """
        _id = unicode(self.ui.idEdit.text())
        if not _id:
            return

        self.ui.loadButton.setEnabled(False)
        self.ui.loadButton.setText('Loading...')
        self.ui.contentEdit.setReadOnly(True)

        backend = str(self.ui.backendBox.currentText())
        self.process = QtDo(self.weboob, self._loadedPage, self._errorLoadPage)
        self.process.do('get_content', _id, backends=(backend, ))
Exemple #17
0
 def postReply(self):
     text = unicode(self.ui.textEdit.toPlainText())
     self.ui.textEdit.setEnabled(False)
     self.ui.sendButton.setEnabled(False)
     m = Message(thread=self.thread,
                 id=0,
                 title=u'',
                 sender=None,
                 receivers=None,
                 content=text,
                 parent=self.messages[0].message if len(self.messages) > 0 else None)
     self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
     self.process_reply.do('post_message', m, backends=self.contact.backend)
Exemple #18
0
    def addHousing(self, backend, housing):
        if not backend:
            self.ui.queriesList.setEnabled(True)
            self.ui.bookmarksButton.setEnabled(True)
            self.process = None
            return

        if not housing:
            return

        item = HousingListWidgetItem(housing)
        item.setAttrs(self.storage)

        if housing.photos is NotLoaded:
            process = QtDo(self.weboob, lambda b, c: self.setPhoto(c, item))
            process.do('fillobj', housing, ['photos'], backends=housing.backend)
            self.process_photo[housing.id] = process
        elif housing.photos is not NotAvailable and len(housing.photos) > 0:
            if not self.setPhoto(housing, item):
                photo = housing.photos[0]
                process = QtDo(self.weboob, lambda b, p: self.setPhoto(housing, item))
                process.do('fillobj', photo, ['data'], backends=housing.backend)
                self.process_photo[housing.id] = process

        self.ui.housingsList.addItem(item)

        if housing.fullid in self.process_bookmarks:
            self.process_bookmarks.pop(housing.fullid)
Exemple #19
0
    def __init__(self, weboob, contact, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Notes()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.contact = contact

        self.ui.textEdit.setEnabled(False)
        self.ui.saveButton.setEnabled(False)
        self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb)
        self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,))

        self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes)
Exemple #20
0
    def jobSelected(self, item, prev):
        if item is not None:
            job = item.job
            self.ui.queriesFrame.setEnabled(False)

            self.process = QtDo(self.weboob, self.gotJob)
            self.process.do('fillobj', job, backends=job.backend)

        else:
            job = None

        self.setJob(job)

        if prev:
            prev.setAttrs(self.storage)
Exemple #21
0
    def doSearch(self):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        pattern = unicode(self.ui.searchEdit.text())

        # arbitrary max number of completion word
        if pattern:
            if len(self.search_history) > 50:
                self.search_history.pop(0)
            if pattern not in self.search_history:
                self.search_history.append(pattern)
                self.updateCompletion()

        self.ui.jobList.clear()
        self.process = QtDo(self.weboob, self.addJobSearch)
        self.process.do('search_job', pattern)
Exemple #22
0
class MiniVideo(QFrame):
    def __init__(self, weboob, backend, video, parent=None):
        QFrame.__init__(self, parent)
        self.ui = Ui_MiniVideo()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.backend = backend
        self.video = video
        self.ui.titleLabel.setText(video.title)
        self.ui.backendLabel.setText(backend.name)
        self.ui.durationLabel.setText(unicode(video.duration))
        self.ui.authorLabel.setText(unicode(video.author))
        self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
        if video.rating_max:
            self.ui.ratingLabel.setText('%s / %s' %
                                        (video.rating, video.rating_max))
        else:
            self.ui.ratingLabel.setText('%s' % video.rating)

        self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
        self.process_thumbnail.do('fillobj',
                                  self.video, ['thumbnail'],
                                  backends=backend)

    def gotThumbnail(self, backend, video):
        if not backend:
            return

        if video.thumbnail and video.thumbnail.data:
            img = QImage.fromData(video.thumbnail.data)
            self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))

    def enterEvent(self, event):
        self.setFrameShadow(self.Sunken)
        QFrame.enterEvent(self, event)

    def leaveEvent(self, event):
        self.setFrameShadow(self.Raised)
        QFrame.leaveEvent(self, event)

    def mousePressEvent(self, event):
        QFrame.mousePressEvent(self, event)

        video = self.backend.get_video(self.video.id)
        if video:
            video_widget = Video(video, self)
            video_widget.show()
Exemple #23
0
    def display_photo(self):
        if self.displayed_photo_idx >= len(self.contact.photos):
            self.displayed_photo_idx = len(self.contact.photos) - 1
        if self.displayed_photo_idx < 0:
            self.ui.photoUrlLabel.setText('')
            return

        photo = self.contact.photos.values()[self.displayed_photo_idx]
        if photo.data:
            data = photo.data
            if photo.id in self.process_photo:
                self.process_photo.pop(photo.id)
        else:
            self.process_photo[photo.id] = QtDo(
                self.weboob, lambda b, p: self.display_photo())
            self.process_photo[photo.id].do('fillobj',
                                            photo, ['data'],
                                            backends=self.contact.backend)

            if photo.thumbnail_data:
                data = photo.thumbnail_data
            else:
                return

        img = QImage.fromData(data)
        img = img.scaledToWidth(self.width() / 3)

        self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
        if photo.url is not NotLoaded:
            text = '<a href="%s">%s</a>' % (photo.url, photo.url)
            if photo.hidden:
                text += '<br /><font color=#ff0000><i>(Hidden photo)</i></font>'
            self.ui.photoUrlLabel.setText(text)
Exemple #24
0
    def saveNotes(self):
        text = unicode(self.ui.textEdit.toPlainText())
        self.ui.saveButton.setEnabled(False)
        self.ui.textEdit.setEnabled(False)

        self.process = QtDo(self.weboob, self._saveNotes_cb, self._saveNotes_eb)
        self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))
Exemple #25
0
    def jobSelected(self, item, prev):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        if item is not None:
            job = item.job
            self.ui.queriesTabWidget.setEnabled(False)

            self.process = QtDo(self.weboob, self.gotJob)
            self.process.do('fillobj', job, backends=job.backend)

        else:
            job = None

        self.setJob(job)

        if prev:
            prev.setAttrs(self.storage)
Exemple #26
0
    def _sendPressed(self):
        if not self.ui.replyWidget.isVisible():
            return

        text = unicode(self.ui.replyEdit.toPlainText())
        title = unicode(self.ui.titleEdit.text())

        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)
        self.ui.messagesTree.setEnabled(False)
        self.ui.replyButton.setEnabled(False)
        self.ui.replyWidget.setEnabled(False)
        self.ui.sendButton.setText(self.tr('Sending...'))
        flags = 0
        if self.ui.htmlBox.currentIndex() == 0:
            flags = Message.IS_HTML
        m = Message(thread=self.thread,
                    id=0,
                    title=title,
                    sender=None,
                    receivers=None,
                    content=text,
                    parent=self.message,
                    flags=flags)
        self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
        self.process_reply.do('post_message', m, backends=self.thread.backend)
Exemple #27
0
    def refreshHousingsList(self):
        name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex()))
        q = self.config.get('queries', name)

        if q is None:
            return q

        self.ui.housingsList.clear()
        self.ui.queriesList.setEnabled(False)
        self.ui.bookmarksButton.setEnabled(False)

        query = Query()
        query.type = int(q.get('type', 0))
        query.cities = []
        for c in q['cities']:
            city = City(c['id'])
            city.backend = c['backend']
            city.name = c['name']
            query.cities.append(city)

        query.area_min = int(q['area_min']) or None
        query.area_max = int(q['area_max']) or None
        query.cost_min = int(q['cost_min']) or None
        query.cost_max = int(q['cost_max']) or None
        query.nb_rooms = int(q['nb_rooms']) or None

        self.process = QtDo(self.weboob, self.addHousing)
        self.process.do('search_housings', query)
Exemple #28
0
    def searchSubtitleAction(self, lang, pattern):
        self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
        for mini in self.minis:
            self.ui.list_content.layout().removeWidget(mini)
            mini.hide()
            mini.deleteLater()

        self.minis = []
        self.parent.ui.searchEdit.setEnabled(False)
        QApplication.setOverrideCursor(Qt.WaitCursor)

        backend_name = str(
            self.parent.ui.backendEdit.itemData(
                self.parent.ui.backendEdit.currentIndex()).toString())

        self.process = QtDo(
            self.weboob, self.addSubtitle, fb=self.processFinished)
        #self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=CapSubtitle)
        self.process.do(
            self.app._do_complete,
            self.parent.getCount(), ('name'),
            'iter_subtitles',
            lang,
            pattern,
            backends=backend_name,
            caps=CapSubtitle)
        self.parent.ui.stopButton.show()
Exemple #29
0
    def loadHistory(self):
        """ Loads the page's log into the 'History' tab """
        if self.backend is None:
            return

        self.ui.loadHistoryButton.setEnabled(False)
        self.ui.loadHistoryButton.setText("Loading...")

        self.ui.historyTable.clear()
        self.ui.historyTable.setRowCount(0)

        self.ui.historyTable.setHorizontalHeaderLabels(["Revision",
                                                        "Time",
                                                        "Author",
                                                        "Summary"])
        self.ui.historyTable.setColumnWidth(3, 1000)

        self.process = QtDo(self.weboob,
                            self._gotRevision,
                            self._errorHistory)
        self.process.do(self.app._do_complete,
                        self.ui.nbRevBox.value(),
                        (),
                        'iter_revisions',
                        self.content.id,
                        backends=(self.backend,))
Exemple #30
0
    def savePage(self):
        """ Saves the current page to the remote site """
        if self.backend is None:
            return
        new_content = unicode(self.ui.contentEdit.toPlainText())
        minor = self.ui.minorBox.isChecked()
        if new_content != self.content.content:
            self.ui.saveButton.setEnabled(False)
            self.ui.saveButton.setText('Saving...')
            self.ui.contentEdit.setReadOnly(True)
            self.content.content = new_content
            message = unicode(self.ui.descriptionEdit.text())

            def finished():
                self.process = None
                self.ui.saveButton.setText('Saved')
                self.ui.descriptionEdit.clear()
                self.ui.contentEdit.setReadOnly(False)

            self.process = QtDo(self.weboob,
                                None,
                                self._errorSavePage,
                                finished)
            self.process.do('push_content',
                            self.content,
                            message,
                            minor=minor,
                            backends=self.backend)
Exemple #31
0
    def display_photo(self):
        if not self.housing.photos:
            self.ui.photosFrame.hide()
            return

        if self.displayed_photo_idx >= len(self.housing.photos):
            self.displayed_photo_idx = len(self.housing.photos) - 1
        if self.displayed_photo_idx < 0:
            self.ui.photosFrame.hide()
            return

        self.ui.photosFrame.show()

        photo = self.housing.photos[self.displayed_photo_idx]
        if photo.data:
            data = photo.data
            if photo.id in self.process_photo:
                self.process_photo.pop(photo.id)
        else:
            self.process_photo[photo.id] = QtDo(self.weboob, lambda b,p: self.display_photo())
            self.process_photo[photo.id].do('fillobj', photo, ['data'], backends=self.housing.backend)

            return

        img = QImage.fromData(data)
        img = img.scaledToWidth(self.width()/3)

        self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
        if photo.url is not NotLoaded:
            text = '<a href="%s">%s</a>' % (photo.url, photo.url)
            self.ui.photoUrlLabel.setText(text)
Exemple #32
0
    def openJob(self):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        url = unicode(self.ui.idEdit.text())
        if not url:
            return

        for backend in self.weboob.iter_backends():
            job = backend.get_job_advert(url)
            if job:
                self.process = QtDo(self.weboob, self.gotJob)
                self.process.do('fillobj', job, backends=job.backend)
                break

        self.setJob(job)
        self.ui.idEdit.clear()
        QApplication.restoreOverrideCursor()
Exemple #33
0
    def searchCity(self):
        pattern = unicode(self.ui.cityEdit.text())
        self.ui.resultsList.clear()
        self.ui.cityEdit.clear()
        self.ui.cityEdit.setEnabled(False)

        self.search_process = QtDo(self.weboob, self.addResult, fb=self.addResultEnd)
        self.search_process.do('search_city', pattern)
Exemple #34
0
    def refreshMessages(self, fillobj=False):
        if self.process_msg:
            return

        self.ui.refreshButton.setEnabled(False)

        def finished():
            #v = self.ui.scrollArea.verticalScrollBar()
            #print v.minimum(), v.value(), v.maximum(), v.sliderPosition()
            #self.ui.scrollArea.verticalScrollBar().setValue(self.ui.scrollArea.verticalScrollBar().maximum())
            self.process_msg = None

        self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError, finished)
        if fillobj and self.thread:
            self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
        else:
            self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
Exemple #35
0
 def refreshEventsList(self):
     self.ui.eventsList.clear()
     self.ui.refreshButton.setEnabled(False)
     if self.ui.typeBox.currentIndex() >= 0:
         # XXX strangely, in gotEvent() in the loop to check if there is already the
         # event type to try to introduce it in list, itemData() returns the right value.
         # But, I don't know why, here, it will ALWAYS return None...
         # So the filter does not work currently.
         self.events_filter = self.ui.typeBox.itemData(
             self.ui.typeBox.currentIndex())
     else:
         self.event_filter = None
     self.ui.typeBox.setEnabled(False)
     self.ui.typeBox.clear()
     self.ui.typeBox.addItem('All', None)
     self.process = QtDo(self.weboob, self.gotEvent)
     self.process.do('iter_events')
Exemple #36
0
class MiniVideo(QFrame):
    def __init__(self, weboob, backend, video, parent=None):
        QFrame.__init__(self, parent)
        self.ui = Ui_MiniVideo()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.backend = backend
        self.video = video
        self.ui.titleLabel.setText(video.title)
        self.ui.backendLabel.setText(backend.name)
        self.ui.durationLabel.setText(unicode(video.duration))
        self.ui.authorLabel.setText(unicode(video.author))
        self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
        if video.rating_max:
            self.ui.ratingLabel.setText('%s / %s' % (video.rating, video.rating_max))
        else:
            self.ui.ratingLabel.setText('%s' % video.rating)

        self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
        self.process_thumbnail.do('fillobj', self.video, ['thumbnail'], backends=backend)

    def gotThumbnail(self, backend, video):
        if not backend:
            return

        if video.thumbnail and video.thumbnail.data:
            img = QImage.fromData(video.thumbnail.data)
            self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))

    def enterEvent(self, event):
        self.setFrameShadow(self.Sunken)
        QFrame.enterEvent(self, event)

    def leaveEvent(self, event):
        self.setFrameShadow(self.Raised)
        QFrame.leaveEvent(self, event)

    def mousePressEvent(self, event):
        QFrame.mousePressEvent(self, event)

        video = self.backend.get_video(self.video.id)
        if video:
            video_widget = Video(video, self)
            video_widget.show()
Exemple #37
0
    def __init__(self, weboob, contact, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Profile()
        self.ui.setupUi(self)

        self.connect(self.ui.previousButton, SIGNAL('clicked()'), self.previousClicked)
        self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked)

        self.weboob = weboob
        self.contact = contact
        self.loaded_profile = False
        self.displayed_photo_idx = 0
        self.process_photo = {}

        missing_fields = self.gotProfile(self.weboob.get_backend(contact.backend), contact)
        if len(missing_fields) > 0:
            self.process_contact = QtDo(self.weboob, self.gotProfile, self.gotError)
            self.process_contact.do('fillobj', self.contact, missing_fields, backends=self.contact.backend)
Exemple #38
0
class MetaGroup(IGroup):
    def iter_contacts(self, cb):
        if self.id == 'online':
            status = Contact.STATUS_ONLINE | Contact.STATUS_AWAY
        elif self.id == 'offline':
            status = Contact.STATUS_OFFLINE
        else:
            status = Contact.STATUS_ALL

        self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
        self.process.do('iter_contacts', status, caps=ICapContact)

    def cb(self, cb, backend, contact):
        if contact:
            cb(contact)
        elif not backend:
            self.process = None
            cb(None)
Exemple #39
0
class MetaGroup(IGroup):
    def iter_contacts(self, cb):
        if self.id == 'online':
            status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
        elif self.id == 'offline':
            status = Contact.STATUS_OFFLINE
        else:
            status = Contact.STATUS_ALL

        self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
        self.process.do('iter_contacts', status, caps=ICapContact)

    def cb(self, cb, backend, contact):
        if contact:
            cb(contact)
        elif not backend:
            self.process = None
            cb(None)
Exemple #40
0
    def urlClicked(self):
        url = unicode(self.ui.urlEdit.text())
        if not url:
            return

        backend_name = unicode(self.ui.backendsList.currentText())
        self.ui.urlButton.setEnabled(False)
        self.url_process = QtDo(self.weboob, self.urlClicked_cb, self.urlClicked_eb)
        self.url_process.do('get_contact', url, backends=backend_name)
Exemple #41
0
    def castingAction(self, backend_name, id, role):
        self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
        for mini in self.minis:
            self.ui.list_content.layout().removeWidget(mini)
            mini.hide()
            mini.deleteLater()

        self.minis = []
        self.parent.ui.searchEdit.setEnabled(False)
        QApplication.setOverrideCursor(Qt.WaitCursor)

        self.process = QtDo(self.weboob, self.addPerson)
        self.process.do('iter_movie_persons',
                        id,
                        role,
                        backends=backend_name,
                        caps=ICapCinema)
        self.parent.ui.stopButton.show()
Exemple #42
0
    def refreshThreadMessages(self, backend, id):
        self.ui.messagesTree.clear()
        self.ui.messageBody.clear()
        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)
        self.ui.replyButton.setEnabled(False)
        self.hideReply()

        self.process = QtDo(self.weboob, self._gotThreadMessages)
        self.process.do('get_thread', id, backends=backend)
Exemple #43
0
    def refreshMessages(self, fillobj=False):
        if self.process_msg:
            return

        self.ui.refreshButton.setEnabled(False)
        self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError)
        if fillobj and self.thread:
            self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
        else:
            self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
Exemple #44
0
    def iter_contacts(self, cb):
        if self.id == 'online':
            status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
        elif self.id == 'offline':
            status = Contact.STATUS_OFFLINE
        else:
            status = Contact.STATUS_ALL

        self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
        self.process.do('iter_contacts', status, caps=ICapContact)
Exemple #45
0
class MetaGroup(IGroup):
    def iter_contacts(self, cb):
        if self.id == 'online':
            status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
        elif self.id == 'offline':
            status = Contact.STATUS_OFFLINE
        else:
            status = Contact.STATUS_ALL

        self.process = QtDo(self.weboob, lambda d: self.cb(cb, d), fb=lambda: self.fb(cb))
        self.process.do('iter_contacts', status, caps=CapContact)

    def cb(self, cb, contact):
        if contact:
            cb(contact)

    def fb(self, fb):
        self.process = None
        if fb:
            fb(None)
Exemple #46
0
    def refreshThreads(self):
        self.ui.messagesTree.clear()
        self.ui.threadsList.clear()

        self.hideReply()
        self.ui.replyButton.setEnabled(False)
        self.ui.backendsList.setEnabled(False)
        self.ui.threadsList.setEnabled(False)

        self.process_threads = QtDo(self.weboob, self._gotThread)
        self.process_threads.do('iter_threads', backends=self.backend, caps=ICapMessages)
Exemple #47
0
    def addHousing(self, backend, housing):
        if not backend:
            self.ui.queriesList.setEnabled(True)
            self.ui.bookmarksButton.setEnabled(True)
            self.process = None
            return

        if not housing:
            return

        item = HousingListWidgetItem(housing)
        item.setAttrs(self.storage)

        if housing.photos is NotLoaded:
            process = QtDo(self.weboob, lambda b, c: self.setPhoto(c, item))
            process.do('fillobj', housing, ['photos'], backends=housing.backend)
            self.process_photo[housing.id] = process
        elif housing.photos is not NotAvailable and len(housing.photos) > 0:
            if not self.setPhoto(housing, item):
                photo = housing.photos[0]
                process = QtDo(self.weboob, lambda b, p: self.setPhoto(housing, item))
                process.do('fillobj', photo, ['data'], backends=housing.backend)
                self.process_photo[housing.id] = process

        self.ui.housingsList.addItem(item)

        if housing.fullid in self.process_bookmarks:
            self.process_bookmarks.pop(housing.fullid)
Exemple #48
0
 def postReply(self):
     text = unicode(self.ui.textEdit.toPlainText())
     self.ui.textEdit.setEnabled(False)
     self.ui.sendButton.setEnabled(False)
     m = Message(thread=self.thread,
                 id=0,
                 title=u'',
                 sender=None,
                 receivers=None,
                 content=text,
                 parent=self.messages[0].message if len(self.messages) > 0 else None)
     self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
     self.process_reply.do('post_message', m, backends=self.contact.backend)
Exemple #49
0
    def gotEvent(self, event):
        found = False
        for i in xrange(self.ui.typeBox.count()):
            s = self.ui.typeBox.itemData(i)
            if s == event.type:
                found = True
        if not found:
            print(event.type)
            self.ui.typeBox.addItem(event.type.capitalize(), event.type)
            if event.type == self.event_filter:
                self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)

        if self.event_filter and self.event_filter != event.type:
            return

        if not event.contact:
            return

        contact = event.contact
        contact.backend = event.backend
        status = ''

        if contact.status == contact.STATUS_ONLINE:
            status = u'Online'
            status_color = 0x00aa00
        elif contact.status == contact.STATUS_OFFLINE:
            status = u'Offline'
            status_color = 0xff0000
        elif contact.status == contact.STATUS_AWAY:
            status = u'Away'
            status_color = 0xffad16
        else:
            status = u'Unknown'
            status_color = 0xaaaaaa

        if contact.status_msg:
            status += u' — %s' % contact.status_msg

        name = '<h2>%s</h2><font color="#%06X">%s</font><br /><i>%s</i>' % (contact.name, status_color, status, event.backend)
        date = event.date.strftime('%Y-%m-%d %H:%M')
        type = event.type
        message = event.message

        item = QTreeWidgetItem(None, [name, date, type, message])
        item.setData(0, Qt.UserRole, event)
        if contact.photos is NotLoaded:
            process = QtDo(self.weboob, lambda c: self.setPhoto(c, item))
            process.do('fillobj', contact, ['photos'], backends=contact.backend)
            self.photo_processes[contact.id] = process
        elif len(contact.photos) > 0:
            if not self.setPhoto(contact, item):
                photo = contact.photos.values()[0]
                process = QtDo(self.weboob, lambda p: self.setPhoto(contact, item))
                process.do('fillobj', photo, ['thumbnail_data'], backends=contact.backend)
                self.photo_processes[contact.id] = process

        self.ui.eventsList.addTopLevelItem(item)
        self.ui.eventsList.resizeColumnToContents(0)
        self.ui.eventsList.resizeColumnToContents(1)
Exemple #50
0
    def castingAction(self, backend_name, id, role):
        self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
        for mini in self.minis:
            self.ui.list_content.layout().removeWidget(mini)
            mini.hide()
            mini.deleteLater()

        self.minis = []
        self.parent.ui.searchEdit.setEnabled(False)
        QApplication.setOverrideCursor(Qt.WaitCursor)

        self.process = QtDo(self.weboob, self.addPerson, fb=self.processFinished)
        self.process.do('iter_movie_persons', id, role, backends=backend_name, caps=CapCinema)
        self.parent.ui.stopButton.show()
Exemple #51
0
    def __init__(self, weboob, contact, parent=None):
        QWidget.__init__(self, parent)
        self.ui = Ui_Notes()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.contact = contact

        self.ui.textEdit.setEnabled(False)
        self.ui.saveButton.setEnabled(False)
        self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb)
        self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,))

        self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes)
Exemple #52
0
 def loadPage(self):
     """ Loads a page's source into the 'content' QPlainTextEdit """
     _id = unicode(self.ui.idEdit.text())
     if not _id:
         return
     
     self.ui.loadButton.setEnabled(False)
     self.ui.loadButton.setText('Loading...')
     self.ui.contentEdit.setReadOnly(True)
             
     backend = str(self.ui.backendBox.currentText())
     self.process = QtDo(self.weboob,
                         self._loadedPage,
                         self._errorLoadPage)
     self.process.do('get_content', _id, backends=(backend,))
Exemple #53
0
    def doSearch(self):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        pattern = unicode(self.ui.searchEdit.text())

        # arbitrary max number of completion word
        if pattern:
            if len(self.search_history) > 50:
                self.search_history.pop(0)
            if pattern not in self.search_history:
                self.search_history.append(pattern)
                self.updateCompletion()

        self.ui.jobList.clear()
        self.process = QtDo(self.weboob, self.addJobSearch)
        self.process.do('search_job', pattern)
Exemple #54
0
 def refreshEventsList(self):
     self.ui.eventsList.clear()
     self.ui.refreshButton.setEnabled(False)
     if self.ui.typeBox.currentIndex() >= 0:
         # XXX strangely, in gotEvent() in the loop to check if there is already the
         # event type to try to introduce it in list, itemData() returns the right value.
         # But, I don't know why, here, it will ALWAYS return None...
         # So the filter does not work currently.
         self.events_filter = self.ui.typeBox.itemData(self.ui.typeBox.currentIndex())
     else:
         self.event_filter = None
     self.ui.typeBox.setEnabled(False)
     self.ui.typeBox.clear()
     self.ui.typeBox.addItem('All', None)
     self.process = QtDo(self.weboob, self.gotEvent)
     self.process.do('iter_events')
Exemple #55
0
    def jobSelected(self, item, prev):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        if item is not None:
            job = item.job
            self.ui.queriesTabWidget.setEnabled(False)

            self.process = QtDo(self.weboob, self.gotJob)
            self.process.do('fillobj', job, backends=job.backend)

        else:
            job = None

        self.setJob(job)

        if prev:
            prev.setAttrs(self.storage)
Exemple #56
0
    def openJob(self):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        url = unicode(self.ui.idEdit.text())
        if not url:
            return

        for backend in self.weboob.iter_backends():
            job = backend.get_job_advert(url)
            if job:
                self.process = QtDo(self.weboob, self.gotJob)
                self.process.do('fillobj', job, backends=job.backend)
                break

        self.setJob(job)
        self.ui.idEdit.clear()
        QApplication.restoreOverrideCursor()
Exemple #57
0
    def search(self):
        pattern = unicode(self.ui.searchEdit.text())
        if not pattern:
            return

        for minivideo in self.minivideos:
            self.ui.scrollAreaContent.layout().removeWidget(minivideo)
            minivideo.hide()
            minivideo.deleteLater()

        self.minivideos = []
        self.ui.searchEdit.setEnabled(False)

        backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())

        self.process = QtDo(self.weboob, self.addVideo)
        self.process.do('search_videos', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, max_results=20, backends=backend_name)