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*))); }
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") ); }