Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void QAbstractFormBuilder::loadTreeWidgetExtraInfo ( DomWidget *  ui_widget,
QTreeWidget treeWidget,
QWidget parentWidget 
) [protected, inherited]

For internal use only.

Definition at line 2025 of file abstractformbuilder.cpp.

References QList< T >::at(), QList< T >::count(), QQueue< T >::dequeue(), QQueue< T >::enqueue(), QTreeWidget::headerItem(), QList< T >::isEmpty(), QAbstractFormBuilder::nameToIcon(), QAbstractFormBuilder::propertyMap(), QTreeWidget::setColumnCount(), QTreeWidgetItem::setIcon(), QTreeWidgetItem::setText(), and QHash< Key, T >::value().

Referenced by QAbstractFormBuilder::loadExtraInfo().

{
    Q_UNUSED(parentWidget);

    QList<DomColumn*> columns = ui_widget->elementColumn();

    treeWidget->setColumnCount(columns.count());

    for (int i = 0; i<columns.count(); ++i) {
        DomColumn *c = columns.at(i);
        QHash<QString, DomProperty*> properties = propertyMap(c->elementProperty());

        DomProperty *ptext = properties.value(QLatin1String("text"));
        DomProperty *picon = properties.value(QLatin1String("icon"));

        if (ptext != 0 && ptext->elementString())
            treeWidget->headerItem()->setText(i, ptext->elementString()->text());

        if (picon && picon->kind() == DomProperty::IconSet) {
            DomResourcePixmap *icon = picon->elementIconSet();
            Q_ASSERT(icon != 0);
            QString iconPath = icon->text();
            QString qrcPath = icon->attributeResource();

            treeWidget->headerItem()->setIcon(i, nameToIcon(iconPath, qrcPath));
        }
    }

    QQueue<QPair<DomItem *, QTreeWidgetItem *> > pendingQueue;
    foreach (DomItem *ui_item, ui_widget->elementItem())
        pendingQueue.enqueue(qMakePair(ui_item, (QTreeWidgetItem *)0));

    while (!pendingQueue.isEmpty()) {
        QPair<DomItem *, QTreeWidgetItem *> pair = pendingQueue.dequeue();
        DomItem *domItem = pair.first;
        QTreeWidgetItem *parentItem = pair.second;

        QTreeWidgetItem *currentItem = 0;

        if (parentItem)
            currentItem = new QTreeWidgetItem(parentItem);
        else
            currentItem = new QTreeWidgetItem(treeWidget);

        QList<DomProperty *> properties = domItem->elementProperty();
        int col = 0;
        foreach (DomProperty *property, properties) {
            if (property->attributeName() == QLatin1String("text") &&
                        property->elementString()) {
                currentItem->setText(col, property->elementString()->text());
                col++;
            } else if (property->attributeName() == QLatin1String("icon") &&
                        property->kind() == DomProperty::IconSet && col > 0) {
                DomResourcePixmap *icon = property->elementIconSet();
                Q_ASSERT(icon != 0);
                QString iconPath = icon->text();
                QString qrcPath = icon->attributeResource();

                currentItem->setIcon(col - 1, nameToIcon(iconPath, qrcPath));
            }
        }


        foreach (DomItem *childItem, domItem->elementItem())
            pendingQueue.enqueue(qMakePair(childItem, currentItem));

    }
}


Generated by  Doxygen 1.6.0   Back to index