qt: make network models use BaseModel
This MR follows !4200 (merged)
Network models now use BaseModel to provide filtering, sorting, offset/limit, using the same code as the medialibrary.
This induce quite some changes in the implementation of the network models, reviews are welcomed.
The scheme is mostly the same for the 3 models
- Data is store locally in the models, unsorted
- When the view requires the data it creates a loader with the sort order and filter
- The loader will copy the references to the objects that match the the filter and sort it (on demand)
- diff-util is run on filtered+sorted models when data is updated, this will generate model events (like in the medialibrary)
Data is referenced using shared_pointer between the model and the loader, this makes the copy relatively cheap, I tried to do it using indexes but this was harder to keep it coherent when the source data changes.
notes
-
An unordered_set is used in the NetworkSourceModel to store the data, because model aggregation is quite expensive and searching for similar data was hitting performances.
-
Aggregation has been removed from NetworkMediaModel as it has half-implemented and unused
-
Some service provider (like the icecast directory) tend to notify items one by one and have lots of items. While the performances with the current implementation is better than the previous one, this can probably be probably be improved by queuing the insertions events and processing them with a (short) delay. This have been voluntary left aside for this MR
edit
revision 3:
- added a hotfix for changes past cache in the ListCache, this fixes issues where you ended up with invalid items if a model was made available in several batches (you ended up with one extra items every time you insert data past the cache).
revision 4:
- change default sort order in BaseModel
- add callback in BaseModel to request model initialization
- fix name sorting in NetworkMediaModel
- rebase on master