本文整理汇总了C++中SyncDocument::setRows方法的典型用法代码示例。如果您正苦于以下问题:C++ SyncDocument::setRows方法的具体用法?C++ SyncDocument::setRows怎么用?C++ SyncDocument::setRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyncDocument
的用法示例。
在下文中一共展示了SyncDocument::setRows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
SyncDocument *SyncDocument::load(const QString &fileName)
{
SyncDocument *ret = new SyncDocument;
ret->fileName = fileName;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(NULL, "Error", file.errorString());
return NULL;
}
QDomDocument doc;
QString err;
if (!doc.setContent(&file, &err)) {
file.close();
QMessageBox::critical(NULL, "Error", err);
return NULL;
}
file.close();
QDomNamedNodeMap attribs = doc.documentElement().attributes();
QDomNode rowsParam = attribs.namedItem("rows");
if (!rowsParam.isNull()) {
QString rowsString = rowsParam.nodeValue();
ret->setRows(rowsString.toInt());
}
QDomNodeList trackNodes =
doc.documentElement().elementsByTagName("track");
for (int i = 0; i < int(trackNodes.length()); ++i) {
QDomNode trackNode = trackNodes.item(i);
QDomNamedNodeMap attribs = trackNode.attributes();
QString name = attribs.namedItem("name").nodeValue();
// look up track-name, create it if it doesn't exist
SyncTrack *t = ret->findTrack(name.toUtf8());
if (!t)
t = ret->createTrack(name.toUtf8().constData());
QDomNodeList rowNodes = trackNode.childNodes();
for (int i = 0; i < int(rowNodes.length()); ++i) {
QDomNode keyNode = rowNodes.item(i);
QString baseName = keyNode.nodeName();
if (baseName == "key") {
QDomNamedNodeMap rowAttribs = keyNode.attributes();
QString rowString = rowAttribs.namedItem("row").nodeValue();
QString valueString = rowAttribs.namedItem("value").nodeValue();
QString interpolationString = rowAttribs.namedItem("interpolation").nodeValue();
SyncTrack::TrackKey k;
k.row = rowString.toInt();
k.value = valueString.toFloat();
k.type = SyncTrack::TrackKey::KeyType(interpolationString.toInt());
Q_ASSERT(!t->isKeyFrame(k.row));
t->setKey(k);
}
}
}
// YUCK: gathers from entire document
QDomNodeList bookmarkNodes =
doc.documentElement().elementsByTagName("bookmark");
for (int i = 0; i < int(bookmarkNodes.length()); ++i) {
QDomNode bookmarkNode =
bookmarkNodes.item(i);
QDomNamedNodeMap bookmarkAttribs =
bookmarkNode.attributes();
QString str =
bookmarkAttribs.namedItem("row").nodeValue();
int row = str.toInt();
ret->toggleRowBookmark(row);
}
return ret;
}