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


C++ QSqlRecord函数代码示例

本文整理汇总了C++中QSqlRecord函数的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRecord函数的具体用法?C++ QSqlRecord怎么用?C++ QSqlRecord使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: removeRow

/*!
    Deletes the given \a row from the currently active database table.

    This is a low-level method that operates directly on the database
    and should not be called directly. Use removeRow() or removeRows()
    to delete values. The model will decide depending on its edit strategy
    when to modify the database.

    Returns true if the row was deleted; otherwise returns false.

    \sa removeRow(), removeRows()
*/
bool QSqlTableModel::deleteRowFromTable(int row)
{
    Q_D(QSqlTableModel);
    emit beforeDelete(row);

    const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row);
    bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);
    QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,
                                                d->tableName,
                                                QSqlRecord(),
                                                prepStatement);
    QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
                                                 d->tableName,
                                                 whereValues,
                                                 prepStatement);

    if (stmt.isEmpty() || where.isEmpty()) {
        d->error = QSqlError(QLatin1String("Unable to delete row"), QString(),
                             QSqlError::StatementError);
        return false;
    }
    stmt.append(QLatin1Char(' ')).append(where);

    return d->exec(stmt, prepStatement, QSqlRecord() /* no new values */, whereValues);
}
开发者ID:phen89,项目名称:rtqt,代码行数:37,代码来源:qsqltablemodel.cpp

示例2: QSqlRecord

QSqlRecord XSqlTableModelProto::record(int row) const
{
  XSqlTableModel *item = qscriptvalue_cast<XSqlTableModel*>(thisObject());
  if (item)
    return item->record(row);
  return QSqlRecord();
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:7,代码来源:xsqltablemodelproto.cpp

示例3: removeRow

/*!
    Deletes the given \a row from the currently active database table.

    This is a low-level method that operates directly on the database
    and should not be called directly. Use removeRow() or removeRows()
    to delete values. The model will decide depending on its edit strategy
    when to modify the database.

    Returns true if the row was deleted; otherwise returns false.

    \sa removeRow(), removeRows()
*/
bool QSqlTableModel::deleteRowFromTable(int row)
{
    Q_D(QSqlTableModel);
    emit beforeDelete(row);

    QSqlRecord rec = d->primaryValues(row);
    bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);
    QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,
                                                d->tableName,
                                                QSqlRecord(),
                                                prepStatement);
    QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
                                                 d->tableName,
                                                 rec,
                                                 prepStatement);

    if (stmt.isEmpty() || where.isEmpty()) {
        d->error = QSqlError(QLatin1String("Unable to delete row"), QString(),
                             QSqlError::StatementError);
        return false;
    }
    stmt.append(QLatin1Char(' ')).append(where);

    return d->exec(stmt, prepStatement, rec);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:37,代码来源:qsqltablemodel.cpp

示例4: QSqlRecord

QSqlRecord XSqlQueryProto::record() const
{
  XSqlQuery *item = qscriptvalue_cast<XSqlQuery*>(thisObject());
  if (item)
    return item->record();
  return QSqlRecord();
}
开发者ID:xtuple,项目名称:qt-client,代码行数:7,代码来源:xsqlqueryproto.cpp

示例5: agrpAdd

void FormLibraryEditor::agrpAdd()
{
	if (modelAgeGroups->insertRecord(-1, QSqlRecord())) {
		ui->tableViewAgeGroups->update();
		ui->actionAgeGroupCommit->setEnabled(true);
	}
}
开发者ID:pitikov,项目名称:cwall.qt4,代码行数:7,代码来源:formlibraryeditor.cpp

示例6: QSqlRecord

QSqlRecord SqliteDriver::record2(const QString &tblname) const
{
  if (!isOpen() || !dataBase_)
    return QSqlRecord();

  return recordInfo(tblname).toRecord();
}
开发者ID:gestiweb,项目名称:eneboo,代码行数:7,代码来源:qsqlite.cpp

示例7: QSqlRecord

QVariant EventColorQSqlQueryModel::data(const QModelIndex &index, int role) const
{
    QVariant value = QSqlQueryModel::data(index, role);

    if (role == Qt::BackgroundColorRole)
    {
        int level=	QSqlRecord (record(index.row())).value(4).toInt();
        switch(level)
        {
        case 1 : return qVariantFromValue(QColor(0xff,0xca,0x00));
        case 2 : return qVariantFromValue(QColor(Qt::red));
        case 3 : return qVariantFromValue(QColor(Qt::gray));
        case 4 : return qVariantFromValue(QColor(Qt::green));
        }
    }
    if(role==Qt::DisplayRole )
    {

        if (index.column() == 4)
        {
            switch(value.toInt())
            {
            case 0 : return qVariantFromValue(tr("Program"));
            case 1 : return qVariantFromValue(tr("Level I"));
            case 2 : return qVariantFromValue(tr("Level II"));
            case 3 : return qVariantFromValue(tr("Fault"));
            case 4 : return qVariantFromValue(tr("Correct"));
            }
        }

    }
    return value;
}
开发者ID:mishapk,项目名称:pcn,代码行数:33,代码来源:eventcolorqsqlquerymodel.cpp

示例8: query

QSqlRecord GenericDAO::getRecord(const QSqlDatabase& db, const QString& where, const QVariantList& bindValues) const
{
    if (db.isOpen())
    {
        QSqlQuery query(db);
        query.setForwardOnly(true);
        QString sql = QString("SELECT * FROM %1 WHERE %2").arg(m_table).arg(where);
        query.prepare(sql);
        int n = bindValues.size();
        for (int i = 0; i < n; i++)
        {
            query.bindValue(i, bindValues[i]);
        }

        if (query.exec())
        {
            if (query.next())
            {
                return query.record();
            }
        }
        else
            DatabaseException(query).displayMessage();
    }

    return QSqlRecord();
}
开发者ID:koboveb,项目名称:SVID.TERMINAL,代码行数:27,代码来源:genericdao.cpp

示例9: QSqlRecord

QSqlRecord QSQLiteDriver::record(const QString &tblname) const
{
    if (!isOpen())
        return QSqlRecord();

    return recordInfo(tblname).toRecord();
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:7,代码来源:qsql_sqlite.cpp

示例10: QSqlRecord

QSqlRecord FormFirewallRules::getFirewallRulesetFromShortName(QString shortName)
{
    QSqlRecord result = QSqlRecord();
    QSqlQuery qry;
    QVariant sn(shortName);

    qry.prepare(" select id, name, shortname, rules "
                " from ruleset "
                " where shortname = :shortname");
    qry.bindValue(":shortname", sn);

    if (qry.exec())
    {
        if (qry.first())
        {
            result = qry.record();
        }
        else
        {
            qDebug("FormFirewallRules::getFirewallRulesetFromShortName Can't move to first row [%s]",
                   qry.lastError().text().toAscii().data());
        }

    }
    else
    {
        qDebug("FormFirewallRules::getFirewallRulesetFromShortName query failed [%s]",
               qry.lastError().text().toAscii().data());
    }

    return result;
}
开发者ID:tailored,项目名称:qiptables,代码行数:32,代码来源:formfirewallrules.cpp

示例11: QSqlRecord

/* ********************************************************************* */
QSqlRecord BarlowsDataMapper::currentRecord()
{ 
	if (lastRowNumberSelected == -1) {
		return QSqlRecord();
	} else {
		return tableModel->record(lastRowNumberSelected);
	}
}
开发者ID:EvilTosha,项目名称:Stellarium-GSoC12,代码行数:9,代码来源:BarlowsDataMapper.cpp

示例12: QSqlRecord

QSqlRecord TargetsDialog::currentRecord()
{ 
	if (lastRowNumberSelected == -1) {
		return QSqlRecord();
	} else {
		return tableModel->record(lastRowNumberSelected);
	}
}
开发者ID:NGCyang,项目名称:stellarium,代码行数:8,代码来源:TargetsDialog.cpp

示例13: QSqlRecord

void FormLibraryEditor::teamAdd()
{
	int row = modelTeams->rowCount();
	modelTeams->insertRecord(-1, QSqlRecord());
	ui->tableViewTeams->setCurrentIndex(modelTeams->index(row, modelTeams->fieldIndex("label")));
	ui->actionTeamCommit->setEnabled(true);
	ui->actionDifficultyDelete->setDisabled(true);
}
开发者ID:pitikov,项目名称:cwall.qt4,代码行数:8,代码来源:formlibraryeditor.cpp

示例14: isForwardOnly

/*!
    Resets the model and sets the data provider to be the given \a
    query. Note that the query must be active and must not be
    isForwardOnly().

    lastError() can be used to retrieve verbose information if there
    was an error setting the query.

    \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
*/
void QSqlQueryModel::setQuery(const QSqlQuery &query)
{
    Q_D(QSqlQueryModel);
    QSqlRecord newRec = query.record();
    bool columnsChanged = (newRec != d->rec);
    bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize);
    bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid();

    if (d->colOffsets.size() != newRec.count() || columnsChanged)
        d->initColOffsets(newRec.count());

    bool mustClearModel = d->bottom.isValid();
    if (mustClearModel) {
        d->atEnd = true;
        beginRemoveRows(QModelIndex(), 0, qMax(d->bottom.row(), 0));
        d->bottom = QModelIndex();
    }

    d->error = QSqlError();
    d->query = query;
    d->rec = newRec;

    if (mustClearModel)
        endRemoveRows();

    d->atEnd = false;

    if (columnsChanged && hasNewData)
        reset();

    if (!query.isActive() || query.isForwardOnly()) {
        d->atEnd = true;
        d->bottom = QModelIndex();
        if (query.isForwardOnly())
            d->error = QSqlError(QLatin1String("Forward-only queries "
                                               "cannot be used in a data model"),
                                 QString(), QSqlError::ConnectionError);
        else
            d->error = query.lastError();
        return;
    }
    QModelIndex newBottom;
    if (hasQuerySize && d->query.size() > 0) {
        newBottom = createIndex(d->query.size() - 1, d->rec.count() - 1);
        beginInsertRows(QModelIndex(), 0, qMax(0, newBottom.row()));
        d->bottom = createIndex(d->query.size() - 1, columnsChanged ? 0 : d->rec.count() - 1);
        d->atEnd = true;
        endInsertRows();
    } else {
        newBottom = createIndex(-1, d->rec.count() - 1);
    }
    d->bottom = newBottom;

    queryChange();

    // fetchMore does the rowsInserted stuff for incremental models
    fetchMore();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:68,代码来源:qsqlquerymodel.cpp

示例15: entryFromIndex

QSqlRecord LibraryModel::record(const QModelIndex &index)
{
    LibraryEntry * item = entryFromIndex(index);
    if(item->isDirNode()) {
        return QSqlRecord();
    } else {
        return item->record();
    }
}
开发者ID:alorence,项目名称:tym,代码行数:9,代码来源:librarymodel.cpp


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