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

void QAbstractFormBuilder::loadTableWidgetExtraInfo ( DomWidget *  ui_widget,
QTableWidget tableWidget,
QWidget parentWidget 
) [protected, inherited]

For internal use only.

Definition at line 2097 of file abstractformbuilder.cpp.

References QList< T >::at(), QList< T >::count(), QAbstractFormBuilder::nameToIcon(), QAbstractFormBuilder::propertyMap(), QTableWidget::setColumnCount(), QTableWidget::setHorizontalHeaderItem(), QTableWidgetItem::setIcon(), QTableWidget::setItem(), QTableWidget::setRowCount(), QTableWidgetItem::setText(), QTableWidget::setVerticalHeaderItem(), and QHash< Key, T >::value().

Referenced by QAbstractFormBuilder::loadExtraInfo().

{
    Q_UNUSED(parentWidget);

    QList<DomColumn*> columns = ui_widget->elementColumn();
    tableWidget->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 || picon) {
            QTableWidgetItem *item = new QTableWidgetItem;
            if (ptext != 0 && ptext->elementString()) {
                item->setText(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();

                item->setIcon(nameToIcon(iconPath, qrcPath));
            }
            tableWidget->setHorizontalHeaderItem(i, item);
        }
    }

    QList<DomRow*> rows = ui_widget->elementRow();
    tableWidget->setRowCount(rows.count());
    for (int i = 0; i< rows.count(); i++) {
        DomRow *r = rows.at(i);
        QHash<QString, DomProperty*> properties = propertyMap(r->elementProperty());

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

        if (ptext || picon) {
            QTableWidgetItem *item = new QTableWidgetItem;
            if (ptext != 0 && ptext->elementString()) {
                item->setText(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();

                item->setIcon(nameToIcon(iconPath, qrcPath));
            }
            tableWidget->setVerticalHeaderItem(i, item);
        }
    }

    foreach (DomItem *ui_item, ui_widget->elementItem()) {
        if (ui_item->hasAttributeRow() && ui_item->hasAttributeColumn()) {
            QTableWidgetItem *item = new QTableWidgetItem;
            foreach (DomProperty *property, ui_item->elementProperty()) {
                if (property->attributeName() == QLatin1String("text") &&
                        property->elementString()) {
                    item->setText(property->elementString()->text());
                } else if (property->attributeName() == QLatin1String("icon") &&
                        property->kind() == DomProperty::IconSet) {
                    DomResourcePixmap *icon = property->elementIconSet();
                    Q_ASSERT(icon != 0);
                    QString iconPath = icon->text();
                    QString qrcPath = icon->attributeResource();

                    item->setIcon(nameToIcon(iconPath, qrcPath));
                }

            }
            tableWidget->setItem(ui_item->attributeRow(), ui_item->attributeColumn(), item);
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index