MCPcopy Create free account
hub / github.com/YACReader/yacreader / notifyCoverChange

Method notifyCoverChange

YACReaderLibrary/db/comic_model.cpp:1228–1245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226}
1227
1228void 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
1247QUrl ComicModel::getCoverUrlPathForComicHash(const QString &hash) const
1248{

Callers 1

createConnectionsMethod · 0.80

Calls 3

QModelIndexClass · 0.50
dataMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected