Exemplo n.º 1
0
void WeatherDataSource::onSqlConnectorReply(const bb::data::DataAccessReply& reply)
{
    if (reply.hasError()) {
        qWarning() << "WeatherModel: Database error, " << reply.errorType() << " "
                << reply.errorMessage() << " id: " << reply.id();
    } else {
        if (reply.id() == 0) {
            emit weatherChanged(mRevision);
        }
    }
}
Exemplo n.º 2
0
void AnimDataSource::onSqlConnectorReply(
		const bb::data::DataAccessReply& reply) {
	if (reply.hasError()) {
		qWarning() << "Database error, " << reply.errorType() << " "
				<< reply.errorMessage() << " id: " << reply.id();
	} else {
		if (reply.id() == 0) {
		    // We fake a network request here by adding a small delay before emitting
		    // the signal that will trigger the update in the list.
			QTimer::singleShot(800, this, SLOT(fakeNetworkDelay()));
		}
	}
}
Exemplo n.º 3
0
void CityModel::onLoadAsyncResultData(const bb::data::DataAccessReply& reply)
{
    if (reply.hasError()) {
        qWarning() << "onLoadAsyncResultData: " << reply.id() << ", SQL error: " << reply;
    } else {
        if (reply.id() >= INITIAL_LOAD_ID) {
            QVariantList resultList = reply.result().value<QVariantList>();

            if (resultList.size() > 0) {
                // Insert the data into the model.
                this->insertList(resultList);

                if (reply.id() >= ASYNCH_LOAD_ID) {
                    // If the id belongs to an asynchronous request we keep asking until there are no more results.
                    QString query;

                    // We increase the offset by using the reply id:s
                    QTextStream(&query) << "select * from cities limit " << ASYNCH_BATCH_SIZE <<
                    " offset " << +(ASYNCH_BATCH_SIZE * (reply.id() - ASYNCH_LOAD_ID + 2));
                    mSqlConnector->execute(query, (reply.id() + 1));
                }
            }
        }
    }
}