| 218 | } |
| 219 | |
| 220 | void ListModel::searchRequestFinished(QJsonDocument& doc) |
| 221 | { |
| 222 | jobPtr.reset(); |
| 223 | |
| 224 | QList<ModPlatform::IndexedPack> newList; |
| 225 | auto packs = documentToArray(doc); |
| 226 | |
| 227 | for (auto packRaw : packs) { |
| 228 | auto packObj = packRaw.toObject(); |
| 229 | |
| 230 | ModPlatform::IndexedPack pack; |
| 231 | try { |
| 232 | loadIndexedPack(pack, packObj); |
| 233 | newList.append(pack); |
| 234 | } catch (const JSONValidationError& e) { |
| 235 | qWarning() << "Error while loading mod from " << m_parent->debugName() << ": " << e.cause(); |
| 236 | continue; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | if (packs.size() < 25) { |
| 241 | searchState = Finished; |
| 242 | } else { |
| 243 | nextSearchOffset += 25; |
| 244 | searchState = CanPossiblyFetchMore; |
| 245 | } |
| 246 | |
| 247 | // When you have a Qt build with assertions turned on, proceeding here will abort the application |
| 248 | if (newList.size() == 0) |
| 249 | return; |
| 250 | |
| 251 | beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); |
| 252 | modpacks.append(newList); |
| 253 | endInsertRows(); |
| 254 | } |
| 255 | |
| 256 | void ListModel::searchRequestFailed(QString reason) |
| 257 | { |
no test coverage detected