当前位置: 首页>>代码示例>>C++>>正文


C++ QSqlRecord::isGenerated方法代码示例

本文整理汇总了C++中QSqlRecord::isGenerated方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRecord::isGenerated方法的具体用法?C++ QSqlRecord::isGenerated怎么用?C++ QSqlRecord::isGenerated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSqlRecord的用法示例。


在下文中一共展示了QSqlRecord::isGenerated方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isGenerated

bool QSqlRecordProto::isGenerated(int index) const
{
  QSqlRecord *item = qscriptvalue_cast<QSqlRecord*>(thisObject());
  if (item)
    return item->isGenerated(index);
  return false;
}
开发者ID:ChristopherCotnoir,项目名称:qt-client,代码行数:7,代码来源:qsqlrecordproto.cpp

示例2: exec

bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,
                                 const QSqlRecord &rec, const QSqlRecord &whereValues)
{
    if (stmt.isEmpty())
        return false;

    // lazy initialization of editQuery
    if (editQuery.driver() != db.driver())
        editQuery = QSqlQuery(db);

    // workaround for In-Process databases - remove all read locks
    // from the table to make sure the editQuery succeeds
    if (db.driver()->hasFeature(QSqlDriver::SimpleLocking))
        const_cast<QSqlResult *>(query.result())->detachFromResultSet();

    if (prepStatement) {
        if (editQuery.lastQuery() != stmt) {
            if (!editQuery.prepare(stmt)) {
                error = editQuery.lastError();
                return false;
            }
        }
        int i;
        for (i = 0; i < rec.count(); ++i) {
            if (rec.isGenerated(i) && rec.value(i).type() != QVariant::Invalid)
                editQuery.addBindValue(rec.value(i));
        }
        for (i = 0; i < whereValues.count(); ++i) {
            if (whereValues.isGenerated(i))
                editQuery.addBindValue(whereValues.value(i));
        }

        if (!editQuery.exec()) {
            error = editQuery.lastError();
            return false;
        }
    } else {
        if (!editQuery.exec(stmt)) {
            error = editQuery.lastError();
            return false;
        }
    }
    return true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:44,代码来源:qsqltablemodel.cpp

示例3: translateFieldNames

/*! \internal
 */
void QSqlRelationalTableModelPrivate::translateFieldNames(QSqlRecord &values) const
{
    for (int i = 0; i < values.count(); ++i) {
        if (relations.value(i).isValid()) {
            QVariant v = values.value(i);
            bool gen = values.isGenerated(i);
            values.replace(i, baseRec.field(i));
            values.setValue(i, v);
            values.setGenerated(i, gen);
        }
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:14,代码来源:qsqlrelationaltablemodel.cpp

示例4: setRecord

/*!
    Applies \a values to the \a row in the model. The source and
    target fields are mapped by field name, not by position in
    the record.

    Note that the generated flags in \a values are preserved
    and determine whether the corresponding fields are used when
    changes are submitted to the database. The caller should
    remember to set the generated flag to FALSE for fields
    where the database is meant to supply the value, such as an
    automatically incremented ID.

    For edit strategies OnFieldChange and OnRowChange, a row may
    receive a change only if no other row has a cached change.
    Changes are submitted immediately. Submitted changes are not
    reverted upon failure.

    Returns \c true if all the values could be set; otherwise returns
    false.

    \sa record(), editStrategy()
*/
bool QSqlTableModel::setRecord(int row, const QSqlRecord &values)
{
    Q_D(QSqlTableModel);
    Q_ASSERT_X(row >= 0, "QSqlTableModel::setRecord()", "Cannot set a record to a row less than 0");
    if (d->busyInsertingRows)
        return false;

    if (row >= rowCount())
        return false;

    if (d->cache.value(row).op() == QSqlTableModelPrivate::Delete)
        return false;

    if (d->strategy != OnManualSubmit && d->cache.value(row).submitted() && isDirty())
        return false;

    // Check field names and remember mapping
    typedef QMap<int, int> Map;
    Map map;
    for (int i = 0; i < values.count(); ++i) {
        int idx = d->nameToIndex(values.fieldName(i));
        if (idx == -1)
            return false;
        map[i] = idx;
    }

    QSqlTableModelPrivate::ModifiedRow &mrow = d->cache[row];
    if (mrow.op() == QSqlTableModelPrivate::None)
        mrow = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update,
                                                  QSqlQueryModel::record(row));

    Map::const_iterator i = map.constBegin();
    const Map::const_iterator e = map.constEnd();
    for ( ; i != e; ++i) {
        // have to use virtual setData() here rather than mrow.setValue()
        EditStrategy strategy = d->strategy;
        d->strategy = OnManualSubmit;
        QModelIndex cIndex = createIndex(row, i.value());
        setData(cIndex, values.value(i.key()));
        d->strategy = strategy;
        // setData() sets generated to TRUE, but source record should prevail.
        if (!values.isGenerated(i.key()))
            mrow.recRef().setGenerated(i.value(), false);
    }

    if (d->strategy != OnManualSubmit)
        return submit();

    return true;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:72,代码来源:qsqltablemodel.cpp

示例5: translateFieldNames

/*! \internal
 */
void QSqlRelationalTableModelPrivate::translateFieldNames(int row, QSqlRecord &values) const
{
    Q_Q(const QSqlRelationalTableModel);

    for (int i = 0; i < values.count(); ++i) {
        int realCol = q->indexInQuery(q->createIndex(row, i)).column();
        if (realCol != -1 && relations.value(realCol).isValid()) {
            QVariant v = values.value(i);
            bool gen = values.isGenerated(i);
            values.replace(i, baseRec.field(realCol));
            values.setValue(i, v);
            values.setGenerated(i, gen);
        }
    }
}
开发者ID:phen89,项目名称:rtqt,代码行数:17,代码来源:qsqlrelationaltablemodel.cpp

示例6: record

/*!
\since 5.0
    Returns the record at \a row in the model.

    If \a row is the index of a valid row, the record
    will be populated with values from that row.

    If the model is not initialized, an empty record will be
    returned.

    \sa QSqlRecord::isEmpty()
*/
QSqlRecord QSqlTableModel::record(int row) const
{
    Q_D(const QSqlTableModel);

    // the query gets the values from virtual data()
    QSqlRecord rec = QSqlQueryModel::record(row);

    // get generated flags from the cache
    const QSqlTableModelPrivate::ModifiedRow mrow = d->cache.value(row);
    if (mrow.op() != QSqlTableModelPrivate::None) {
        const QSqlRecord crec = mrow.rec();
        for (int i = 0, cnt = rec.count(); i < cnt; ++i)
            rec.setGenerated(i, crec.isGenerated(i));
    }

    return rec;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:29,代码来源:qsqltablemodel.cpp

示例7: agregarServicio

/*!
    \fn MPeluqueria::agregarServicio( QVariant desc, QVariant precio, QVariant fecha, QVariant id_mascota )
 */
bool MPeluqueria::agregarServicio( QVariant desc, QVariant precio, QVariant fecha, QVariant id_mascota )
{
/* if( !mascota.isValid() )
 {
   qDebug( "Inidce Mascota es invalido" );
   return false;
 }
 QVariant id_mascota = relationModel( 1 )->data( mascota, 0 );
 if( id_mascota.isValid() && id_mascota.toInt() <= 0 )
 {return false;}*/
 QSqlRecord registro = record();
 registro.setValue( 1, id_mascota );
 registro.setValue( 2, desc );
 registro.setValue( 3, precio );
 registro.setValue( 4, fecha );
 for( int i = 0; i<registro.count(); i++ )
 {
   qDebug( QString( "Campo: %1, generado? %2, null? %3, valor? |%4|" ).arg( registro.fieldName( i ) ).arg( registro.isGenerated( i ) ).arg( registro.isNull( i ) ).arg( registro.value( i ).toString() ).toLocal8Bit() );
 }
 if( insertRecord( -1, registro ) )
 {
   qDebug( "Registro de servicio agregado correctamente" );
   return true;
 }
 else
 {
   qDebug( "Error al insertar registro de servicio de mascota" );
   qDebug( QString( "Detalles: tipo: %1, errno: %2, descripcion: %3" ).arg( lastError().type() ).arg( lastError().number() ).arg( lastError().text() ).toLocal8Bit() );
   return false;
 }
}
开发者ID:chungote,项目名称:gestotux,代码行数:34,代码来源:mpeluqueria.cpp


注:本文中的QSqlRecord::isGenerated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。