This is a valid approach and would almost certainly provide for your needs.
However, I would choose a different approach if I were to implement that.
First, I would store the media objects in separate lists, one for each C++ type:
- no casting is required when accessing media type specific
- no filtering needed to just see one type
- still easy to list all media by just going through all lists in any order I want
These lists would be in an object that any add/remove/change operation would go through:
- the object can emit signals when data is added/removed/changed
- it can implement overall saving/loading if that is required
- it makes data handling testable without any model API
Each model would have access to this object
- the overall model's rowCount would just be the sum of all list counts
- the detail model(s) would work on a single list
- if any model affects change, it would go through the list holder object
- the signals of the list holder object would allow each model instance to notify its view(s) of change
Cheers,
_
Bookmarks