本文整理汇总了C++中QDomNode::insertBefore方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::insertBefore方法的具体用法?C++ QDomNode::insertBefore怎么用?C++ QDomNode::insertBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::insertBefore方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doExecute
void XBELImportCommand::doExecute(const KBookmarkGroup &/*bkGroup*/) {
// check if already open first???
KBookmarkManager *pManager = KBookmarkManager::managerForFile(m_fileName, QString());
QDomDocument doc = GlobalBookmarkManager::self()->mgr()->internalDocument();
// get the xbel
QDomNode subDoc = pManager->internalDocument().namedItem("xbel").cloneNode();
if (subDoc.isProcessingInstruction())
subDoc = subDoc.nextSibling();
if (subDoc.isDocumentType())
subDoc = subDoc.nextSibling();
if (subDoc.nodeName() != "xbel")
return;
if (!folder().isEmpty()) {
// transform into folder
subDoc.toElement().setTagName("folder");
// clear attributes
QStringList tags;
for (int i = 0; i < subDoc.attributes().count(); i++)
tags << subDoc.attributes().item(i).toAttr().name();
for (QStringList::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
subDoc.attributes().removeNamedItem((*it));
subDoc.toElement().setAttribute("icon", m_icon);
// give the folder a name
QDomElement textElem = doc.createElement("title");
subDoc.insertBefore(textElem, subDoc.firstChild());
textElem.appendChild(doc.createTextNode(folder()));
}
// import and add it
QDomNode node = doc.importNode(subDoc, true);
if (!folder().isEmpty()) {
GlobalBookmarkManager::self()->root().internalElement().appendChild(node);
m_group = KBookmarkGroup(node.toElement()).address();
} else {
QDomElement root = GlobalBookmarkManager::self()->root().internalElement();
QList<QDomElement> childList;
QDomNode n = subDoc.firstChild().toElement();
while (!n.isNull()) {
QDomElement e = n.toElement();
if (!e.isNull())
childList.append(e);
n = n.nextSibling();
}
QList<QDomElement>::Iterator it = childList.begin();
QList<QDomElement>::Iterator end = childList.end();
for (; it!= end ; ++it)
root.appendChild((*it));
}
}
示例2: QDomNode
QDomNode QDomNodeProto:: insertBefore(const QDomNode& newChild, const QDomNode& refChild)
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->insertBefore(newChild, refChild);
return QDomNode();
}
示例3: behaviourUp
void PolicyDocumentClass::behaviourUp(const QString& patternName,
const QString& behaviourName)
{
// get DOM node of the given pattern and behaviour //
QDomNode patternNode = getPatternNode(patternName);
QDomNode behaviourNode = getBehaviourNode(patternName, behaviourName);
QDomNode prevBehaviourNode = getPrevBehaviourNode(patternName,behaviourName);
if (prevBehaviourNode.isNull()) return;
// remove DOM node //
patternNode.insertBefore(behaviourNode, prevBehaviourNode);
}
示例4: reassignPosition
//===========================================================================
void detectorTabWidget::reassignPosition(int from, int to)
{
int direction = from - to ;
std::string tabLabelFrom = this->tabText(from).toStdString() ;
std::string tabLabelTo = this->tabText(to ).toStdString() ;
QDomNode parentNode = detectorMap_[tabLabelFrom].parentNode() ;
if( direction > 0 ) // Insert after
{
parentNode.insertAfter(detectorMap_[tabLabelFrom],detectorMap_[tabLabelTo]) ;
}
else // Insert before
{
parentNode.insertBefore(detectorMap_[tabLabelFrom],detectorMap_[tabLabelTo]) ;
}
}
示例5: QObject
KopeteCommandGUIClient( Kopete::ChatSession *manager ) : QObject(manager), KXMLGUIClient(manager)
{
setXMLFile( QString::fromLatin1("kopetecommandui.rc") );
QDomDocument doc = domDocument();
QDomNode menu = doc.documentElement().firstChild().firstChild().firstChild();
CommandList mCommands = Kopete::CommandHandler::commandHandler()->commands(
manager->protocol()
);
CommandList::Iterator it, itEnd = mCommands.end();
for( it = mCommands.begin(); it != itEnd; ++it )
{
KAction *a = static_cast<KAction*>( it.value() );
actionCollection()->addAction( a->objectName(), a );
QDomElement newNode = doc.createElement( QString::fromLatin1("Action") );
newNode.setAttribute( QString::fromLatin1("name"), a->objectName() );
bool added = false;
for( QDomElement n = menu.firstChild().toElement();
!n.isNull(); n = n.nextSibling().toElement() )
{
if( a->objectName() < n.attribute(QString::fromLatin1("name")))
{
menu.insertBefore( newNode, n );
added = true;
break;
}
}
if( !added )
{
menu.appendChild( newNode );
}
}
setDOMDocument( doc );
}
示例6: while
// function that parses an XML DOM for 'xs:include' directives and loads
// and inserts the mentioned documents into it
void
load(QDomNode n) {
while (!n.isNull()) {
if (n.hasChildNodes()) {
load(n.firstChild());
}
if (n.nodeName() == "xs:include") {
QString f = n.toElement().attribute("schemaLocation");
QDomDocument d = loadDocument(dir+"/"+f);
QDomDocument o = n.ownerDocument();
QDomNode newn = o.importNode(d.documentElement(), true);
QDomNode p = n.parentNode();
QDomNode old = n;
n = n.nextSibling();
p.removeChild(old);
while (!newn.firstChild().isNull()) {
p.insertBefore(newn.firstChild(), n);
}
} else {
n = n.nextSibling();
}
}
}