PolygonPoint* Polygon::appendPoint() { PolygonPoint* newPoint = new PolygonPoint(*getBaseNode(), getPositionProvider(), 0.25); newPoint->makeInteractive(mBulletWorld); mPoints.push_back(newPoint); return newPoint; }
void ResourceInfo::init_() { ResourceInfoRequestData requestData; requestData.bonusType = bonusType_; requestData.playerType = playerType_; infoNode_ = getBaseNode(requestData); }
bool KOfficePlugin::writeInfo( const KFileMetaInfo& info) const { bool no_errors = true; QDomDocument doc = getMetaDocument(info.path()); QDomElement base = getBaseNode(doc).toElement(); if (base.isNull()) return false; for (int i = 0; Information[i]; i+=2) no_errors = no_errors && writeTextNode(doc, base, Information[i], info[DocumentInfo][Information[i]].value().toString()); // If we need a meta:keywords container, we create it. if (base.namedItem(metakeywords).isNull()) base.appendChild(doc.createElement(metakeywords)); QDomNode metaKeyNode = base.namedItem(metakeywords); QDomNodeList childs = doc.elementsByTagName(metakeyword); for (int i = childs.length(); i >= 0; --i){ metaKeyNode.removeChild( childs.item(i) ); } QStringList keywordList = QStringList::split(",", info[DocumentInfo][metakeyword].value().toString().stripWhiteSpace(), false); for ( QStringList::Iterator it = keywordList.begin(); it != keywordList.end(); ++it ) { QDomElement elem = doc.createElement(metakeyword); metaKeyNode.appendChild(elem); elem.appendChild(doc.createTextNode((*it).stripWhiteSpace())); } // Now, we store the user-defined data QDomNodeList theElements = base.elementsByTagName(metauserdef); for (uint i = 0; i < theElements.length(); i++) { QDomElement el = theElements.item(i).toElement(); if (el.isNull()){ kdDebug(7034) << metauserdef << " is not an Element" << endl; no_errors = false; } QString s = info[UserDefined][el.attribute(metaname)].value().toString(); if (s != el.text()){ QDomText txt = doc.createTextNode(s); if (!el.firstChild().isNull()) el.replaceChild(txt, el.firstChild()); else el.appendChild(txt); } } if (!no_errors){ kdDebug(7034) << "Errors were found while building " << metafile << " for file " << info.path() << endl; // It is safer to avoid to manipulate meta.xml if errors, we abort. return false; } writeMetaData(info.path(), doc); return true; }
void Polygon::loadFromShape(const WFMath::Polygon<2>& shape) { clear(); for (size_t i = 0; i < shape.numCorners(); ++i) { const WFMath::Point<2>& position = shape[i]; PolygonPoint* point = new PolygonPoint(*getBaseNode(), getPositionProvider(), 0.25, position); point->makeInteractive(mBulletWorld); mPoints.push_back(point); } mRenderer.update(); }
PolygonPoint* Polygon::insertPointBefore(PolygonPoint& point) { if (!mPoints.empty()) { auto I = std::find(mPoints.begin(), mPoints.end(), &point); if (I != mPoints.end()) { PolygonPoint* newPoint = new PolygonPoint(*getBaseNode(), getPositionProvider(), 0.25); newPoint->makeInteractive(mBulletWorld); mPoints.insert(I, newPoint); return newPoint; } } return nullptr; }
bool KOfficePlugin::readInfo( KFileMetaInfo& info, uint /*what*/) { if ( info.path().isEmpty() ) // remote file return false; KFileMetaInfoGroup group = appendGroup(info, DocumentInfo); QDomDocument doc = getMetaDocument(info.path()); if (doc.isNull()) return false; QDomElement base = getBaseNode(doc).toElement(); if (base.isNull()) return false; for (int i = 0; Information[i]; i+=2) appendItem(group, Information[i], stringFromNode(base, Information[i])); // Special case for keyword QDomNodeList keywordList = base.elementsByTagName( metakeyword ); QString allKeywords; for (uint i = 0; i < keywordList.length(); i++){ QDomNode node = keywordList.item(i); if (node.isElement()){ if (i>0) allKeywords += ", "; allKeywords += node.toElement().text(); } } appendItem(group, metakeyword, allKeywords); KFileMetaInfoGroup group1 = appendGroup(info, DocAdvanced); for (int i = 0; Advanced[i]; i+=2){ QString txt = stringFromNode(base, Advanced[i]); if (!txt.isEmpty()){ // A silly way to do it... switch (i){ case 2: case 4: case 6: getDateTime(group1, Advanced[i], txt); break; case 14: getEditingTime(group1, Advanced[i], txt); break; default: appendItem(group1, Advanced[i], txt);} } } QDomNode dstat = base.namedItem(metadocstat); KFileMetaInfoGroup group2 = appendGroup(info, DocStatistics); if (!dstat.isNull() && dstat.isElement()){ QDomElement dinfo = dstat.toElement(); for (int i = 0; Statistics[i]; i+=2) addAttributeInfo(dinfo, group2, Statistics[i] ); } QDomNodeList userList = base.elementsByTagName( metauserdef ); KFileMetaInfoGroup groupuser = appendGroup(info, UserDefined); for (uint i = 0; i < userList.length(); i++){ QDomNode node = userList.item(i); if (node.isElement()){ appendItem(groupuser, node.toElement().attribute(metaname, QString("User %1").arg(i)), node.toElement().text()); } } return true; }
void SpecInfo::init_() { infoNode_ = getBaseNode(SpecInfoRequestData(specialistType_, playerType_)); }