本文整理汇总了C++中AttributeMap::save方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeMap::save方法的具体用法?C++ AttributeMap::save怎么用?C++ AttributeMap::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeMap
的用法示例。
在下文中一共展示了AttributeMap::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: archivePos
int ArchiveMan::archivePos( int archDocId, KraftDoc *doc )
{
/*
mysql> describe archdocpos;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| archPosID | int(11) | NO | PRI | NULL | auto_increment |
| archDocID | int(11) | NO | MUL | | |
| ordNumber | int(11) | NO | | | |
| text | text | YES | | NULL | |
| amount | decimal(6,2) | YES | | NULL | |
| unit | varchar(64) | YES | | NULL | |
| price | decimal(6,2) | YES | | NULL | |
| vat | decimal(3,1) | YES | | 0.0 | |
+-----------+--------------+------+-----+---------+----------------+
*/
if( ! doc ) return -1;
QSqlTableModel model;
model.setTable("archdocpos");
QSqlRecord record = model.record();
int cnt = 0;
DocPositionList posList = doc->positions();
DocPositionListIterator it( posList );
kDebug() << "Archiving pos for " << archDocId << endl;
while ( it.hasNext() ) {
DocPosition *dp = static_cast<DocPosition*>( it.next() );
record.setValue( "archDocID", archDocId );
record.setValue( "ordNumber", 1+cnt /* dp->position() */ );
record.setValue( "kind", dp->attribute( DocPosition::Kind ) );
record.setValue( "text", dp->text() ); // expandItemText( dp ) );
record.setValue( "amount", dp->amount() );
record.setValue( "unit", dp->unit().einheit( dp->amount() ) );
record.setValue( "price", dp->unitPrice().toDouble() );
record.setValue( "overallPrice", dp->overallPrice().toDouble() );
record.setValue( "taxType", dp->taxTypeNumeric() );
if(!model.insertRecord(-1, record)) {
kDebug() << model.lastError();
}
dbID id = KraftDB::self()->getLastInsertID();
// kDebug() << "Inserted for id " << id.toString() << endl;
cnt++;
// save the attributes of the positions in the attributes
// table but with a new host type which reflects the arch state
AttributeMap attribs = dp->attributes();
attribs.setHost( "ArchPosition" );
attribs.save( id );
}
return cnt;
}