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

void QAbstractFormBuilder::saveTreeWidgetExtraInfo ( QTreeWidget treeWidget,
DomWidget *  ui_widget,
DomWidget *  ui_parentWidget 
) [protected, inherited]

For internal use only.

Definition at line 1634 of file abstractformbuilder.cpp.

References QList< T >::append(), QTreeWidgetItem::child(), QTreeWidgetItem::childCount(), QTreeWidget::columnCount, QQueue< T >::dequeue(), QQueue< T >::enqueue(), QTreeWidget::headerItem(), QTreeWidgetItem::icon(), QAbstractFormBuilder::iconToFilePath(), QAbstractFormBuilder::iconToQrcPath(), QList< T >::isEmpty(), QString::isEmpty(), QIcon::isNull(), QTreeWidgetItem::text(), QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount.

Referenced by QAbstractFormBuilder::saveExtraInfo().

{
    Q_UNUSED(ui_parentWidget);

    QList<DomColumn*> columns;

    // save the header
    for (int c = 0; c<treeWidget->columnCount(); ++c) {
        DomColumn *column = new DomColumn;

        QList<DomProperty*> properties;

        // property text
        DomProperty *ptext = new DomProperty;
        DomString *str = new DomString;
        str->setText(treeWidget->headerItem()->text(c));
        ptext->setAttributeName(QLatin1String("text"));
        ptext->setElementString(str);
        properties.append(ptext);

        QIcon icon = treeWidget->headerItem()->icon(c);
        if (!icon.isNull()) {
            QString iconPath = iconToFilePath(icon);
            QString qrcPath = iconToQrcPath(icon);

            DomProperty *p = new DomProperty;

            DomResourcePixmap *pix = new DomResourcePixmap;
            if (!qrcPath.isEmpty())
                pix->setAttributeResource(qrcPath);

            pix->setText(iconPath);

            p->setAttributeName(QLatin1String("icon"));
            p->setElementIconSet(pix);

            properties.append(p);
        }

        column->setElementProperty(properties);
        columns.append(column);
    }

    ui_widget->setElementColumn(columns);

    QList<DomItem *> items = ui_widget->elementItem();

    QQueue<QPair<QTreeWidgetItem *, DomItem *> > pendingQueue;
    for (int i = 0; i < treeWidget->topLevelItemCount(); i++)
        pendingQueue.enqueue(qMakePair(treeWidget->topLevelItem(i), (DomItem *)0));

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

        DomItem *currentDomItem = new DomItem;

        QList<DomProperty*> properties;
        for (int c = 0; c < treeWidget->columnCount(); c++) {
            DomProperty *ptext = new DomProperty;
            DomString *str = new DomString;
            str->setText(item->text(c));
            ptext->setAttributeName(QLatin1String("text"));
            ptext->setElementString(str);
            properties.append(ptext);

            QIcon icon = item->icon(c);
            if (!icon.isNull()) {
                QString iconPath = iconToFilePath(icon);
                QString qrcPath = iconToQrcPath(icon);

                DomProperty *p = new DomProperty;

                DomResourcePixmap *pix = new DomResourcePixmap;
                if (!qrcPath.isEmpty())
                    pix->setAttributeResource(qrcPath);

                pix->setText(iconPath);

                p->setAttributeName(QLatin1String("icon"));
                p->setElementIconSet(pix);

                properties.append(p);
            }

        }
        currentDomItem->setElementProperty(properties);

        if (parentDomItem) {
            QList<DomItem *> childrenItems = parentDomItem->elementItem();
            childrenItems.append(currentDomItem);
            parentDomItem->setElementItem(childrenItems);
        } else
            items.append(currentDomItem);

        for (int i = 0; i < item->childCount(); i++)
            pendingQueue.enqueue(qMakePair(item->child(i), currentDomItem));
    }

    ui_widget->setElementItem(items);
}


Generated by  Doxygen 1.6.0   Back to index