From 1968bc6c9587e8ffd238e0fdbc25759acb6dac01 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 26 Nov 2014 13:16:09 +0100 Subject: [PATCH] [qcineoob] movies in common implemented in person page --- weboob/applications/qcineoob/main_window.py | 36 ++++++++++++++++ weboob/applications/qcineoob/person.py | 10 +++++ weboob/applications/qcineoob/ui/person.ui | 46 +++++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/weboob/applications/qcineoob/main_window.py b/weboob/applications/qcineoob/main_window.py index d0faab77..3bc16c9b 100644 --- a/weboob/applications/qcineoob/main_window.py +++ b/weboob/applications/qcineoob/main_window.py @@ -102,6 +102,42 @@ class Result(QFrame): self.process.do('iter_movie_persons', id, role, backends=backend_name, caps=CapCinema) self.parent.ui.stopButton.show() + def moviesInCommonAction(self, backend_name, id1, id2): + 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) + + for a_backend in self.weboob.iter_backends(): + if (backend_name and a_backend.name == backend_name): + backend = a_backend + person1 = backend.get_person(id1) + person2 = backend.get_person(id2) + + lid1 = [] + for p in backend.iter_person_movies_ids(id1): + lid1.append(p) + lid2 = [] + for p in backend.iter_person_movies_ids(id2): + lid2.append(p) + + inter = list(set(lid1) & set(lid2)) + + for common in inter: + movie = backend.get_movie(common) + movie.backend = backend_name + role1 = movie.get_role_by_person_id(person1.id) + role2 = movie.get_role_by_person_id(person2.id) + movie.short_description = '%s as %s ; %s as %s'%(person1.name, role1, person2.name, role2) + self.addMovie(movie) + + self.processFinished() + def personsInCommonAction(self, backend_name, id1, id2): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: diff --git a/weboob/applications/qcineoob/person.py b/weboob/applications/qcineoob/person.py index 9d4a2922..6be2bcb6 100644 --- a/weboob/applications/qcineoob/person.py +++ b/weboob/applications/qcineoob/person.py @@ -35,6 +35,7 @@ class Person(QFrame): self.connect(self.ui.filmographyButton, SIGNAL("clicked()"), self.filmography) self.connect(self.ui.biographyButton, SIGNAL("clicked()"), self.biography) + self.connect(self.ui.moviesInCommonButton, SIGNAL("clicked()"), self.moviesInCommon) self.person = person self.backend = backend @@ -87,3 +88,12 @@ class Person(QFrame): self.ui.biographyLabel.setText('Full biography:') self.ui.biographyButton.hide() QApplication.restoreOverrideCursor() + + def moviesInCommon(self): + my_id = self.person.id + my_name = self.person.name + other_id = unicode(self.ui.moviesInCommonEdit.text()).split('@')[0] + other_person = self.backend.get_person(other_id) + other_name = other_person.name + desc = 'Movies in common %s, %s'%(my_name, other_name) + self.parent.doAction(desc, self.parent.moviesInCommonAction, [self.backend.name, my_id, other_id]) diff --git a/weboob/applications/qcineoob/ui/person.ui b/weboob/applications/qcineoob/ui/person.ui index 91e3fb59..625de366 100644 --- a/weboob/applications/qcineoob/ui/person.ui +++ b/weboob/applications/qcineoob/ui/person.ui @@ -72,6 +72,52 @@ filmography + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Search movies in common with + + + + + + + + + + 0 + 0 + + + + Person ID : + + + + + + + + 0 + 0 + + + + + + + + +