⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3databrowser.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}/*!    \property Q3DataBrowser::confirmEdits    \brief whether the browser confirms edits    If this property is true, the browser confirms all edit operations    (insertions, updates and deletions), otherwise all edit operations    happen immediately. Confirmation is achieved by presenting the    user with a message box -- this behavior can be changed by    reimplementing the confirmEdit() function,    \sa confirmEdit() confirmCancels() confirmInsert() confirmUpdate() confirmDelete()*/bool Q3DataBrowser::confirmEdits() const{    return (d->dat.confirmEdits());}bool Q3DataBrowser::confirmInsert() const{    return (d->dat.confirmInsert());}bool Q3DataBrowser::confirmUpdate() const{    return (d->dat.confirmUpdate());}bool Q3DataBrowser::confirmDelete() const{    return (d->dat.confirmDelete());}/*!    \property Q3DataBrowser::confirmCancels    \brief whether the browser confirms cancel operations    If this property is true, all cancels must be confirmed by the    user through a message box (this behavior can be changed by    overriding the confirmCancel() function), otherwise all cancels    occur immediately. The default is false.    \sa confirmEdits() confirmCancel()*/void Q3DataBrowser::setConfirmCancels(bool confirm){    d->dat.setConfirmCancels(confirm);}bool Q3DataBrowser::confirmCancels() const{    return d->dat.confirmCancels();}/*!    \property Q3DataBrowser::autoEdit    \brief whether the browser automatically applies edits    The default value for this property is true. When the user begins    an insertion or an update on a form there are two possible    outcomes when they navigate to another record:    \list    \i the insert or update is is performed -- this occurs if autoEdit is true    \i the insert or update is discarded -- this occurs if autoEdit is false    \endlist*/void Q3DataBrowser::setAutoEdit(bool autoEdit){    d->dat.setAutoEdit(autoEdit);}bool Q3DataBrowser::autoEdit() const{    return d->dat.autoEdit();}/*!    \fn void Q3DataBrowser::firstRecordAvailable(bool available)    This signal is emitted whenever the position of the cursor    changes. The \a available parameter indicates whether or not the    first record in the default cursor is available.*//*!    \fn void Q3DataBrowser::lastRecordAvailable(bool available)    This signal is emitted whenever the position of the cursor    changes. The \a available parameter indicates whether or not the    last record in the default cursor is available.*//*!    \fn void Q3DataBrowser::nextRecordAvailable(bool available)    This signal is emitted whenever the position of the cursor    changes. The \a available parameter indicates whether or not the    next record in the default cursor is available.*//*!    \fn void Q3DataBrowser::prevRecordAvailable(bool available)    This signal is emitted whenever the position of the cursor    changes. The \a available parameter indicates whether or not the    previous record in the default cursor is available.*//*!    \fn void Q3DataBrowser::currentChanged(const QSqlRecord* record)    This signal is emitted whenever the current cursor position    changes. The \a record parameter points to the contents of the    current cursor's record.*//*!    \fn void Q3DataBrowser::primeInsert(QSqlRecord* buf)    This signal is emitted when the data browser enters insertion    mode. The \a buf parameter points to the record buffer that is to    be inserted. Connect to this signal to, for example, prime the    record buffer with default data values, auto-numbered fields etc.    (Note that Q3SqlCursor::primeInsert() is \e not called on the    default cursor, as this would corrupt values in the form.)    \sa insert()*//*!    \fn void Q3DataBrowser::primeUpdate(QSqlRecord* buf)    This signal is emitted when the data browser enters update mode.    Note that during navigation (first(), last(), next(), prev()),    each record that is shown in the default form is primed for    update. The \a buf parameter points to the record buffer being    updated. (Note that Q3SqlCursor::primeUpdate() is \e not called on    the default cursor, as this would corrupt values in the form.)    Connect to this signal in order to, for example, keep track of    which records have been updated, perhaps for auditing purposes.    \sa update()*//*!    \fn void Q3DataBrowser::primeDelete(QSqlRecord* buf)    This signal is emitted when the data browser enters deletion mode.    The \a buf parameter points to the record buffer being deleted.    (Note that Q3SqlCursor::primeDelete() is \e not called on the    default cursor, as this would corrupt values in the form.)    Connect to this signal in order to, for example, save a copy of    the deleted record for auditing purposes.    \sa del()*//*!    \fn void Q3DataBrowser::cursorChanged(Q3SqlCursor::Mode mode)    This signal is emitted whenever the cursor record was changed due    to navigation. The \a mode parameter is the edit that just took    place, e.g. Insert, Update or Delete. See \l Q3SqlCursor::Mode.*//*!    Refreshes the data browser's data using the default cursor. The    browser's current filter and sort are applied if they have been    set.    \sa setFilter() setSort()*/void Q3DataBrowser::refresh(){    d->cur.refresh();}/*!    Performs an insert operation on the data browser's cursor. If    there is no default cursor or no default form, nothing happens.    If auto-editing is on (see setAutoEdit()), the following happens:    \list    \i If the browser is already actively inserting a record,    the current form's data is inserted into the database.    \i If the browser is not inserting a record, but the current record    was changed by the user, the record is updated in the database with    the current form's data (i.e. with the changes).    \endlist    If there is an error handling any of the above auto-edit actions,    handleError() is called and no insert or update is performed.    If no error occurred, or auto-editing is not enabled, the data browser    begins actively inserting a record into the database by performing the    following actions:    \list    \i The default cursor is primed for insert using Q3SqlCursor::primeInsert().    \i The primeInsert() signal is emitted.    \i The form is updated with the values in the default cursor's.    edit buffer so that the user can fill in the values to be inserted.    \endlist*/void Q3DataBrowser::insert(){    QSqlRecord* buf = d->frm.record();    Q3SqlCursor* cur = d->cur.cursor();    if (!buf || !cur)        return;    bool doIns = true;    QSql::Confirm conf = QSql::Yes;    switch (d->dat.mode()) {    case QSql::Insert:        if (autoEdit()) {            if (confirmInsert())                conf = confirmEdit(QSql::Insert);            switch (conf) {            case QSql::Yes:                insertCurrent();                break;            case QSql::No:                break;            case QSql::Cancel:                doIns = false;                break;            }        }        break;    default:        if (autoEdit() && currentEdited()) {            if (confirmUpdate())                conf = confirmEdit(QSql::Update);            switch (conf) {            case QSql::Yes:                updateCurrent();                break;            case QSql::No:                break;            case QSql::Cancel:                doIns = false;                break;            }        }        break;    }    if (doIns) {        d->dat.setMode(QSql::Insert);        sqlCursor()->primeInsert();        emit primeInsert(d->frm.record());        readFields();    }}/*!    Performs an update operation on the data browser's cursor.    If there is no default cursor or no default form, nothing happens.    Otherwise, the following happens:    If the data browser is actively inserting a record (see insert()),    that record is inserted into the database using insertCurrent().    Otherwise, the database is updated with the current form's data    using updateCurrent(). If there is an error handling either    action, handleError() is called.*/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;    }}/*!    Performs a delete operation on the data browser's cursor. If there    is no default cursor or no default form, nothing happens.    Otherwise, the following happens:    The current form's record is deleted from the database, providing    that the data browser is not in insert mode. If the data browser    is actively inserting a record (see insert()), the insert action    is canceled, and the browser navigates to the last valid record    that was current. If there is an error, handleError() is called.*/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;    }}/*!  Moves the default cursor to the record specified by index \a i  and refreshes the default form to display that record. If there is  no default form or no default cursor, nothing happens. If  \a relative is true (the default is false), the cursor is moved  relative to its current position. If the data browser successfully  navigated to the desired record, the default cursor is primed for  update and the primeUpdate() signal is emitted.    If the browser is already positioned on the desired record nothing  happens. Returns false if there is no cursor. Otherwise returns  true.*/bool Q3DataBrowser::seek(int i, bool relative){    int b = 0;    Q3SqlCursor* cur = d->cur.cursor();    if (!cur)        return false;    if (preNav())        b = cur->seek(i, relative);    postNav(b);    return b;}/*!    Moves the default cursor to the first record and refreshes the    default form to display this record. If there is no default form    or no default cursor, nothing happens. If the data browser    successfully navigated to the first record, the default cursor is    primed for update and the primeUpdate() signal is emitted.    If the browser is already positioned on the first record nothing    happens.*/void Q3DataBrowser::first(){    nav(&Q3SqlCursor::first);}/*!    Moves the default cursor to the last record and refreshes the    default form to display this record. If there is no default form    or no default cursor, nothing happens. If the data browser    successfully navigated to the last record, the default cursor is    primed for update and the primeUpdate() signal is emitted.    If the browser is already positioned on the last record nothing    happens.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -