
Public Member Functions | |
| def | __init__ |
| def | setup_ui |
| def | fill |
| def | change_published_date |
| def | change_published_date_year |
| def | change_published_date_month |
| def | change_published_date_day |
| def | validate |
| def | add_authors |
| def | delete_authors |
| def | edit_authors |
| def | add_drawers |
| def | delete_drawers |
| def | edit_drawers |
| def | select_context |
| def | select_editor |
| def | select_collection |
| def | select_series |
| def | fetch_form |
| def | apply_value |
Public Attributes | |
| series_entity | |
| collection_entity | |
| editor_entity | |
Static Public Attributes | |
| model = Album | |
| def py::gui::editor::album::__init__ | ( | self, | ||
| parent, | ||||
| entity, | ||||
content = None | ||||
| ) |
Reimplemented from py::gui::editor::entity_editor.
00281 : 00282 Ui_album_editor.__init__(self) 00283 self.series_entity = None 00284 self.collection_entity = None 00285 self.editor_entity = None 00286 for authors in ['authors','drawers'] : 00287 setattr(self,"%s_items"%authors,[]) 00288 entity_editor.__init__(self, parent, entity) 00289 if not entity and content : 00290 self.fill(content) 00291 self.validate() 00292 def setup_ui( self ) :
| def py::gui::editor::album::setup_ui | ( | self | ) |
Reimplemented from py::gui::editor::entity_editor.
00293 : 00294 entity_editor.setup_ui(self) 00295 if not self.entity : 00296 for id in [qodb.cte.main_library_id, qodb.cte.shopping_list_id] : 00297 self.libraries.addItem(Library.objects.get(id=id).name, QVariant(id)) 00298 else : 00299 self.add_to_library.hide() 00300 self.libraries.hide() 00301 00302 for f in [self.editor,self.collection,self.series] : 00303 p = f.palette() 00304 p.setColor(QPalette.Text,p.windowText().color()) 00305 f.setPalette(p) 00306 00307 for x in ["editor","collection","series"] : 00308 self.connect(getattr(self,"%s_change"%x), SIGNAL("clicked()"), getattr(self,"select_%s"%x)) 00309 for authors in ['authors','drawers'] : 00310 self.connect(getattr(self,"%s_add"%authors), SIGNAL("clicked()"), getattr(self, "add_%s"%authors)) 00311 self.connect(getattr(self,"%s_delete"%authors), SIGNAL("clicked()"), getattr(self, "delete_%s"%authors)) 00312 self.connect(getattr(self,authors), SIGNAL("doubleClicked(const QModelIndex&)"), getattr(self, "edit_%s"%authors)) 00313 for d in ['day','month','year'] : 00314 self.connect(getattr(self,"published_date_%s"%d), SIGNAL("valueChanged(int)"), getattr(self, "change_published_date_%s"%d)) 00315 def fill( self, album = None ) :
| def py::gui::editor::album::fill | ( | self, | ||
album = None | ||||
| ) |
00316 : 00317 if not album : 00318 album = self.entity 00319 self.series_entity = album.series 00320 self.collection_entity = self.series_entity.collection 00321 self.editor_entity = self.collection_entity.editor 00322 00323 self.name.setText(album.name) 00324 self.volume.setValue(album.volume) 00325 self.isbn.setText(album.isbn) 00326 self.ean.setText(album.ean) 00327 if album.published_date : 00328 year, month, day = map(int,album.published_date.split('-')) 00329 self.published_date_year.setValue(year) 00330 self.published_date_month.setValue(month) 00331 self.published_date_day.setValue(day) 00332 self.guiding_price.setValue(album.guiding_price) 00333 self.series.setText(self.series_entity.name) 00334 self.collection.setText(self.collection_entity.name) 00335 self.editor.setText(self.editor_entity.name) 00336 00337 for authors in ['authors','drawers'] : 00338 setattr(self,"%s_items"%authors,[]) 00339 for entity in getattr(album,"%s_entities"%authors) : 00340 getattr(self,"%s_items"%authors).append(entity_item(entity, entity.name, getattr(self,authors))) 00341 00342 def change_published_date( self, context, value ) :
| def py::gui::editor::album::change_published_date | ( | self, | ||
| context, | ||||
| value | ||||
| ) |
00343 : 00344 contexts = ['year','month','day'] 00345 pos = contexts.index(context) 00346 if value == 0 : 00347 if pos != len(contexts) - 1 : 00348 getattr(self, "published_date_%s"%contexts[pos+1]).setValue(0) 00349 else : 00350 if pos > 0 : 00351 pc = contexts[pos-1] 00352 pfield = getattr(self, "published_date_%s"%pc) 00353 if pfield.value() == 0 : 00354 pfield.setValue(getattr(datetime.date.today(),pc)) 00355 def change_published_date_year( self, value ) :
| def py::gui::editor::album::change_published_date_year | ( | self, | ||
| value | ||||
| ) |
| def py::gui::editor::album::change_published_date_month | ( | self, | ||
| value | ||||
| ) |
| def py::gui::editor::album::change_published_date_day | ( | self, | ||
| value | ||||
| ) |
| def py::gui::editor::album::validate | ( | self | ) |
00363 : 00364 valid = True 00365 00366 def make_red( field ) : 00367 p = field.palette() 00368 p.setColor(QPalette.Base,Qt.red) 00369 p.setColor(QPalette.Window,Qt.red) 00370 field.setPalette(p) 00371 def make_ro( field ) : 00372 p = field.palette() 00373 p.setColor(QPalette.Window, self.palette().window().color()) 00374 p.setColor(QPalette.Base,p.window().color()) 00375 field.setPalette(p) 00376 00377 for field in ['editor','collection','series'] : 00378 if getattr(self,"%s_entity"%field) is None : 00379 make_red(getattr(self,field)) 00380 valid = False 00381 else : 00382 make_ro(getattr(self,field)) 00383 00384 self.collection_change.setEnabled(self.editor_entity is not None) 00385 self.series_change.setEnabled(self.collection_entity is not None) 00386 self.okButton.setEnabled(valid) 00387 def add_authors( self, field='authors' ) :
| def py::gui::editor::album::add_authors | ( | self, | ||
field = 'authors' | ||||
| ) |
00388 : 00389 entity = author_editor(self, None).exec_() 00390 if entity : 00391 items = getattr(self,"%s_items"%field) 00392 listwidget = getattr(self,field) 00393 items.append(entity_item(entity, entity.name, listwidget)) 00394 listwidget.sortItems() 00395 def delete_authors( self, field='authors' ) :
| def py::gui::editor::album::delete_authors | ( | self, | ||
field = 'authors' | ||||
| ) |
| def py::gui::editor::album::edit_authors | ( | self, | ||
| model_index, | ||||
field = 'authors' | ||||
| ) |
00403 : 00404 listwidget = getattr(self,field) 00405 item = listwidget.selectedItems()[0] 00406 entity = author_editor(self, item.entity).exec_() 00407 if entity : 00408 for field in ['authors','drawers'] : 00409 for i in getattr(self,"%s_items"%field) : 00410 if item.entity == entity : 00411 item.entity = entity 00412 item.setText(entity.name) 00413 getattr(self,field).sortItems() 00414 def add_drawers( self ) :
| def py::gui::editor::album::add_drawers | ( | self | ) |
| def py::gui::editor::album::delete_drawers | ( | self | ) |
| def py::gui::editor::album::edit_drawers | ( | self, | ||
| model_index | ||||
| ) |
| def py::gui::editor::album::select_context | ( | self, | ||
| context | ||||
| ) |
00423 : 00424 contexts = ['editor','collection','series'] 00425 context_id = contexts.index(context) 00426 00427 # prepare selector 00428 cur_entity = getattr(self,"%s_entity"%context) 00429 selector = globals()['%s_selector'%context] 00430 args = [] 00431 if context_id > 0 : 00432 args.append(getattr(self,"%s_entity"%contexts[context_id-1])) 00433 entity = selector(self, cur_entity, *args).exec_() 00434 00435 if entity is not False : 00436 # user has selected something 00437 # does qoid changed? 00438 has_change = entity != cur_entity 00439 00440 # update entity 00441 if entity is not None : 00442 getattr(self,context).setText(entity.name) 00443 else : 00444 getattr(self,context).clear() 00445 setattr(self,"%s_entity"%context,entity) 00446 00447 if has_change : 00448 # clear fields depending on me 00449 for i in range(context_id+1,len(contexts)) : 00450 d = contexts[i] 00451 setattr(self,"%s_entity"%d,None) 00452 getattr(self,d).clear() 00453 self.validate() 00454 def select_editor( self ) :
| def py::gui::editor::album::select_editor | ( | self | ) |
| def py::gui::editor::album::select_collection | ( | self | ) |
| def py::gui::editor::album::select_series | ( | self | ) |
| def py::gui::editor::album::fetch_form | ( | self, | ||
| form | ||||
| ) |
Reimplemented from py::gui::editor::entity_editor.
00462 : 00463 for p in ['name','isbn','ean'] : 00464 form[p] = unicode(getattr(self,p).text()).strip() 00465 for p in ['volume','guiding_price'] : 00466 form[p] = getattr(self,p).value() 00467 form["published_date"] = "%04d-%02d-%02d" % tuple([getattr(self,"published_date_%s"%c).value() for c in ["year","month","day"]]) 00468 form["series"] = self.series_entity 00469 for p in ['authors','drawers'] : 00470 authors = [item.entity for item in getattr(self, "%s_items"%p)] 00471 form["%s_raw"%p] = Album.build_authors_raw([entity.qoid for entity in authors]) 00472 form["%s_str"%p] = Album.build_authors_str(authors) 00473 def apply_value( self, album ) :
| def py::gui::editor::album::apply_value | ( | self, | ||
| album | ||||
| ) |
Reimplemented from py::gui::editor::entity_editor.
00474 : 00475 # if new, apply 'add to library' 00476 if self.add_to_library.isChecked() : 00477 library_id, ok = self.libraries.itemData(self.libraries.currentIndex()).toInt() 00478 albumcopy = Library.objects.get(id=library_id).albums.create(album=album) 00479 gui.models.manager.register_albumcopy(albumcopy) 00480 00481
py::gui::editor::album::model = Album [static] |
Reimplemented from py::gui::editor::entity_editor.
1.5.3