本文整理汇总了C++中DomItem类的典型用法代码示例。如果您正苦于以下问题:C++ DomItem类的具体用法?C++ DomItem怎么用?C++ DomItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVariant
QVariant MetricDomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
if( !attributeMap.contains("Type") ) {
return QVariant();
}
return attributeMap.namedItem("Type").nodeValue();
case 2:
if( !attributeMap.contains("Format") ) {
return QVariant();
}
return attributeMap.namedItem("Format").nodeValue();
default:
return QVariant();
}
}
示例2: Q_ASSERT
bool Q3ListBoxExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget)
{
Q3ListBox *listBox = qobject_cast<Q3ListBox*>(widget());
Q_ASSERT(listBox != 0);
QList<DomItem *> items;
const int childCount = listBox->count();
for (int i = 0; i < childCount; ++i) {
DomItem *item = new DomItem();
QList<DomProperty*> properties;
DomString *str = new DomString();
str->setText(listBox->text(i));
DomProperty *ptext = new DomProperty();
ptext->setAttributeName(QLatin1String("text"));
ptext->setElementString(str);
properties.append(ptext);
item->setElementProperty(properties);
items.append(item);
}
ui_widget->setElementItem(items);
return true;
}
示例3: DomItem
DomItem *Q3ListViewExtraInfo::saveQ3ListViewItem(Q3ListViewItem *item) const
{
DomItem *pitem = new DomItem();
QList<DomProperty *> properties;
const int columnCount = static_cast<Q3ListView*>(widget())->columns();
for (int i = 0; i < columnCount; ++i) {
DomString *str = new DomString();
str->setText(item->text(i));
DomProperty *ptext = new DomProperty();
ptext->setAttributeName(QLatin1String("text"));
ptext->setElementString(str);
properties.append(ptext);
}
pitem->setElementProperty(properties);
QList<DomItem *> items;
Q3ListViewItem *child = item->firstChild();
while (child) {
items.append(saveQ3ListViewItem(child));
child = child->nextSibling();
}
pitem->setElementItem(items);
return pitem;
}
示例4: pixmap
void Q3ListViewExtraInfo::initializeQ3ListViewItems(const QList<DomItem *> &items, Q3ListViewItem *parentItem)
{
for (int i=0; i<items.size(); ++i) {
DomItem *item = items.at(i);
Q3ListViewItem *__item = 0;
if (parentItem != 0)
__item = new Q3ListViewItem(parentItem);
else
__item = new Q3ListViewItem(static_cast<Q3ListView*>(widget()));
int textCount = 0, pixCount = 0;
QList<DomProperty*> properties = item->elementProperty();
for (int i=0; i<properties.size(); ++i) {
DomProperty *p = properties.at(i);
if (p->attributeName() == QLatin1String("text"))
__item->setText(textCount++, p->elementString()->text());
if (p->attributeName() == QLatin1String("pixmap")) {
DomResourcePixmap *pix = p->elementPixmap();
QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory()));
__item->setPixmap(pixCount++, pixmap);
}
}
if (item->elementItem().size()) {
__item->setOpen(true);
initializeQ3ListViewItems(item->elementItem(), __item);
}
}
}
示例5: QVariant
//! [3]
QVariant DomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
//! [3] //! [4]
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\""
+attribute.nodeValue() + "\"";
}
return attributes.join(" ");
case 2:
return node.nodeValue().split("\n").join(" ");
default:
return QVariant();
}
}
示例6: QVariant
QVariant DomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
switch (role) {
case Qt::UserRole:
if (item->isFolder()) {
return item->name();
} else {
return item->uuid();
}
break;
case Qt::DisplayRole:
return item->name();
break;
case Qt::DecorationRole:
switch (type(index)) {
case Folder:
return QVariant(QIcon(":/pic/folder.png"));
case Favorite:
return QVariant(QIcon(":/pic/folder_favorite.png"));
case Site:
return QVariant(QIcon(":/pic/tabpad.png"));
}
default:
return QVariant();
}
}
示例7: addSlot
void KUI_project::addSlot()
{
QModelIndex sessionIndex = model->index(0, 0,QModelIndex());
DomItem *sessionItem = static_cast<DomItem*> ( sessionIndex.internalPointer() );
qDebug() << sessionItem->node().nodeName();
model->insertRows(0,1, sessionIndex);
usersList->update();
}
示例8: rowCount
int QAbstractXmlTreeModel::rowCount(const QModelIndex &parent) const
{
DomItem *item = 0;
if (!parent.isValid())
item = dqaxtm->m_RootItem;
else
item = static_cast<DomItem*>(parent.internalPointer());
return item->node().childNodes().count();
}
示例9: rowCount
int DomModel::rowCount(const QModelIndex &parent) const
{
DomItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<DomItem*>(parent.internalPointer());
return parentItem->node().childNodes().count();
}
示例10: node
QDomNode QAbstractXmlTreeModel::node(const QModelIndex &index) const
{
if (!index.isValid())
return dqaxtm->m_RootNode;
DomItem *domItem = static_cast<DomItem*>(index.internalPointer());
if (!domItem)
return dqaxtm->m_RootNode;
return domItem->node();
}
示例11: UndoBaseChangeElement
UndoInsertCommand::UndoInsertCommand(QTreeWidget *theWidget, DomModel *newRegola, QList<int> newPath) : UndoBaseChangeElement(theWidget, newRegola, newPath)
{
DomItem *selElement = regola->findItemByArray(path);
if(NULL != selElement) {
// copy data
_element = new DomItem(NULL);
if(NULL != _element) {
// full copy
selElement->copyTo(*_element);
}
}
}
示例12: QModelIndex
//! [9]
QModelIndex DomModel::parent(const QModelIndex &child) const
{
if (!child.isValid())
return QModelIndex();
DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
DomItem *parentItem = childItem->parent();
if (!parentItem || parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
}
示例13: if
bool DomModel::dropMimeData(const QMimeData *data,
Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
return true;
if (!data->hasFormat("text/plain"))
return false;
// Find out after which row to insert
int beginRow;
if (row != -1) // given
beginRow = row;
else if (parent.isValid()) // 1st of parent item
beginRow = 0;
else // last of the root item
beginRow = rowCount(QModelIndex());
DomItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<DomItem*>(parent.internalPointer());
// Extract dropped items
QByteArray encodedData = data->data("text/plain");
QDataStream stream(&encodedData, QIODevice::ReadOnly);
QList<DomItem*> newItems;
while (!stream.atEnd()) {
quintptr p;
stream >> p;
newItems << static_cast<DomItem*>((void *)p);
}
int count = newItems.count();
switch(action) {
case Qt::MoveAction:
if (parentItem == rootItem)
return false;
for (int i=0; i<count; i++) {
DomItem *item = newItems.at(i);
QDomElement node = item->element().cloneNode().toElement();
DomItem *newItem = new DomItem(node);
insertRow(beginRow, parent, newItem);
}
break;
default:
return false;
}
return true;
}
示例14: removeSlot
void KUI_project::removeSlot()
{
QModelIndex current = usersList->selectionModel()->currentIndex();
DomItem *item = static_cast<DomItem*>( current.internalPointer() );
if ( current.isValid() && item->node().nodeName()=="user" ) {
qDebug() << "Removing: " << item->node().nodeName();
model->removeRows( current.row(), 1, current.parent() );
}
usersList->update();
}
示例15: index
QModelIndex DomModel::index(int row, int column, const QModelIndex &parent) const
{
DomItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<DomItem*>(parent.internalPointer());
DomItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}