[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

@ -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))