[qcookboob] operationnal

This commit is contained in:
Julien Veyssier 2013-03-16 12:31:21 +01:00
commit 66141a5c93
4 changed files with 72 additions and 230 deletions

View file

@ -63,4 +63,4 @@ class MiniRecipe(QFrame):
recipe = self.backend.get_recipe(self.recipe.id)
if recipe:
self.parent.doAction('Details of recipe "%s"' %
recipe.title, self.parent.displayMovie, [recipe, self.backend])
recipe.title, self.parent.displayRecipe, [recipe, self.backend])

View file

@ -32,50 +32,50 @@ class Recipe(QFrame):
self.parent = parent
self.ui = Ui_Recipe()
self.ui.setupUi(self)
langs = LANGUAGE_CONV.keys()
langs.sort()
for lang in langs:
self.ui.langCombo.addItem(lang)
self.recipe = recipe
self.backend = backend
self.ui.titleLabel.setText(recipe.original_title)
self.ui.durationLabel.setText(unicode(recipe.duration))
self.gotThumbnail()
self.ui.idEdit.setText(u'%s@%s' % (recipe.id, backend.name))
if not empty(recipe.other_titles):
self.ui.otherTitlesPlain.setPlainText('\n'.join(recipe.other_titles))
if not empty(recipe.title):
self.ui.titleLabel.setText(recipe.title)
if not empty(recipe.nb_person):
self.ui.nbPersonLabel.setText('%s'%recipe.nb_person)
else:
self.ui.otherTitlesPlain.parent().hide()
if not empty(recipe.release_date):
self.ui.releaseDateLabel.setText(recipe.release_date.strftime('%Y-%m-%d'))
self.ui.nbPersonLabel.parent().hide()
if not empty(recipe.preparation_time):
self.ui.prepTimeLabel.setText('%s min' % recipe.preparation_time)
else:
self.ui.releaseDateLabel.parent().hide()
if not empty(recipe.duration):
self.ui.durationLabel.setText('%s min' % recipe.duration)
self.ui.prepTimeLabel.parent().hide()
if not empty(recipe.cooking_time):
self.ui.cookingTimeLabel.setText('%s min' % recipe.cooking_time)
else:
self.ui.durationLabel.parent().hide()
if not empty(recipe.pitch):
self.ui.pitchPlain.setPlainText('%s' % recipe.pitch)
self.ui.cookingTimeLabel.parent().hide()
if not empty(recipe.ingredients):
txt = u''
for ing in recipe.ingredients:
txt += '* %s\n' % ing
self.ui.ingredientsPlain.setPlainText('%s' % txt)
else:
self.ui.pitchPlain.parent().hide()
if not empty(recipe.country):
self.ui.countryLabel.setText('%s' % recipe.country)
self.ui.ingredientsPlain.parent().hide()
if not empty(recipe.instructions):
self.ui.instructionsPlain.setPlainText('%s' % recipe.instructions)
else:
self.ui.countryLabel.parent().hide()
if not empty(recipe.note):
self.ui.noteLabel.setText('%s' % recipe.note)
self.ui.instructionsPlain.parent().hide()
if not empty(recipe.comments):
txt = u''
for com in recipe.comments:
txt += '* %s\n' % com
self.ui.commentsPlain.setPlainText('%s' % txt)
else:
self.ui.noteLabel.parent().hide()
for role in ROLE_LIST:
self.ui.castingCombo.addItem('%ss' % role)
self.ui.commentsPlain.parent().hide()
self.ui.verticalLayout.setAlignment(Qt.AlignTop)
self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
def gotThumbnail(self):
if not empty(self.recipe.thumbnail_url):
data = urllib.urlopen(self.recipe.thumbnail_url).read()
if not empty(self.recipe.picture_url):
data = urllib.urlopen(self.recipe.picture_url).read()
img = QImage.fromData(data)
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))

View file

@ -43,45 +43,6 @@
<item>
<widget class="QLineEdit" name="searchEdit"/>
</item>
<item>
<widget class="QComboBox" name="typeCombo">
<item>
<property name="text">
<string>movie</string>
</property>
</item>
<item>
<property name="text">
<string>person</string>
</property>
</item>
<item>
<property name="text">
<string>torrent</string>
</property>
</item>
<item>
<property name="text">
<string>subtitle</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="langLabel">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>language</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="langCombo"/>
</item>
<item>
<widget class="QComboBox" name="backendEdit"/>
</item>
@ -200,8 +161,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>63</width>
<height>18</height>
<width>96</width>
<height>26</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8"/>

View file

@ -54,93 +54,6 @@
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_10">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="castingButton">
<property name="text">
<string>view casting</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="castingCombo">
<item>
<property name="text">
<string>all</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_12">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="torrentButton">
<property name="text">
<string>search torrents</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_11">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="subtitleButton">
<property name="text">
<string>search subtitles</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="langCombo"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@ -232,6 +145,134 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</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="QLabel" name="label_3">
<property name="text">
<string>Number of people:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nbPersonLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Preparation time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="prepTimeLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_7">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Cook time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cookingTimeLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Ingredients:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="ingredientsPlain">
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_8">
<property name="sizePolicy">
@ -262,12 +303,12 @@
</size>
</property>
<property name="text">
<string>Other titles:</string>
<string>Instructions:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="otherTitlesPlain">
<widget class="QPlainTextEdit" name="instructionsPlain">
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
@ -276,166 +317,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</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="QLabel" name="label_3">
<property name="text">
<string>Duration:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="durationLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Release date:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="releaseDateLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Pitch:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="pitchPlain">
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_7">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Country:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="countryLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Note:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="noteLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_13">
<property name="maximumSize">
@ -454,12 +335,12 @@
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>All release dates:</string>
<string>Comments:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="allReleasesPlain">
<widget class="QTextEdit" name="commentsPlain">
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>