本文整理汇总了C++中Q3SqlCursor::editBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3SqlCursor::editBuffer方法的具体用法?C++ Q3SqlCursor::editBuffer怎么用?C++ Q3SqlCursor::editBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3SqlCursor
的用法示例。
在下文中一共展示了Q3SqlCursor::editBuffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: beforeUpdate
bool Q3DataBrowser::updateCurrent()
{
if (isReadOnly())
return false;
QSqlRecord* buf = d->frm.record();
Q3SqlCursor* cur = d->cur.cursor();
if (!buf || !cur)
return false;
writeFields();
emit beforeUpdate(buf);
int ar = cur->update();
if (!ar || !cur->isActive()) {
handleError(cur->lastError());
refresh();
updateBoundary();
} else {
refresh();
d->cur.findBuffer(cur->primaryIndex());
updateBoundary();
cur->editBuffer(true);
cursorChanged(Q3SqlCursor::Update);
readFields();
return true;
}
return false;
}
示例2: primeDelete
void Q3DataBrowser::del()
{
QSqlRecord* buf = d->frm.record();
Q3SqlCursor* cur = d->cur.cursor();
if (!buf || !cur)
return;
QSql::Confirm conf = QSql::Yes;
switch (d->dat.mode()){
case QSql::Insert:
if (confirmCancels())
conf = confirmCancel(QSql::Insert);
if (conf == QSql::Yes) {
cur->editBuffer(true); /* restore from cursor */
readFields();
d->dat.setMode(QSql::Update);
} else
d->dat.setMode(QSql::Insert);
break;
default:
if (confirmDelete())
conf = confirmEdit(QSql::Delete);
switch (conf) {
case QSql::Yes:
emit primeDelete(buf);
deleteCurrent();
break;
case QSql::No:
case QSql::Cancel:
break;
}
d->dat.setMode(QSql::Update);
break;
}
}
示例3: beforeDelete
bool Q3DataBrowser::deleteCurrent()
{
if (isReadOnly())
return false;
QSqlRecord* buf = d->frm.record();
Q3SqlCursor* cur = d->cur.cursor();
if (!buf || !cur)
return false;
writeFields();
int n = cur->at();
emit beforeDelete(buf);
int ar = cur->del();
if (ar) {
refresh();
updateBoundary();
cursorChanged(Q3SqlCursor::Delete);
if (!cur->seek(n))
last();
if (cur->isValid()) {
cur->editBuffer(true);
readFields();
} else {
clearValues();
}
return true;
} else {
if (!cur->isActive()) {
handleError(cur->lastError());
refresh();
updateBoundary();
}
}
return false;
}
示例4: switch
void Q3DataBrowser::update()
{
QSqlRecord* buf = d->frm.record();
Q3SqlCursor* cur = d->cur.cursor();
if (!buf || !cur)
return;
QSql::Confirm conf = QSql::Yes;
switch (d->dat.mode()){
case QSql::Insert:
if (confirmInsert())
conf = confirmEdit(QSql::Insert);
switch (conf) {
case QSql::Yes:
if (insertCurrent())
d->dat.setMode(QSql::Update);
break;
case QSql::No:
d->dat.setMode(QSql::Update);
cur->editBuffer(true);
readFields();
break;
case QSql::Cancel:
break;
}
break;
default:
d->dat.setMode(QSql::Update);
if (confirmUpdate())
conf = confirmEdit(QSql::Update);
switch (conf) {
case QSql::Yes:
updateCurrent();
break;
case QSql::No:
case QSql::Cancel:
break;
}
break;
}
}
示例5: 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
//.........这里部分代码省略.........