void QSparqlQueryModelPrivate::beginQuery(int totalResults) { // This function will only be called when result is a valid // pointer. result->first(); QSparqlResultRow newResultRow = result->current(); bool columnsChanged = (newResultRow != resultRow); // bool hasQuerySize = connection->hasFeature(QSparqlConnection::QuerySize); bool hasNewData = (newResultRow != QSparqlResultRow()) || !result->hasError(); if (colOffsets.size() != newResultRow.count() || columnsChanged) initColOffsets(newResultRow.count()); resultRow = newResultRow; atEnd = false; if (columnsChanged && hasNewData) q->reset(); QModelIndex newBottom; newBottom = q->createIndex(totalResults - 1, resultRow.count() - 1); q->beginInsertRows(QModelIndex(), 0, qMax(0, newBottom.row())); bottom = q->createIndex(totalResults - 1, columnsChanged ? 0 : resultRow.count() - 1); q->endInsertRows(); bottom = newBottom; q->queryChange(); }
void QSqlTableModelPrivate::initRecordAndPrimaryIndex() { rec = db.record(tableName); primaryIndex = db.primaryIndex(tableName); initColOffsets(rec.count()); }