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


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

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


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

示例1: AddRow

void DatabaseManager::AddRow()
{
	int rowNum = mptableModel->rowCount();//获得表的行数
	QSqlRecord record = mptableModel->record();
	QSqlField fieldStr("ReplaceString", QVariant::Char);
	QSqlField fieldRes("ReplaceRes", QVariant::Char);
	QSqlField fieldPak("ReplacePak", QVariant::Char);
	QSqlField fieldAppPak("ReplaceAppPak", QVariant::Char);
	fieldStr.setValue(QStringLiteral("双击编辑"));
	fieldRes.setValue(QStringLiteral("双击编辑"));
	fieldPak.setValue(QStringLiteral("双击编辑"));
	fieldAppPak.setValue(QStringLiteral("双击编辑"));
	record.append(fieldStr);
	record.append(fieldRes);
	record.append(fieldPak);
	record.append(fieldAppPak);

	if (!mptableModel->insertRecord(rowNum, record)){
		BjMessageBox::warning(NULL, QStringLiteral("数据库错误"), QStringLiteral("数据库错误: %1").arg(mptableModel->lastError().text()), QMessageBox::Ok, QMessageBox::NoButton);
		mptableModel->revertAll();//如果不删除,则撤销
		return;
	}

	if (!mptableModel->submitAll()){
		BjMessageBox::warning(NULL, QStringLiteral("数据库错误"), QStringLiteral("数据库错误: %1").arg(mptableModel->lastError().text()));
		mptableModel->revertAll();//如果不删除,则撤销
	}
}
开发者ID:langelee,项目名称:AutopackingAndroid,代码行数:28,代码来源:DatabaseManager.cpp

示例2: AddDasignar

void Gconsignaciones::AddDasignar(){
    mensajebox *add = new mensajebox("Guardar", "Esta seguro de guardar los datos?", this);
    int accepted = add->exec();
    if (accepted == 1) {

        QSqlRecord record;

        QSqlField f1("Id_asig", QVariant::Int);
        QSqlField f2("Id_pro", QVariant::Int);
        QSqlField f3("Cantidad", QVariant::Int);
        QSqlField f4("Costo", QVariant::Double);
        total =total+(ui->costo2spinbox->value()*ui->cantidad2->value());
        f1.setValue(QVariant(idunicoasignar));
        f2.setValue(QVariant(ui->id2spinbox->text().toInt(0, 10)));
        f3.setValue(QVariant(ui->cantidad2->value()));
        f4.setValue(QVariant(ui->costo2spinbox->value()*ui->cantidad2->value()));

        record.append(f1);
        record.append(f2);
        record.append(f3);
        record.append(f4);

        ui->total2->setValue(total);;
        modelodasignar->insertRecord(-1, record);
        ui->informacionproductoadicionado->show();

    }
}
开发者ID:jorgenio,项目名称:pandasoft,代码行数:28,代码来源:gconsignaciones.cpp

示例3: addAccount

bool DailymotionAccountModel::addAccount(const QString &userId, const QString &username, const QString &accessToken,
                                         const QString &refreshToken, const QString &scopes) {
                                     
    QSqlField userIdField("userId", QVariant::String);
    userIdField.setValue(userId);
    
    QSqlField usernameField("username", QVariant::String);
    usernameField.setValue(username);
        
    QSqlField accessTokenField("accessToken", QVariant::String);
    accessTokenField.setValue(accessToken);
    
    QSqlField refreshTokenField("refreshToken", QVariant::String);
    refreshTokenField.setValue(refreshToken);
    
    QSqlField scopesField("scopes", QVariant::String);
    scopesField.setValue(scopes);

    QSqlRecord record;
    record.append(userIdField);
    record.append(usernameField);
    record.append(accessTokenField);
    record.append(refreshTokenField);
    record.append(scopesField);
    
    if (insertRecord(-1, record)) {
        Dailymotion::instance()->setUserId(userId);
        const int count = rowCount();
        emit dataChanged(index(0, 0), index(count - 1, columnCount() - 1));
        emit countChanged(count);
        return true;
    }
    
    return false;
}
开发者ID:freemangordon,项目名称:cutetube2,代码行数:35,代码来源:dailymotionaccountmodel.cpp

示例4: createTargetFromSelection

void TargetsDialog::createTargetFromSelection()
{
	if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) {
		QList<StelObjectP> selectedObjects = StelApp::getInstance().getStelObjectMgr().getSelectedObject();
		QListIterator<StelObjectP> objectIterator(selectedObjects);
		StelCore* core = StelApp::getInstance().getCore();
		while (objectIterator.hasNext()) {
			StelObjectP stelObject = objectIterator.next();
			QString type = stelObject->getType();
			QString englishName = stelObject->getEnglishName();
			if (englishName == "") {
				englishName = "No Name";
			}
			float magnatude = stelObject->getVMagnitude(core);
			double angularSize = stelObject->getAngularSize(core);
			
			Vec3d pos;
			double ra, dec;
			// ra/dec in J2000
			pos = stelObject->getJ2000EquatorialPos(core);
			StelUtils::rectToSphe(&ra, &dec, pos);
			
		    QSqlField field1("name", QVariant::String);
			QSqlField field2("right_ascension", QVariant::Double);
			QSqlField field3("declination", QVariant::Double);
			QSqlField field4("target_type_id", QVariant::Int);
			QSqlField field5("magnitude", QVariant::Double);
			QSqlField field6("size", QVariant::Double);
			field1.setValue(QVariant(englishName));
			field2.setValue(QVariant(ra));
			field3.setValue(QVariant(dec));
			field4.setValue(QVariant(1));
			field5.setValue(QVariant(magnatude));
			field6.setValue(QVariant(angularSize));
			QSqlRecord newRecord = QSqlRecord();
			newRecord.append(field1);
			newRecord.append(field2);
			newRecord.append(field3);
			newRecord.append(field4);
			newRecord.append(field5);
			newRecord.append(field6);
			
			if (tableModel->insertRecord(-1, newRecord)) {
				ui->targetsListView->setCurrentIndex(tableModel->index(tableModel->rowCount() - 1, 1));
			} else {
				qWarning() << "LogBook: could not insert new target.  The error is: " << tableModel->lastError();
			}
		}
	} else {
		qDebug() << "====> Nothing selected.";
	}
}	
开发者ID:NGCyang,项目名称:stellarium,代码行数:52,代码来源:TargetsDialog.cpp

示例5: formatRecord

QSqlRecord DatabaseLayout::formatRecord(const LoggingEvent &rEvent)
{
    QSqlField field;
    QSqlRecord record;

    if (!mTimeStamp.isEmpty())
    {
        field.setName(mTimeStamp);
        field.setType(QVariant::DateTime);
        field.setGenerated(true);
        field.setValue(DateTime::fromMSecsSinceEpoch(rEvent.timeStamp()));
        record.append(field);
    }

    if (!mLoggerName.isEmpty())
    {
        field.setName(mLoggerName);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.loggerName());
        record.append(field);
    }

    if (!mThreadName.isEmpty())
    {
        field.setName(mThreadName);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.threadName());
        record.append(field);
    }

    if (!mLevel.isEmpty())
    {
        field.setName(mLevel);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.level().toString());
        record.append(field);
    }

    if (!mMessage.isEmpty())
    {
        field.setName(mMessage);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.message());
        record.append(field);
    }
    return record;
}
开发者ID:fu7iang,项目名称:Log4Qt,代码行数:51,代码来源:databaselayout.cpp

示例6: query

// ## See if DELETE+INSERT is the best approach. Sqlite3 supports INSERT OR IGNORE which could aslo be used
// ## Also check other upsert methods
QList<QSqlRecord> VideoParser::updateMediaInfos(const QList<QFileInfo> &fis, const QString &searchPath, QSqlDatabase db)
{
    Q_UNUSED(searchPath);
    QList<QSqlRecord> records;
    QSqlQuery query(db);
    ScopedTransaction transaction(db);

    foreach(const QFileInfo &fi, fis) {
        DEBUG << "Updating " << fi.absoluteFilePath();
        query.prepare("DELETE FROM video WHERE filepath=:filepath");
        query.bindValue(":filepath", fi.absoluteFilePath());
        if (!query.exec())
            qWarning() << query.lastError().text();

        if (!query.prepare("INSERT INTO video (filepath, title, thumbnail, uri, directory, mtime, ctime, filesize, show, season) "
                           " VALUES (:filepath, :title, :thumbnail, :uri, :directory, :mtime, :ctime, :filesize, :show, :season)")) {
            qWarning() << query.lastError().text();
            return records;
        }

        query.bindValue(":filepath", fi.absoluteFilePath());
        query.bindValue(":title", determineTitle(fi));
        query.bindValue(":thumbnail", generateThumbnail(m_settings, fi));
        query.bindValue(":uri", QUrl::fromLocalFile(fi.absoluteFilePath()).toEncoded());

        query.bindValue(":directory", fi.absolutePath() + '/');
        query.bindValue(":mtime", fi.lastModified().toTime_t());
        query.bindValue(":ctime", fi.created().toTime_t());
        query.bindValue(":filesize", fi.size());

        QPair<QString, QString> showAndSeason = determineShowAndSeason(fi, searchPath);
        query.bindValue(":show", showAndSeason.first);
        query.bindValue(":season", showAndSeason.second);

        if (!query.exec())
            qWarning() << query.lastError().text();
        
        QSqlRecord record;
        record.append(QSqlField("id", QVariant::Int));
        record.setValue(0, query.lastInsertId());
        QMap<QString, QVariant> boundValues = query.boundValues();
        for (QMap<QString, QVariant>::const_iterator it = boundValues.constBegin(); it != boundValues.constEnd(); ++it) {
            QString key = it.key().mid(1); // remove the ':'
            record.append(QSqlField(key, (QVariant::Type) it.value().type()));
            record.setValue(key, it.value());
        }
        records.append(record);
    }
开发者ID:dmore,项目名称:sasquatch,代码行数:50,代码来源:videoparser.cpp

示例7: accept

void SupplierDlg::accept()
{
    if(le_name->text().trimmed().isEmpty() || !cb_area->currentIndex()) {
	QMessageBox::information(this,
	  trUtf8("Alta Proveedor"),
	  trUtf8("Debe llenar al menos los campos obligatorios."));
	le_name->setFocus();
	return;
    }

    if(selectedRow >= 0) {
	mapper->submit();
    } else {
	QSqlRecord record;

	QSqlField nameField("name", QVariant::String);
	QSqlField areaField("idArea", QVariant::Int);
	QSqlField addressField("address", QVariant::String);
	QSqlField locationField("location", QVariant::String);
	QSqlField phoneField("phone", QVariant::String);
	QSqlField faxField("fax", QVariant::String);
	QSqlField emailField("email", QVariant::String);
	QSqlField contactNameField("contactName", QVariant::String);
	QSqlField contactPhoneField("contactPhone", QVariant::String);

	int idA = cb_area->model()->data(cb_area->model()->index(
	  cb_area->currentIndex(), 0)).toInt();

	nameField.setValue(le_name->text());
	areaField.setValue(idA);
	addressField.setValue(le_address->text());
	locationField.setValue(le_location->text());
	phoneField.setValue(le_phone->text());
	faxField.setValue(le_fax->text());
	emailField.setValue(le_email->text());
	contactNameField.setValue(le_contactName->text());
	contactPhoneField.setValue(le_contactPhone->text());

	record.append(nameField);
	record.append(areaField);
	record.append(addressField);
	record.append(locationField);
	record.append(phoneField);
	record.append(faxField);
	record.append(emailField);
	record.append(contactNameField);
	record.append(contactPhoneField);

	if(!model->insertRecord(-1, record)) {
	    model->revertAll();
	    if(errorCommon(this, SUPPLIER_WINDOW, model->lastError().number())) {
		return;
	    }
	}
    }

    QDialog::accept();
}
开发者ID:sisuani,项目名称:qzette,代码行数:58,代码来源:supplierdlg.cpp

示例8: addAccount

bool SoundCloudAccountModel::addAccount(const QString &userId, const QString &username, const QString &accessToken,
                                         const QString &refreshToken, const QString &scopes) {
    Logger::log(QString("SoundCloudAccountModel::addAccount(). User ID: %1, Username: %2, Access token: %3, Refresh token: %4, Scopes: %5").arg(userId).arg(username).arg(accessToken).arg(refreshToken).arg(scopes), Logger::LowVerbosity);
    QSqlField userIdField("userId", QVariant::String);
    userIdField.setValue(userId);
    
    QSqlField usernameField("username", QVariant::String);
    usernameField.setValue(username);
        
    QSqlField accessTokenField("accessToken", QVariant::String);
    accessTokenField.setValue(accessToken);
    
    QSqlField refreshTokenField("refreshToken", QVariant::String);
    refreshTokenField.setValue(refreshToken);
    
    QSqlField scopesField("scopes", QVariant::String);
    scopesField.setValue(scopes);

    QSqlRecord record;
    record.append(userIdField);
    record.append(usernameField);
    record.append(accessTokenField);
    record.append(refreshTokenField);
    record.append(scopesField);
        
    const int count = rowCount();
    
    for (int i = 0; i < count; i++) {
        if (data(index(i, 0)) == userId) {
            if (setRecord(i, record)) {
                SoundCloud::setUserId(userId);
                return true;
            }
            
            return false;
        }
    }
    
    if (insertRecord(-1, record)) {
        SoundCloud::setUserId(userId);
        const int count = rowCount();
        emit dataChanged(index(0, 0), index(count - 1, columnCount() - 1));
        emit countChanged(count);
        return true;
    }
    
    return false;
}
开发者ID:marxoft,项目名称:musikloud2,代码行数:48,代码来源:soundcloudaccountmodel.cpp

示例9: initColumns

void SQLiteResultPrivate::initColumns(bool emptyResultset)
{
    int nCols = sqlite3_column_count(stmt);
    if (nCols <= 0)
        return;

    q->init(nCols);

    for (int i = 0; i < nCols; ++i) {
        QString colName = stringFromUnicode(reinterpret_cast<const QChar *>(
                    sqlite3_column_name16(stmt, i))
                    ).remove(QLatin1Char('"'));

        // must use typeName for resolving the type to match SQLiteDriver::record
        QString typeName = stringFromUnicode(reinterpret_cast<const QChar *>(
                    sqlite3_column_decltype16(stmt, i)));

        int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
        QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(typeName));

        // sqlite3_column_type is documented to have undefined behavior if the result set is empty
        int stp = emptyResultset ? -1 : sqlite3_column_type(stmt, i);
        fld.setSqlType(stp);
        rInf.append(fld);
    }
}
开发者ID:Helgion,项目名称:quiterss,代码行数:26,代码来源:sqlitedriver.cpp

示例10: record

QSqlRecord QPSQLResult::record() const
{
    QSqlRecord info;
    if (!isActive() || !isSelect())
        return info;

    int count = PQnfields(d->result);
    for (int i = 0; i < count; ++i) {
        QSqlField f;
        if (d->driver->isUtf8)
            f.setName(QString::fromUtf8(PQfname(d->result, i)));
        else
            f.setName(QString::fromLocal8Bit(PQfname(d->result, i)));
        f.setType(qDecodePSQLType(PQftype(d->result, i)));
        int len = PQfsize(d->result, i);
        int precision = PQfmod(d->result, i);
        // swap length and precision if length == -1
        if (len == -1 && precision > -1) {
            len = precision - 4;
            precision = -1;
        }
        f.setLength(len);
        f.setPrecision(precision);
        f.setSqlType(PQftype(d->result, i));
        info.append(f);
    }
    return info;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:28,代码来源:qsql_psql.cpp

示例11: quote

// called on first fetch
void QSQLite2ResultPrivate::init(const char **cnames, int numCols)
{
    if (!cnames)
        return;

    rInf.clear();
    if (numCols <= 0)
        return;
    q->init(numCols);

    for (int i = 0; i < numCols; ++i) {
        const char* lastDot = strrchr(cnames[i], '.');
        const char* fieldName = lastDot ? lastDot + 1 : cnames[i];
        
        //remove quotations around the field name if any
        QString fieldStr = QString::fromAscii(fieldName);
        QLatin1Char quote('\"');
        if ( fieldStr.length() > 2 && fieldStr.startsWith(quote) && fieldStr.endsWith(quote)) {
            fieldStr = fieldStr.mid(1);
            fieldStr.chop(1);
        }
        rInf.append(QSqlField(fieldStr,
                              nameToType(QString::fromAscii(cnames[i+numCols]))));
    }
}
开发者ID:RS102839,项目名称:qt,代码行数:26,代码来源:qsql_sqlite2.cpp

示例12: accept

void CustomerDlg::accept()
{
    if(le_lastName->text().trimmed().isEmpty()) {
	QMessageBox::information(this,
	  trUtf8("Datos incompletos"),
	  trUtf8("Debe llenar al menos los campos obligatorios."));
	le_lastName->setFocus();
	return;
    }

    if(selectedRow >= 0) {
	mapper->submit();
    } else {
	QSqlRecord rec;
	QSqlField lastNameFiel("lastName", QVariant::String);
	QSqlField nameField("name", QVariant::String);
	QSqlField addressField("address", QVariant::String);
	QSqlField locationField("location", QVariant::String);
	QSqlField cellPoneField("cellphone", QVariant::String);
	QSqlField phoneField("phone", QVariant::String);
	QSqlField emailField("email", QVariant::String);

	lastNameFiel.setValue(le_lastName->text());
	nameField.setValue(le_name->text());
	addressField.setValue(le_address->text());
	locationField.setValue(le_location->text());
	cellPoneField.setValue(le_cellphone->text());
	phoneField.setValue(le_phone->text());
	emailField.setValue(le_email->text());

	rec.append(lastNameFiel);
	rec.append(nameField);
	rec.append(addressField);
	rec.append(locationField);
	rec.append(cellPoneField);
	rec.append(phoneField);
	rec.append(emailField);

	if(!model->insertRecord(-1, rec)) {
	    model->revertAll();
	    if(errorCommon(this, CUSTOMER_WINDOW, model->lastError().number()))
		return;
	}
    }

    QDialog::accept();
}
开发者ID:sisuani,项目名称:qzette,代码行数:47,代码来源:customerdlg.cpp

示例13: onAccepted

void AddContactDialog::onAccepted() {
    QSqlRecord record;
    QSqlField f1("firstname",QVariant::String);
    QSqlField f2("lastname",QVariant::String);
    QSqlField f3("birthday",QVariant::String);

    f1.setValue(QVariant(ui->firstNameEdit->text()));
    f2.setValue(QVariant(ui->lastNameEdit->text()));
    f3.setValue(QVariant(ui->birthdayEdit->text()));

    record.append(f1);
    record.append(f2);
    record.append(f3);

//    model->insertRecord(-1,record);
    model->insertRecord(0,record);

}
开发者ID:chk-mue-lab,项目名称:vcGiftTrac,代码行数:18,代码来源:addcontactdialog.cpp

示例14: insertNewBarlow

void BarlowsDataMapper::insertNewBarlow()
{
    QSqlField field1("model", QVariant::String);
    QSqlField field2("vendor", QVariant::String);
    QSqlField field3("factor", QVariant::Double);
	field1.setValue(QVariant("Model"));
	field2.setValue(QVariant("Vendor"));
	field3.setValue(QVariant(1.0));
	QSqlRecord newRecord = QSqlRecord();
	newRecord.append(field1);
	newRecord.append(field2);
	newRecord.append(field3);
	
	if (tableModel->insertRecord(-1, newRecord)) {
		widget->barlowsListView->setCurrentIndex(tableModel->index(tableModel->rowCount() - 1, 1));
	} else {
		qWarning() << "LogBook: could not insert new barlow.  The error is: " << tableModel->lastError();
	}
}
开发者ID:EvilTosha,项目名称:Stellarium-GSoC12,代码行数:19,代码来源:BarlowsDataMapper.cpp

示例15: createPermisoRec

void ModuloUsuarios::createPermisoRec(int & idusr, int & idMod,QSqlRecord & rcd)
{
  QSqlField f1("idcolaborador", QVariant::Int);
  QSqlField f2("id_sys_modulo", QVariant::Int);
  QSqlField f3("id_modulo", QVariant::Int);
  QSqlField f4("acceso",QVariant::Int);
  QSqlField f5("fecha",QVariant::DateTime);

  f1.setValue(QVariant(idusr));
  f2.setValue(QVariant(idMod));
  f3.setValue(QVariant(idMod));
  f4.setValue(QVariant(0));
  f5.clear();

  rcd.append(f1);
  rcd.append(f2);
  rcd.append(f3);
  rcd.append(f4);
  rcd.append(f5);
}
开发者ID:josueaqp92,项目名称:ProyFinal-IS2,代码行数:20,代码来源:modulousuarios.cpp


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