本文整理汇总了C++中Q3SqlCursor::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3SqlCursor::next方法的具体用法?C++ Q3SqlCursor::next怎么用?C++ Q3SqlCursor::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3SqlCursor
的用法示例。
在下文中一共展示了Q3SqlCursor::next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Q3DataBrowser::Boundary Q3DataBrowser::boundary()
{
Q3SqlCursor* cur = d->cur.cursor();
if (!cur || !cur->isActive())
return Unknown;
if (!cur->isValid()) {
if (cur->at() == QSql::BeforeFirst)
return BeforeBeginning;
if (cur->at() == QSql::AfterLast)
return AfterEnd;
return Unknown;
}
if (cur->at() == 0)
return Beginning;
int currentAt = cur->at();
Boundary b = None;
if (!cur->previous())
b = Beginning;
else
cur->seek(currentAt);
if (b == None && !cur->next())
b = End;
cur->seek(currentAt);
return b;
}
示例2: qDebug
//## possibly add sizeHint parameter
bool Q3SqlCursorManager::findBuffer(const QSqlIndex& idx, int atHint)
{
#ifdef QT_DEBUG_DATAMANAGER
qDebug("Q3SqlCursorManager::findBuffer:");
#endif
Q3SqlCursor* cur = cursor();
if (!cur)
return false;
if (!cur->isActive())
return false;
if (!idx.count()) {
if (cur->at() == QSql::BeforeFirst)
cur->next();
return false;
}
QSqlRecord* buf = cur->editBuffer();
bool indexEquals = false;
#ifdef QT_DEBUG_DATAMANAGER
qDebug(" Checking hint...");
#endif
/* check the hint */
if (cur->seek(atHint))
indexEquals = index_matches(cur, buf, idx);
if (!indexEquals) {
#ifdef QT_DEBUG_DATAMANAGER
qDebug(" Checking current page...");
#endif
/* check current page */
int pageSize = 20;
int startIdx = qMax(atHint - pageSize, 0);
int endIdx = atHint + pageSize;
for (int j = startIdx; j <= endIdx; ++j) {
if (cur->seek(j)) {
indexEquals = index_matches(cur, buf, idx);
if (indexEquals)
break;
}
}
}
if (!indexEquals && cur->driver()->hasFeature(QSqlDriver::QuerySize)
&& cur->sort().count()) {
#ifdef QT_DEBUG_DATAMANAGER
qDebug(" Using binary search...");
#endif
// binary search based on record buffer and current sort fields
int lo = 0;
int hi = cur->size();
int mid;
if (compare_recs(buf, cur, cur->sort()) >= 0)
lo = cur->at();
while (lo != hi) {
mid = lo + (hi - lo) / 2;
if (!cur->seek(mid))
break;
if (index_matches(cur, buf, idx)) {
indexEquals = true;
break;
}
int c = compare_recs(buf, cur, cur->sort());
if (c < 0) {
hi = mid;
} else if (c == 0) {
// found it, but there may be duplicates
int at = mid;
do {
mid--;
if (!cur->seek(mid))
break;
if (index_matches(cur, buf, idx)) {
indexEquals = true;
break;
}
} while (compare_recs(buf, cur, cur->sort()) == 0);
if (!indexEquals) {
mid = at;
do {
mid++;
if (!cur->seek(mid))
break;
if (index_matches(cur, buf, idx)) {
indexEquals = true;
break;
}
} while (compare_recs(buf, cur, cur->sort()) == 0);
}
break;
} else if (c > 0) {
lo = mid + 1;
}
}
}
if (!indexEquals) {
#ifdef QT_DEBUG_DATAMANAGER
qDebug(" Using brute search...");
#endif
//.........这里部分代码省略.........