void BigListModel::fetchMore(const QModelIndex &parent) { beginInsertRows(QModelIndex(), mCount, mCount + 100 -1); cacheRow(mCount, mCount+100); mCount += 100; endInsertRows(); }
bool BigListModel::load() { if(mFile.open(QIODevice::ReadOnly|QIODevice::Text)) { mStream.setDevice(&mFile); mCount = 100; mLines = mFile.size() / 9; mCache.setCapacity(200); cacheRow(0,100); } return true; }
/** * This sets the current row of interest. This row is then loaded as well * as windowSize rows above and below. Any non-overlapping rows with the * last row of interest are removed from memory. * * @param r The new row of interest. */ void ChunkRowCache::row(int32 r) { // Remove any cached chunks no longer needed: if (row_ != OUTOFSPACE) { for (int32 i = row_ - (int32)windowSize_; i <= row_ + (int32)windowSize_; ++i) { if (r == OUTOFSPACE || !(r - (int32)windowSize_ <= i && i <= r + (int32)windowSize_)) decacheRow(i); } } row_ = r; // Cache new chunks that are needed: if (row_ != OUTOFSPACE) { for (int32 i = row_ - (int32)windowSize_; i <= row_ + (int32)windowSize_; ++i) { cacheRow(i); } } }