本文整理汇总了C++中QSqlRecord::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRecord::isEmpty方法的具体用法?C++ QSqlRecord::isEmpty怎么用?C++ QSqlRecord::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlRecord
的用法示例。
在下文中一共展示了QSqlRecord::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextRecord
int qtDatabase::nextRecord()
{
result->next();
QSqlRecord record = result->record();
if(record.isEmpty()) return -1;
return 0;
}
示例2: insert
//start id="insert"
bool MetaDataTable::insert(const MetaDataValue &ft) {
using namespace DbUtils;
QSqlDatabase db = DbConnectionSettings::lastSaved();
QSqlRecord record = db.record(m_tableName);
if (record.isEmpty() && !createMetadataTable()) {
qDebug() << "unable to create metadata: "
<< db.lastError().text();
return false;
}
m_insertQuery.bindValue(":artist", ft.artist());
m_insertQuery.bindValue(":title", ft.trackTitle());
m_insertQuery.bindValue(":album", ft.albumTitle());
m_insertQuery.bindValue(":track", ft.trackNumber());
QTime t = ft.trackTime();
int secs = QTime().secsTo(t);
m_insertQuery.bindValue(":time", secs);
m_insertQuery.bindValue(":genre", ft.genre());
m_insertQuery.bindValue(":filename", ft.fileName());
int pref = ft.preference().intValue();
m_insertQuery.bindValue(":preference", pref);
m_insertQuery.bindValue(":comment", ft.comment());
bool retval = m_insertQuery.exec();
if (!retval) {
qDebug() << m_insertQuery.lastError().text()
<< m_insertQuery.lastQuery();
abort();
}
emit inserted(ft);
return retval;
}
示例3: update
void update(QSqlDatabase* db, Tag& tag) {
QSqlQuery q(*db);
QSqlRecord r;
if(!QItem::isExists(db, "tags", "guid", QString::fromStdString(tag.guid), r))
{
r = QItem::load(db, "tags", "name", QString::fromUtf8(tag.name.c_str()));
if(!r.isEmpty())
{
tag.name = QItem::resolveConflict(db, r, QString::fromStdString(tag.guid), DELETE_ITEM("tags", "guid", QString::fromStdString(tag.guid)), tag.name);
}
q.prepare(INSERT_TAG(tag.guid, tag.name, tag.parentGuid, tag.updateSequenceNum));
}
else if(r.value("updateSequenceNum").toInt() < tag.updateSequenceNum)
{
qDebug() << r.value("updateSequenceNum").toInt() << r;
// update tag
q.prepare(UPDATE_TAG(tag.guid, tag.name, tag.parentGuid, tag.updateSequenceNum));
}
else
return;
QItem::executeQuery(q);
}
示例4: isEmpty
bool QSqlRecordProto::isEmpty() const
{
QSqlRecord *item = qscriptvalue_cast<QSqlRecord*>(thisObject());
if (item)
return item->isEmpty();
return false;
}
示例5: insertRowIntoTable
bool PoitemTableModel::insertRowIntoTable(const QSqlRecord& record)
{
if (record.isEmpty())
return true;
bool isNull = true;
for (int i = 0; i < record.count(); i++)
{
if (i == record.indexOf("poitem_pohead_id") ||
(record.value(i).toString().isEmpty() &&
(i == record.indexOf("poitem_status") ||
i == record.indexOf("poitem_vend_item_descrip") ||
i == record.indexOf("poitem_vend_uom") ||
i == record.indexOf("poitem_vend_item_number") ||
i == record.indexOf("poitem_comments") )))
continue;
isNull &= record.isNull(i);
}
if (isNull)
return true;
QSqlRecord newRecord(record);
if (! validRow(newRecord))
return false;
return QSqlRelationalTableModel::insertRowIntoTable(newRecord);
}
示例6: readProtoBufferFromDatabase
/**
* @brief cwRegionLoadTask::readProtoBufferFromDatabase
* @return This reads the proto buffer from the database
*/
QByteArray cwRegionLoadTask::readProtoBufferFromDatabase(bool* okay)
{
cwSQLManager::Transaction transaction(&Database, cwSQLManager::ReadOnly);
QSqlQuery selectObjectData(Database);
QString queryStr =
QString("SELECT protoBuffer FROM ObjectData where id = 1");
bool couldPrepare = selectObjectData.prepare(queryStr);
if(!couldPrepare) {
qDebug() << "Couldn't prepare select Caving Region:" << selectObjectData.lastError().databaseText() << queryStr;
}
//Extract the data
selectObjectData.exec();
QSqlRecord record = selectObjectData.record();
if(record.isEmpty()) {
qDebug() << "Hmmmm, no caving regions to load from protoBuffer";
*okay = false;
return QByteArray();
}
//Get the first row
selectObjectData.next();
*okay = true;
QByteArray data = selectObjectData.value(0).toByteArray();
return data;
}
示例7: count
int XSqlQuery::count()
{
QSqlRecord rec = record();
if (!rec.isEmpty())
return rec.count();
else
return 0;
}
示例8: setItem
void Scrap::setItem(const QSqlRecord &record)
{
if(!record.isEmpty()){
ui->number_lineEdit->setText(record.value("number").toString());
ui->operator_lineEdit->setText(record.value("name").toString());
ui->type_lineEdit->setText(record.value("type").toString());
ui->manufacturer_lineEdit->setText(record.value("manufacturer").toString());
}
}
示例9: QStringList
int
QcOfflineCacheDatabase::has_tile(const QcTileSpec & tile_spec)
{
QSqlRecord record = select_one(TILE, QStringList(OFFLINE_COUNT), tile_where_clause(tile_spec));
if (record.isEmpty())
return 0;
else
return record.value(0).toInt();
}
示例10: count
int XSqlQuery::count()
{
QSqlRecord record = driver()->record(*this);
if (!record.isEmpty())
return record.count();
else
return 0;
}
示例11: generateRoleNames
void SqlQueryModel::generateRoleNames(const QSqlRecord &rec)
{
roles.clear();
if (rec.isEmpty()) {
for( int i = 0; i < record().count(); i++)
roles.insert(Qt::UserRole + i + 1, record().fieldName(i).toLocal8Bit());
} else {
for( int i = 0; i < rec.count(); i++)
roles.insert(Qt::UserRole + i + 1, rec.fieldName(i).toLocal8Bit());
}
}
示例12: value
QVariant XSqlQuery::value(const QString & name) const
{
if (name.isEmpty())
return QVariant();
QSqlRecord r = driver()->record(*this);
if (!r.isEmpty())
return value(r.position(name));
return QVariant();
}
示例13: getRecord
QSqlRecord GenericDAO::getRecord(const QString& where, const QVariantList& bindValues, DBMode dbMode) const
{
DBPair* dbPair = DBPool::getInstance()->getInstanceDBPair();
Q_ASSERT(dbPair);
QSqlRecord rec = getRecord(dbPair->getDabase(dbMode), where, bindValues);
if (!rec.isEmpty())
return rec;
return dbMode == Local ? getRecord(dbPair->getDabaseRemote(), where, bindValues) : QSqlRecord();
}
示例14: configurationFromRecord
WineConfiguration WineConfigurationsModel::configurationFromRecord(const QSqlRecord & record) const
{
WineConfiguration c;
if ( record.isEmpty() ) return c;
c.setWinePrefix(record.value("wineprefix").toString());
WineInstallationsModel *m = qtwineApp->wineInstallationsModel();
c.setWineInstallation( m->installationById(record.value("wineinstallation").toInt()) );
return c;
}
示例15: removeEntry
bool PlayListDb::removeEntry(QString playList, int pid) {
QSqlDatabase db = DbConnectionSettings::lastSaved();
QString tn = tableName(playList);
QSqlRecord record = db.record(tn);
Q_ASSERT(!record.isEmpty());
QString queryString=QString("delete from %1 where pid=%2")
.arg(tn).arg(pid);
QSqlQuery q(queryString);
qDebug() << queryString;
return q.isActive();
}