while (mRequestRows > 0) { qCDebug(candleModelDebug) << "Send rest request"; RestEventLoop eventLoop; connect(&mRest,&Rest::stateChanged,&eventLoop,&RestEventLoop::finish); mRest.sendRequest(); eventLoop.exec(); qCDebug(candleModelDebug) << "Data loaded"; QList<BaCandleData> buffer = mRest.candleData();
void GraphicsView::checkNeedData(){ int fetchCount = requestVisibleData(); int needRowCount = fetchCount + model->rowCount(); if (needRowCount > model->[b]requestRowCount[/b]()) { qCDebug(graphicsViewDebug) << "Data size: " << scene()->model()->rowCount(); int fetchedCount = fetchData(fetchCount); qCDebug(graphicsViewDebug) << "Send request fetched data" << fetchedCount; }void CaModel::fetchMore(const QModelIndex &){ ..... if (mRequestRows == 0) { mRequestRows = mRest.limit(); mRest.sendRequest(); } else { //if data in progress mRequestRows += mRest.limit(); }}void CaModel::finishFetch(Ba::ReplyNetworkState state){ qCDebug(candleModelDebug) << "Data loaded"; QList<BaCandleData> buffer = mRest.candleData(); mRequestRows -= buffer.size(); if (buffer.size() == 0) return; beginInsertRows(QModelIndex(),rowCount(),rowCount() + buffer.size() - 1); mData.append(std::move(buffer)); endInsertRows(); if (mRequestRows > 0) mRest.sendRequest();}