| 1226 | } |
| 1227 | |
| 1228 | void ComicModel::notifyCoverChange(const ComicDB &comic) |
| 1229 | { |
| 1230 | auto it = std::find_if(_data.begin(), _data.end(), [comic](ComicItem *item) { return item->data(ComicModel::Id).toULongLong() == comic.id; }); |
| 1231 | auto itemIndex = std::distance(_data.begin(), it); |
| 1232 | auto item = _data[itemIndex]; |
| 1233 | |
| 1234 | // emiting a dataChage doesn't work in QML for some reason, CoverPathRole is requested but the view doesn't update the image |
| 1235 | // removing and reading again works with the flow views without any additional code, but it's not the best solution |
| 1236 | beginRemoveRows(QModelIndex(), itemIndex, itemIndex); |
| 1237 | _data.removeAt(itemIndex); |
| 1238 | endRemoveRows(); |
| 1239 | |
| 1240 | beginInsertRows(QModelIndex(), itemIndex, itemIndex); |
| 1241 | _data.insert(itemIndex, item); |
| 1242 | endInsertRows(); |
| 1243 | |
| 1244 | // this doesn't work in QML -> emit dataChanged(index(itemIndex, 0), index(itemIndex, 0), QVector<int>() << CoverPathRole); |
| 1245 | } |
| 1246 | |
| 1247 | QUrl ComicModel::getCoverUrlPathForComicHash(const QString &hash) const |
| 1248 | { |
no test coverage detected