Re: [gtkmvc-users] Communicating between sub-models/sub-controllers
Brought to you by:
cavada
From: Tobias W. <to...@ce...> - 2010-07-16 07:26:23
|
On 16.07.2010, at 06:53, Steve McGrath wrote: > This may be a dumb question, but I can't quite find a clear answer. I'm no export on object oriented modelling, either. > Under appController I have a collectionController, and a playlistController, which each have their own respective view and model. I suppose only songs from the collection can be on the playlist, and that the playlist is persistant. Some day there may be multiple playlists. Almost as if playlists were part of the collection! > I will also encounter a problem with my actual playback code, which I intend to create as another sub-model of appModel. But appModel doesn't know what to play. Maybe it should belong to collectionModel. Or even playlistModel, if you cannot play directly from the collection. That wouldn't leave much for appModel to do. So maybe collectionModel *is* your appModel. The program is about music, after all. > Will signals emitted from a sub-model make it to the parent model's controller without help? No. Diagonal dependencies are bad. Horizontal is built in. Vertical is up to you: class appModel: def init: self.collection = collectionModel(self) class collectionModel: def init(parent): self.register_observer(parent) class appController: def init: self.collection = collectionController(self.model.collection, ..., self) class collectionController: def init(m, v, parent): # Keep for direct calls. self.parent = parent |