当前位置: 首页>>代码示例>>C++>>正文


C++ DomItem类代码示例

本文整理汇总了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();
    }
}
开发者ID:DMachuca,项目名称:SGEMS-UQ,代码行数:32,代码来源:metricdommodel.cpp

示例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;
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:27,代码来源:q3listbox_extrainfo.cpp

示例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;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:25,代码来源:q3listview_extrainfo.cpp

示例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);
        }
    }
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:31,代码来源:q3listview_extrainfo.cpp

示例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();
    }
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:32,代码来源:dommodel.cpp

示例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();
    }
}
开发者ID:adaptee,项目名称:qterm-hack,代码行数:30,代码来源:dommodel.cpp

示例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();
}
开发者ID:mluscon,项目名称:KDE-Usability-Inspector,代码行数:10,代码来源:KUI_project.cpp

示例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();
}
开发者ID:Dinesh-Ramakrishnan,项目名称:freemedforms,代码行数:11,代码来源:qabstractxmltreemodel.cpp

示例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();
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:11,代码来源:dommodel.cpp

示例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();
}
开发者ID:Dinesh-Ramakrishnan,项目名称:freemedforms,代码行数:12,代码来源:qabstractxmltreemodel.cpp

示例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);
        }
    }
}
开发者ID:superliujian,项目名称:ICD_Creator,代码行数:12,代码来源:undoinsertcommand.cpp

示例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);
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:14,代码来源:dommodel.cpp

示例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;
}
开发者ID:adaptee,项目名称:qterm-hack,代码行数:51,代码来源:dommodel.cpp

示例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();
}
开发者ID:mluscon,项目名称:KDE-Usability-Inspector,代码行数:14,代码来源:KUI_project.cpp

示例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();
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:15,代码来源:dommodel.cpp


注:本文中的DomItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。