QString Tag::toString() { QTag *qTag = QuantaCommon::tagFromDTD(dtd, name); QValueList<TagAttr>::Iterator it; TagAttr attr; QString attrString; QString tagString; for (it = attrs.begin(); it != attrs.end(); ++it) { attr = *it; attrString = " "; if (attr.value.isEmpty()) { attrString.append(attr.name); } else { attrString.append(attr.name + "="); if (!attr.value.startsWith("\\\"") && !attr.value.startsWith("\\\'")) attrString.append(qConfig.attrValueQuotation); attrString.append(attr.value); if (!attr.value.endsWith("\\\"") && !attr.value.endsWith("\\\'")) attrString.append(qConfig.attrValueQuotation); } tagString.prepend(attrString); } attrString = "<" + QuantaCommon::tagCase(name); tagString.prepend(attrString); if (attrs.isEmpty() && qTag && qTag->parentDTD->singleTagStyle == "xml" && (qTag->isSingle() || (!qConfig.closeOptionalTags && qTag->isOptional()) || single) ) { tagString.append(" /"); } tagString.append(">"); return tagString; }
void Tag::parse(const QString &p_tagStr, Document *p_write) { attrs.clear(); m_tagStr = p_tagStr; uint strLength = m_tagStr.length(); cleanStr = m_tagStr; m_write = p_write; if (!m_tagStr.startsWith("<")) { type = Text; return; } m_nameLine = m_area.bLine; m_nameCol = m_area.bCol + 1; uint pos = 1; while (pos < strLength && !m_tagStr[pos].isSpace() && m_tagStr[pos] != '>' && m_tagStr[pos] != '\n') { pos++; } name = m_tagStr.mid(1, pos - 1); int nameSpacePos = name.find(':'); if (nameSpacePos != -1) { nameSpace = name.left(nameSpacePos); name = name.mid(++nameSpacePos); m_nameCol += nameSpacePos; } QString attrStr; TagAttr attr; attr.special = false; //by default non of the attributes are special while (pos < strLength && m_tagStr[pos].isSpace()) pos++; int sPos = pos; int valueStartPos = 0; while (pos < strLength) { //find the attribute name while (pos < strLength && !m_tagStr[pos].isSpace() && m_tagStr[pos] != '=') { pos++; } attr.name = m_tagStr.mid(sPos, pos - sPos); if (attr.name.endsWith(">") && pos == strLength) { attr.name = attr.name.left(attr.name.length() - 1).lower(); if (!attr.name.stripWhiteSpace().isEmpty()) { attr.nameLine = m_tagStr.left(sPos).contains('\n') + m_area.bLine; if (attr.nameLine == m_area.bLine) attr.nameCol = sPos + m_area.bCol; else attr.nameCol = m_tagStr.left(sPos).section('\n',-1).length(); attr.value = (dtd != 0) ? dtd->booleanTrue : QString("checked"); attr.valueCol = attr.nameCol; attr.valueLine = attr.nameLine; attr.quoted = false; attrs.append(attr); } break; } if (dtd && !dtd->caseSensitive) attr.name = attr.name.lower(); attr.nameLine = m_tagStr.left(sPos).contains('\n') + m_area.bLine; if (attr.nameLine == m_area.bLine) attr.nameCol = sPos + m_area.bCol; else attr.nameCol = m_tagStr.left(sPos).section('\n',-1).length(); while (pos < m_tagStr.length() && m_tagStr[pos].isSpace()) pos++; //if the attribute is just listed and there is no value specified, //treate it as a "true" boolean if (m_tagStr[pos] != '=' || pos == strLength) { attr.value = (dtd != 0) ? dtd->booleanTrue : QString("checked"); attr.valueCol = attr.nameCol; attr.valueLine = attr.nameLine; attr.quoted = false; pos--; } else { pos++; while (pos < strLength && m_tagStr[pos].isSpace()) pos++; if (m_tagStr[pos] == '\'' || m_tagStr[pos] == '"') { attr.quoted = true; valueStartPos = pos + 1; QChar quotation = m_tagStr[pos]; pos += 1; while (pos < strLength && (m_tagStr[pos] != quotation || (m_tagStr[pos] == quotation && m_tagStr[pos-1] == '\\'))) { pos++; } attr.value = m_tagStr.mid(valueStartPos, pos - valueStartPos); } else { attr.quoted = false; valueStartPos = pos; while (pos < strLength && !m_tagStr[pos].isSpace()) pos++; if (pos == strLength) pos--; attr.value = m_tagStr.mid(valueStartPos, pos - valueStartPos); } attr.valueLine = m_tagStr.left(valueStartPos).contains('\n') + m_area.bLine; if (attr.valueLine == m_area.bLine) attr.valueCol = valueStartPos + m_area.bCol; else attr.valueCol = m_tagStr.left(valueStartPos).section('\n',-1).length(); } attrs.append(attr); //go to the first non-space char. This is where the next attribute name starts pos++; while (pos < strLength && m_tagStr[pos].isSpace()) pos++; sPos = pos++; } //add the tag to the document usertag list if it's not present in the dtd if (m_tagStr.startsWith("<") && m_tagStr.endsWith(">") && dtd) { //QString tagName = (m_parsingDTD->caseSensitive) ? name : name.upper(); QString tagName = name.lower(); //add the new xml tags to the userTagList if ( !QuantaCommon::isKnownTag(dtd->name, tagName) && name[0] != '/' ) { QTag *newTag = m_write->userTagList.find(tagName); bool insertNew = !newTag; if (insertNew) { newTag = new QTag(); newTag->setName(name); newTag->parentDTD = dtd; } for (int i = 0; i >attrCount(); i++) { Attribute *attr = new Attribute; attr->name = attribute(i); attr->values.append(attributeValue(i)); newTag->addAttribute(attr); delete attr; } if (insertNew) { m_write->userTagList.insert(tagName, newTag); } } } }
void EnhancedTagAttributeTree::deleteNode() { QuantaView *view = ViewManager::ref()->activeView(); if(!curNode || !view->document()) return; Node *oldCurNode, *oldCurNodeParent, *child; QTag *oldCurNodeParentQTag; int curLine, curCol; long offset; DOM::Node domNode; QValueList<int> loc; NodeModifsSet *modifs; //Save the cursor position in kafka/quanta if(view->hadLastFocus() == QuantaView::SourceFocus) curNode->tag->beginPos(curLine, curCol); else { KafkaDocument::ref()->getKafkaWidget()->getCurrentNode(domNode, offset); if(!domNode.previousSibling().isNull()) domNode = domNode.previousSibling(); else if(!domNode.parentNode().isNull()) domNode = domNode.parentNode(); else domNode = KafkaDocument::ref()->getKafkaWidget()->document(); if(domNode.nodeType() == DOM::Node::TEXT_NODE) offset = domNode.nodeValue().length(); else offset = 0; loc = kafkaCommon::getLocation(domNode); } //remove the Nodes oldCurNode = curNode; oldCurNodeParent = curNode->parent; curNode = 0L; attrTree->setCurrentNode(curNode); modifs = new NodeModifsSet(); kafkaCommon::extractAndDeleteNode(oldCurNode, modifs, false); //Then we see if the new parent - child relationships are valid, and if not, delete the child and restart if(oldCurNodeParent) { oldCurNodeParentQTag = QuantaCommon::tagFromDTD(oldCurNodeParent); if(oldCurNodeParentQTag) { child = oldCurNodeParent->child; while(child) { if(!oldCurNodeParentQTag->isChild(child)) { kafkaCommon::extractAndDeleteNode(child, modifs, false); //too lazy to get the real next node ;-) child = oldCurNodeParent->child; } else child = child->next; } } } view->document()->docUndoRedo->addNewModifsSet(modifs, undoRedo::NodeTreeModif); //set the cursor position in kafka/quanta if(view->hadLastFocus() == QuantaView::SourceFocus) view->document()->viewCursorIf->setCursorPositionReal((uint)curLine, (uint)curCol); else { domNode = kafkaCommon::getNodeFromLocation(loc, KafkaDocument::ref()->getKafkaWidget()->document()); KafkaDocument::ref()->getKafkaWidget()->setCurrentNode(domNode, offset); } }
void TagAttributeTree::setCurrentNode(Node *node) { if (m_node == node) return; m_node = node; emit newNodeSelected(node); if (!rebuildEnabled) return; clear(); m_parentItem = 0L; //We don't want to be able to edit the text node but it's parent. if (node && node->tag->type == Tag::Text) m_node = node = node->parent; if (!node) return; #ifdef HEAVY_DEBUG kafkaCommon::coutTree(baseNode, 2); KafkaDocument::ref()->coutLinkTree(baseNode, 2); #endif AttributeItem *item = 0L; TopLevelItem *group = 0L; QString attrName; QTag *qTag = QuantaCommon::tagFromDTD(node); Node *n = node->parent; while (n) { if (n->tag->type == Tag::XmlTag) { if (!m_parentItem) { group = new TopLevelItem(this, 0L, i18n("Parent tags")); m_parentItem = new ParentItem(this, group); } m_parentItem->addNode(n); } n = n->parent; } if (m_parentItem) m_parentItem->showList(true); if (group) group->setOpen(true); // if (!node->tag->nameSpace.isEmpty()) if(node->tag->type == Tag::XmlTag || node->tag->type == Tag::XmlTagEnd) { QString nameSpace = node->tag->nameSpace; if (node->tag->type == Tag::XmlTagEnd) nameSpace.remove('/'); group = new TopLevelItem(this, group, i18n("Namespace")); item = new AttributeNameSpaceItem(this, group, i18n("prefix"), nameSpace); group->setOpen(true); } if (qTag) { group = new TopLevelItem(this, group, i18n("Attributes")); QStringList list; for (int i = 0; i < qTag->attributeCount(); i++) { list += qTag->attributeAt(i)->name; } list.sort(); QStringList::Iterator it = list.end(); --it; while (it != list.end()) { Attribute *attr = qTag->attribute(*it); if (attr->type == "check") { item = new AttributeBoolItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else if (attr->type == "url") { item = new AttributeUrlItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else if (attr->type == "list") { item = new AttributeListItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else if (attr->type == "color") { item = new AttributeColorItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else { item = new AttributeItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } item->setRenameEnabled(1, true); if (it != list.begin()) --it; else break; } group->setOpen(true); for (uint i = 0; i < qTag->commonGroups.count(); i++) { group = new TopLevelItem(this, group, i18n(qTag->commonGroups[i].utf8())); AttributeList *groupAttrs = qTag->parentDTD->commonAttrs->find(qTag->commonGroups[i]); for (uint j = 0; j < groupAttrs->count(); j++) { Attribute *attr = groupAttrs->at(j); attrName = attr->name; if (attr->type == "check") { item = new AttributeBoolItem(this, group, attrName, node->tag->attributeValue(attrName)); } else if (attr->type == "url") { item = new AttributeUrlItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else if (attr->type == "list") { item = new AttributeListItem(this, group, attr->name, node->tag->attributeValue(attr->name), attr); } else if (attr->type == "color") { item = new AttributeColorItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else if (attr->type == "css-style") { item = new AttributeStyleItem(this, group, attr->name, node->tag->attributeValue(attr->name)); } else { item = new AttributeItem(this, group, attrName, node->tag->attributeValue(attrName)); } item->setRenameEnabled(1, true); } group->setOpen(true); } } connect(this, SIGNAL(collapsed(QListViewItem*)), SLOT(slotCollapsed(QListViewItem*))); connect(this, SIGNAL(expanded(QListViewItem*)), SLOT(slotExpanded(QListViewItem*))); }
QList<KTextEditor::CompletionItem>* XmlEntityCompletion::completionEntries() { QList<KTextEditor::CompletionItem> *completions = new QList<KTextEditor::CompletionItem>(); QMap<QString, KTextEditor::CompletionItem> completionMap; KTextEditor::CompletionItem completion; //first search for entities defined in the document const DTDStruct *dtdDTD = DTDs::ref()->find("dtd"); if (dtdDTD) { StructTreeGroup group; uint cnt = dtdDTD->structTreeGroups.count(); for (uint j = 0; j < cnt; j++) { group = dtdDTD->structTreeGroups[j]; if (!group.autoCompleteAfterRx.pattern().isEmpty() && group.autoCompleteAfterRx.indexIn("&") != -1) { SpecialAreaGroupCompletion *inlineDTDCompletion = static_cast<SpecialAreaGroupCompletion*>(CompletionBase::getCompletionObject(m_base, m_source, m_position, m_currentNode, SpecialAreaGroups, Forced, m_plugin)); inlineDTDCompletion->setGroup(&(dtdDTD->structTreeGroups[j])); QList<KTextEditor::CompletionItem> *inlineDTDCompletions = inlineDTDCompletion->completionEntries(); uint count = inlineDTDCompletions->count(); for (uint i = 0; i < count; i++) { completion = (*inlineDTDCompletions)[i]; if (completion.text().startsWith(m_startsWith)) { //FIXME completion.type = "entityCompletion"; completions->append(completion); completionMap[completion.text()] = completion; } } break; } } } //FIXME completion.type = "entityCompletion"; //add the entities from the tag files QHashIterator<QString, QTag*> it(*(m_currentNode->tag->dtd()->tagsList)); while (it.hasNext()) { it.next(); QTag *tag = it.value(); if (tag->type == "entity") { QString tagName = tag->name(); if (m_startsWith.isEmpty() || tagName.startsWith(m_startsWith, Qt::CaseInsensitive) ) { //FIXME completion.text = tagName; completions->append(completion); completionMap[tagName] = completion; } } } //add the global entities QHash<QString, QTag*> *globalEntities = DTDs::ref()->globalEntities(); QHashIterator<QString, QTag*> itGlobal(*globalEntities); while (itGlobal.hasNext()) { itGlobal.next(); QTag *tag = itGlobal.value(); if (tag->type == "entity") { QString tagName = tag->name(); if (!completionMap.contains(tagName) && (m_startsWith.isEmpty() || tagName.startsWith(m_startsWith, Qt::CaseInsensitive))) { //FIXME completion.text = tagName; completions->append(completion); completionMap[tagName] = completion; } } } QList<KTextEditor::CompletionItem> *completions2 = new QList<KTextEditor::CompletionItem>(); QMap<QString, KTextEditor::CompletionItem>::ConstIterator end(completionMap.constEnd()); for (QMap<QString, KTextEditor::CompletionItem>::ConstIterator it = completionMap.constBegin(); it != end; ++it) { completions2->append(it.value()); } delete completions; completions = completions2; return completions; }
bool HTMLEnhancer::enhanceNode(Node *node, DOM::Node parentDNode, DOM::Node nextDNode) { DOM::Node domNode, domNode2, attr, *ptDomNode; bool tbody, goUp; Node *n; QString script, filename, text, oldName; KURL url, baseURL; int oldType; //FIRST update the src attr with the baseURL if(node->rootNode()) { domNode = node->rootNode()->attributes().getNamedItem("src"); if(!domNode.isNull()) { baseURL.setPath(ViewManager::ref()->activeDocument()->url().directory()); QuantaCommon::setUrl(url, domNode.nodeValue().string()); url = QExtFileInfo::toAbsolute(url, baseURL); domNode.setNodeValue(url.url()); #ifdef HEAVY_DEBUG kdDebug(25001)<< "HTMLTranslator::translateNode() - new src : " << url.url() << endl; #endif } } //THEN update the href attr of the LINK node with the baseURL if(node->tag->name.lower() == "link" && node->rootNode()) { domNode = node->rootNode()->attributes().getNamedItem("href"); if(!domNode.isNull()) { baseURL.setPath(ViewManager::ref()->activeDocument()->url().directory()); QuantaCommon::setUrl(url, domNode.nodeValue().string()); url = QExtFileInfo::toAbsolute(url, baseURL); domNode.setNodeValue(url.url()); #ifdef HEAVY_DEBUG kdDebug(25001)<< "HTMLTranslator::translateNode() - new href : " << url.url() << endl; #endif } } //THEN if it is the style element, add a DOM::Node::TEXT_NODE child gathering all the CSS //by default, the parser parse it as a script, which can't be translated in DOM::Nodes. if((node->tag->type == Tag::XmlTag && node->tag->name.lower() == "style") || (node->tag->type == Tag::ScriptTag && node->tag->name.lower().contains("style") != 0)) { //If the style Node doesn't exists, create it if(!node->rootNode()) { oldType = node->tag->type; node->tag->type = Tag::XmlTag; oldName = node->tag->name; node->tag->name = "style"; m_wkafkapart->buildKafkaNodeFromNode(node); node->tag->type = oldType; node->tag->name = oldName; } if(node->rootNode()) { domNode = *node->rootNode(); n = node->child; text = ""; goUp = false; while(n) { text += n->tag->tagStr(); n = kafkaCommon::getNextNode(n, goUp, node); } #ifdef HEAVY_DEBUG kdDebug(25001)<< "HTMLTranslator::translateNode() - CSS code : " << text << endl; #endif domNode2 = kafkaCommon::createTextDomNode(text, m_wkafkapart->getKafkaWidget()->document()); if(!kafkaCommon::insertDomNode(domNode2, domNode)) return false; m_wkafkapart->connectDomNodeToQuantaNode(domNode2, node); } } QTag* qTag = QuantaCommon::tagFromDTD(m_wkafkapart->getCurrentDoc()->defaultDTD(), parentDNode.nodeName().string()); //THEN replace, if asked, scripts by a little icon. if(node->tag->type == Tag::ScriptTag && m_showIconForScripts && qTag->isChild("IMG", false)) { script = node->tag->name.left(node->tag->name.find("block", 0, false) - 1).lower(); #ifdef LIGHT_DEBUG kdDebug(25001)<< "HTMLTranslator::translateNode() - BLOCK:" << script << ":" << endl; #endif filename = m_stddirs->findResource("data", "kafkapart/pics/" + script + ".png" ); if(!filename.isEmpty()) { //FIXME DTD! domNode = kafkaCommon::createDomNode("IMG", m_wkafkapart->defaultDTD(), m_wkafkapart->getKafkaWidget()->document()); kafkaCommon::editDomNodeAttribute(domNode, "IMG", m_wkafkapart->defaultDTD(), "src", filename, m_wkafkapart->getKafkaWidget()->document()); //Add a tooltip indicating the content of the script n = node->child; text = ""; goUp = false; while(n && n != node) { text += n->tag->tagStr(); n = kafkaCommon::getNextNode(n, goUp, node); } //if(text == "") // text = i18n("Empty") kafkaCommon::editDomNodeAttribute(domNode, "img", m_wkafkapart->defaultDTD(), "title", text, m_wkafkapart->getKafkaWidget()->document()); if(!kafkaCommon::insertDomNode(domNode, parentDNode, nextDNode)) return false; m_wkafkapart->connectDomNodeToQuantaNode(domNode, node); } } //THEN if it is a comment, add a little icon ;o) if(node->tag->type == Tag::Comment && m_showIconForScripts && qTag->isChild("IMG", false)) { #ifdef LIGHT_DEBUG kdDebug(25001)<< "HTMLTranslator::translateNode() - Comment" << endl; #endif filename = m_stddirs->findResource("data", "kafkapart/pics/comment.png" ); if(!filename.isEmpty()) { //FIXME DTD! domNode = kafkaCommon::createDomNode("IMG", m_wkafkapart->defaultDTD(), m_wkafkapart->getKafkaWidget()->document()); kafkaCommon::editDomNodeAttribute(domNode, "IMG", m_wkafkapart->defaultDTD(), "src", filename, m_wkafkapart->getKafkaWidget()->document()); //Add a tooltip indicating the content of the script n = node->child; text = ""; goUp = false; while(n && n != node) { text += n->tag->tagStr(); n = kafkaCommon::getNextNode(n, goUp, node); } //if(text == "") // text = i18n("Empty") kafkaCommon::editDomNodeAttribute(domNode, "img", m_wkafkapart->defaultDTD(), "title", text, m_wkafkapart->getKafkaWidget()->document()); if(!kafkaCommon::insertDomNode(domNode, parentDNode, nextDNode)) return false; m_wkafkapart->connectDomNodeToQuantaNode(domNode, node); } } //THEN add a TBODY tag if necessary if(node->rootNode() && node->rootNode()->nodeName().string().lower() == "table") { tbody = false; n = node->child; while(n) { if(n->tag->name.lower() == "tbody") tbody = true; n = n->next; } if(!tbody) { domNode = kafkaCommon::createDomNode("TBODY", m_wkafkapart->defaultDTD(), m_wkafkapart->getKafkaWidget()->htmlDocument()); if(!kafkaCommon::insertDomNode(domNode, *node->rootNode())) return false; m_wkafkapart->connectDomNodeToQuantaNode(domNode, node); ptDomNode = new DOM::Node(domNode); node->setLeafNode(ptDomNode); } } //THEN add a red dotted border to FORM tags. if(node->rootNode() && node->rootNode()->nodeName().string().lower() == "form") { kafkaCommon::editDomNodeAttribute(*node->rootNode(), node, "style", "border: 1px dotted red", m_wkafkapart->getKafkaWidget()->document()); } // THEN add a tooltip indicating the content of the name attribute if(node->rootNode() && node->rootNode()->nodeName().string().lower() == "input") { domNode = *(node->rootNode()); QString text = node->tag->attributeValue("name"); kafkaCommon::editDomNodeAttribute(domNode, "input", m_wkafkapart->defaultDTD(), "title", text, m_wkafkapart->getKafkaWidget()->document()); } //THEN add a blue dotted border to DL, OL, UL tags if(node->rootNode()) { text = node->rootNode()->nodeName().string().lower(); if(text == "dl" || text == "ol" || text == "ul") { kafkaCommon::editDomNodeAttribute(*node->rootNode(), node, "style", "border: 1px dotted blue", m_wkafkapart->getKafkaWidget()->document()); } } //THEN add a minimal border for borderless tables //TODO: make it configurable, and look if CSS hasn't defined a border first if(node->rootNode() && node->rootNode()->nodeName().string().lower() == "table") { attr = node->rootNode()->attributes().getNamedItem("border"); if(attr.isNull() || (!attr.isNull() && attr.nodeValue().string() == "0")) { kafkaCommon::editDomNodeAttribute(*node->rootNode(), node, "border", "1", m_wkafkapart->getKafkaWidget()->document()); } } //THEN add a blue dotted border to DIV tags if(node->rootNode()) { text = node->rootNode()->nodeName().string().lower(); if(text == "div") { kafkaCommon::editDomNodeAttribute(*node->rootNode(), node, "style", "border: 1px dotted green", m_wkafkapart->getKafkaWidget()->document()); } } return true; }
void HTMLEnhancer::postEnhanceNode(DOM::Node domNode) { DOM::Node textNode; kNodeAttrs *props; QTag *qTag; bool isInline; if(domNode.isNull()) return; //If domNode is a Block and there is no text around, and if domNode's parent can handle //text or a P tag, add an empty text DOM::Node // so that the user can access this area. qTag = QuantaCommon::tagFromDTD(m_wkafkapart->getCurrentDoc()->defaultDTD(), domNode.nodeName().string()); isInline = kafkaCommon::isInline(domNode.nodeName().string()); if(domNode.nodeType() == DOM::Node::ELEMENT_NODE && (!isInline || (isInline && qTag && qTag->isSingle()))) { qTag = QuantaCommon::tagFromDTD(m_wkafkapart->getNode(domNode.parentNode())); if((domNode.nextSibling().isNull() || (!domNode.nextSibling().isNull() && domNode.nextSibling().nodeType() == DOM::Node::ELEMENT_NODE && !kafkaCommon::isInline(domNode.nextSibling().nodeName().string()))) && qTag && (qTag->isChild("#text", false) || qTag->isChild("p", false)) && domNode.nodeName().string().lower() != "p") { textNode = kafkaCommon::createTextDomNode("", m_wkafkapart->getKafkaWidget()->document()); props = m_wkafkapart->connectDomNodeToQuantaNode(textNode, 0L); props->setIsLinkedToNode(false); props->setSpecialBehavior(kNodeAttrs::emptyTextSurroundingBlockElementAtTheRight); kafkaCommon::insertDomNode(textNode, domNode.parentNode(), domNode.nextSibling()); } if((domNode.previousSibling().isNull() || (!domNode.previousSibling().isNull() && domNode.previousSibling().nodeType() == DOM::Node::ELEMENT_NODE && !kafkaCommon::isInline(domNode.previousSibling().nodeName().string()))) && qTag && (qTag->isChild("#text", false) || qTag->isChild("p", false)) && domNode.nodeName().string().lower() != "p") { textNode = kafkaCommon::createTextDomNode("", m_wkafkapart->getKafkaWidget()->document()); props = m_wkafkapart->connectDomNodeToQuantaNode(textNode, 0L); props->setIsLinkedToNode(false); props->setSpecialBehavior(kNodeAttrs::emptyTextSurroundingBlockElementAtTheLeft); kafkaCommon::insertDomNode(textNode, domNode.parentNode(), domNode); } } //If domNode is an childless element, and if it can handle Text or a P tag, //add an empty text DOM::Node so that the //user can access this area. qTag = QuantaCommon::tagFromDTD(m_wkafkapart->getNode(domNode)); if(domNode.nodeType() == DOM::Node::ELEMENT_NODE && !domNode.hasChildNodes() && qTag && (qTag->isChild("#text", false) || qTag->isChild("p", false))) { textNode = kafkaCommon::createTextDomNode("", m_wkafkapart->getKafkaWidget()->document()); props = m_wkafkapart->connectDomNodeToQuantaNode(textNode, 0L); props->setIsLinkedToNode(false); props->setSpecialBehavior(kNodeAttrs::emptyTextAsChildOfAChildlessElement); kafkaCommon::insertDomNode(textNode, domNode); } }
void TagImgDlg::initDialog(){ QGridLayout *grid = new QGridLayout( this ); grid->setSpacing( 13 ); grid->setMargin( 11 ); labelImgSource= new QLabel(this,"labelImgSource"); labelImgSource->setText(i18n("Image source:")); grid->addMultiCellWidget(labelImgSource, 0, 0, 0, 0); lineImgSource= new KLineEdit(this,"lineImgSource"); grid->addMultiCellWidget(lineImgSource, 0, 0, 1, 3); buttonImgSource= new QPushButton(this,"NoName"); buttonImgSource->setText(i18n("...")); grid->addMultiCellWidget(buttonImgSource, 0, 0, 4, 4); QTag *imgTag = m_dtd->tagsList->find("img"); if (!imgTag) return; lineWidth = 0L; if (imgTag->attribute("width")) { QLabel_4= new QLabel(this,"NoName"); QLabel_4->setText(i18n("Width:")); grid->addMultiCellWidget(QLabel_4, 1, 1, 0, 0); lineWidth= new KLineEdit(this,"NoName"); lineWidth->setValidator( new KFloatValidator( lineWidth ) ); grid->addMultiCellWidget(lineWidth, 1, 1, 1, 1); } lineHeight = 0L; if (imgTag->attribute("height")) { QLabel_5= new QLabel(this,"NoName"); QLabel_5->setText(i18n("Height:")); grid->addMultiCellWidget(QLabel_5, 1, 1, 2, 2); lineHeight= new KLineEdit(this,"NoName"); lineHeight->setValidator( new KFloatValidator( lineHeight ) ); grid->addMultiCellWidget(lineHeight, 1, 1, 3, 3); } buttonRecalcImgSize= new QPushButton(this,"NoName"); buttonRecalcImgSize->setText(i18n("...")); grid->addMultiCellWidget(buttonRecalcImgSize, 1, 1, 4, 4); lineHSpace = 0L; if (imgTag->attribute("hspace")) { QLabel_6= new QLabel(this,"NoName"); QLabel_6->setText(i18n("HSpace:")); grid->addMultiCellWidget(QLabel_6, 2, 2, 0, 0); lineHSpace= new KLineEdit(this,"NoName"); grid->addMultiCellWidget(lineHSpace, 2, 2, 1, 1); } lineVSpace = 0L; if (imgTag->attribute("vspace")) { QLabel_7= new QLabel(this,"NoName"); QLabel_7->setText(i18n("VSpace:")); grid->addMultiCellWidget(QLabel_7, 2, 2, 2, 2); lineVSpace= new KLineEdit(this,"NoName"); grid->addMultiCellWidget(lineVSpace, 2, 2, 3, 3); } QLabel_8= new QLabel(this,"NoName"); QLabel_8->setText(i18n("Alternate text:")); grid->addMultiCellWidget(QLabel_8, 3, 3, 0, 0); lineAltText= new KLineEdit(this,"NoName"); grid->addMultiCellWidget(lineAltText, 3, 3, 1, 4); spinBorder = 0L; if (imgTag->attribute("border")) { QLabel_9= new QLabel(this,"NoName"); QLabel_9->setText(i18n("Border:")); grid->addMultiCellWidget(QLabel_9, 4, 4, 0, 0); spinBorder= new QSpinBox(this,"NoName"); spinBorder->setRange(0,20); grid->addMultiCellWidget(spinBorder, 4, 4, 1, 1); } comboAlign = 0L; if (imgTag->attribute("align")) { QLabel_10= new QLabel(this,"NoName"); QLabel_10->setText(i18n("Align:")); grid->addMultiCellWidget(QLabel_10, 4, 4, 2, 2); comboAlign= new QComboBox(this,"NoName"); grid->addMultiCellWidget(comboAlign, 4, 4, 3, 4); comboAlign->insertStringList(imgTag->attribute("align")->values); } widgetImg= new PictureView(this); grid->addMultiCellWidget(widgetImg, 5, 10, 0, 4); buttonImgSource->setPixmap( SmallIcon("fileopen") ); buttonRecalcImgSize->setPixmap( SmallIcon("reload") ); }