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


C++ QSqlIndex类代码示例

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


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

示例1: sipReleaseType

static PyObject *meth_QSqlIndex_setCursorName(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        QSqlIndex *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QSqlIndex, &sipCpp, sipType_QString,&a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setCursorName(*a0);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QSqlIndex, sipName_setCursorName, doc_QSqlIndex_setCursorName);

    return NULL;
}
开发者ID:PLJV,项目名称:commodity_crop_dev_suitability_model,代码行数:26,代码来源:sipQtSqlQSqlIndex.cpp

示例2: qGetTableInfo

static QSqlIndex qGetTableInfo(QSqlQuery &q, const QString &tableName, bool onlyPIndex = false)
{
    QString schema;
    QString table(tableName);
    int indexOfSeparator = tableName.indexOf(QLatin1Char('.'));
    if (indexOfSeparator > -1) {
        schema = tableName.left(indexOfSeparator).append(QLatin1Char('.'));
        table = tableName.mid(indexOfSeparator + 1);
    }
    q.exec(QLatin1String("PRAGMA ") + schema + QLatin1String("table_info (") + _q_escapeIdentifier(table) + QLatin1String(")"));

    QSqlIndex ind;
    while (q.next()) {
        bool isPk = q.value(5).toInt();
        if (onlyPIndex && !isPk)
            continue;
        QString typeName = q.value(2).toString().toLower();
        QSqlField fld(q.value(1).toString(), qGetColumnType(typeName));
        if (isPk && (typeName == QLatin1String("integer")))
            // INTEGER PRIMARY KEY fields are auto-generated in sqlite
            // INT PRIMARY KEY is not the same as INTEGER PRIMARY KEY!
            fld.setAutoValue(true);
        fld.setRequired(q.value(3).toInt() != 0);
        fld.setDefaultValue(q.value(4));
        ind.append(fld);
    }
    return ind;
}
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:28,代码来源:qsql_spatialite.cpp

示例3: qGetTableInfo

static QSqlIndex qGetTableInfo(QSqlQuery &q, QString &tableName, bool onlyPIndex = false)
{   
    QString dbName;
    QString table(tableName);
    int indexOfSeparator = tableName.indexOf(QLatin1Char('.'));
    if (indexOfSeparator > -1) {
        dbName = tableName.left(indexOfSeparator +1 );
        table = tableName.mid(indexOfSeparator + 1);
    }
    q.exec(QLatin1String("PRAGMA ") + dbName + QLatin1String("table_info (") + _q_escapeIdentifier(table) + QLatin1String(")"));

    const int NAME_IDX = 1;
    const int TYPE_IDX = 2;
    const int NOTNULL_IDX = 3;
    const int DFLT_VALUE_IDX = 4;
    const int PK_IDX = 5;    
    
    QSqlIndex ind;
    while (q.next()) {
        bool isPk = q.value(PK_IDX).toInt();
        if (onlyPIndex && !isPk)
            continue;
        QString typeName = q.value(TYPE_IDX).toString().toLower();
        QSqlField fld(q.value(NAME_IDX).toString(), qGetColumnType(typeName));
        if (isPk && (typeName == QLatin1String("integer")))
            // INTEGER PRIMARY KEY fields are auto-generated in sqlite
            // INT PRIMARY KEY is not the same as INTEGER PRIMARY KEY!
            fld.setAutoValue(true);
        fld.setRequired(q.value(NOTNULL_IDX).toInt() != 0);
        fld.setDefaultValue(q.value(DFLT_VALUE_IDX));
        ind.append(fld);
    }
    return ind;
}
开发者ID:maxxant,项目名称:qt,代码行数:34,代码来源:qsql_symsql.cpp

示例4: compare_recs

static int compare_recs(const QSqlRecord* buf1, const QSqlRecord* buf2,
                         const QSqlIndex& idx)
{
    int cmp = 0;

    int i = 0;
    const QString fn(idx.field(i).name());
    const QSqlField f1 = buf1->field(fn);

    if (f1.isValid()) {
        switch (f1.type()) { // ### more types?
        case QVariant::String:
            cmp = f1.value().toString().trimmed().compare(
                          buf2->value(fn).toString().trimmed());
            break;
        default:
            if (f1.value().toDouble() < buf2->value(fn).toDouble())
                cmp = -1;
            else if (f1.value().toDouble() > buf2->value(fn).toDouble())
                cmp = 1;
        }
    }

    if (idx.isDescending(i))
        cmp = -cmp;
    return cmp;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:27,代码来源:q3sqlmanager_p.cpp

示例5: primaryIndex

int Q3SqlCursor::del(bool invalidate)
{
    QSqlIndex idx = primaryIndex(false);
    if (idx.isEmpty())
        return del(qWhereClause(&d->editBuffer, d->nm, QLatin1String("and"), driver()), invalidate);
    return del(toString(primaryIndex(), &d->editBuffer, d->nm, QString(QLatin1Char('=')), QLatin1String("and")), invalidate);
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: qOrderByClause

QString qOrderByClause( const QSqlIndex & i, const QString& prefix = QString::null )
{
    QString str;
    int k = i.count();
    if( k == 0 ) return QString::null;
    str = " order by " + i.toString( prefix );
    return str;
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:8,代码来源:qsqlcursor.cpp

示例7: primaryIndex

int QSqlCursor::del( bool invalidate )
{
    QSqlIndex idx = primaryIndex( FALSE );
    if ( idx.isEmpty() )
        return del( qWhereClause( &d->editBuffer, d->nm, "and", driver() ), invalidate );
    else
	return del( toString( primaryIndex(), &d->editBuffer, d->nm,
			  "=", "and" ), invalidate );
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:9,代码来源:qsqlcursor.cpp

示例8: qOrderByClause

QString qOrderByClause(const QSqlIndex & i, const QString& prefix = QString())
{
    QString str;
    int k = i.count();
    if(k == 0)
        return QString();
    str = QLatin1String(" order by ") + i.toString(prefix);
    return str;
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: getPrimary

QString getPrimary(QSqlDatabase &db, QString sTable)
{
  QString sPrimary = "kbrecordid";

  QSqlIndex i = db.driver()->primaryIndex(sTable);
  if (i.count()){
    sPrimary = i.fieldName(0);
  }
  return sPrimary;
}
开发者ID:DamianSuess,项目名称:kbasic,代码行数:10,代码来源:interpreter.cpp

示例10: editBuffer

QSqlRecord* QSqlCursor::primeUpdate()
{
    // memorize the primary keys as they were before the user changed the values in editBuffer
    QSqlRecord* buf = editBuffer( TRUE );
    QSqlIndex idx = primaryIndex( FALSE );
    if ( !idx.isEmpty() )
	d->editIndex = toString( idx, buf, d->nm, "=", "and" );
    else
	d->editIndex = qWhereClause( buf, d->nm, "and", driver() );
    return buf;
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:11,代码来源:qsqlcursor.cpp

示例11: editBuffer

QSqlRecord* Q3SqlCursor::primeUpdate()
{
    // memorize the primary keys as they were before the user changed the values in editBuffer
    QSqlRecord* buf = editBuffer(true);
    QSqlIndex idx = primaryIndex(false);
    if (!idx.isEmpty())
        d->editIndex = toString(idx, buf, d->nm, QString(QLatin1Char('=')), QLatin1String("and"));
    else
        d->editIndex = qWhereClause(buf, d->nm, QLatin1String("and"), driver());
    return buf;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例12: primaryKeyIndex

int TableSchema::primaryKeyIndex() const
{
    QSqlTableModel model;
    model.setTable(tablename);
    QSqlIndex index = model.primaryKey();
    if (index.isEmpty()) {
        return -1;
    }

    QSqlField fi = index.field(0);
    return model.record().indexOf(fi.name());
}
开发者ID:AbhimanyuAryan,项目名称:treefrog-framework,代码行数:12,代码来源:tableschema.cpp

示例13: primaryKeyFieldName

QString TableSchema::primaryKeyFieldName() const
{
    QSqlTableModel model;
    model.setTable(tablename);
    QSqlIndex index = model.primaryKey();
    if (index.isEmpty()) {
        return QString();
    }

    QSqlField fi = index.field(0);
    return fi.name();
}
开发者ID:AbhimanyuAryan,项目名称:treefrog-framework,代码行数:12,代码来源:tableschema.cpp

示例14: field

QSqlIndex Q3SqlCursor::index(const QStringList& fieldNames) const
{
    QSqlIndex idx;
    for (QStringList::ConstIterator it = fieldNames.begin(); it != fieldNames.end(); ++it) {
        QSqlField f = field((*it));
        if (!f.isValid()) { /* all fields must exist */
            idx.clear();
            break;
        }
        idx.append(f);
    }
    return idx;
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例15: index_matches

static bool index_matches(const Q3SqlCursor* cur, const QSqlRecord* buf,
                           const QSqlIndex& idx)
{
    bool indexEquals = false;
    for (int i = 0; i < idx.count(); ++i) {
        const QString fn(idx.field(i).name());
        if (cur->value(fn) == buf->value(fn))
            indexEquals = true;
        else {
            indexEquals = false;
            break;
        }
    }
    return indexEquals;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:q3sqlmanager_p.cpp


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