#include <abstractformbuilder.h>
Inheritance diagram for QAbstractFormBuilder:


QtDesigner
QAbstractFormBuilder provides a standard interface and a default implementation for constructing forms from user interface files. It is not intended to be instantiated directly. Use the QFormBuilder class to create user interfaces from {.ui} files at run-time. For example:
MyForm::MyForm(QWidget *parent) : QWidget(parent) { QFormBuilder builder; QFile file(":/forms/myWidget.ui"); file.open(QFile::ReadOnly); QWidget *myWidget = builder.load(&file, this); file.close(); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(myWidget); setLayout(layout); }
To override certain aspects of the form builder's behavior, subclass QAbstractFormBuilder and reimplement the relevant virtual functions:
load() handles reading of {.ui} format files from arbitrary QIODevices, and construction of widgets from the XML data that they contain. save() handles saving of widget details in {.ui} format to arbitrary QIODevices. workingDirectory() and setWorkingDirectory() control the directory in which forms are held. The form builder looks for other resources on paths relative to this directory.
The QFormBuilder class is typically used by custom components and applications that embed . Standalone applications that need to dynamically generate user interfaces at run-time use the QUiLoader, found in the QtUiTools module.
Definition at line 80 of file abstractformbuilder.h.
| QAbstractFormBuilder::QAbstractFormBuilder | ( | ) |
Constructs a new form builder.
Definition at line 163 of file abstractformbuilder.cpp.
References m_defaultMargin, and m_defaultSpacing.
00164 { 00165 m_defaultMargin = INT_MIN; 00166 m_defaultSpacing = INT_MIN; 00167 }
| QAbstractFormBuilder::~QAbstractFormBuilder | ( | ) | [virtual] |
| QAbstractFormBuilder::QAbstractFormBuilder | ( | const QAbstractFormBuilder & | other | ) | [private] |
| QDir QAbstractFormBuilder::workingDirectory | ( | ) | const |
Returns the current working directory of the form builder.
Definition at line 2530 of file abstractformbuilder.cpp.
References m_workingDirectory.
Referenced by qdesigner_internal::QDesignerResource::createIconProperty(), createProperty(), qdesigner_internal::QSimpleResource::iconToFilePath(), qdesigner_internal::QSimpleResource::iconToQrcPath(), qdesigner_internal::QDesignerFormBuilder::nameToIcon(), nameToIcon(), qdesigner_internal::QSimpleResource::nameToIcon(), qdesigner_internal::QDesignerFormBuilder::nameToPixmap(), nameToPixmap(), qdesigner_internal::QSimpleResource::nameToPixmap(), qdesigner_internal::QSimpleResource::pixmapToFilePath(), qdesigner_internal::QSimpleResource::pixmapToQrcPath(), and toVariant().
02531 { 02532 return m_workingDirectory; 02533 }
| void QAbstractFormBuilder::setWorkingDirectory | ( | const QDir & | directory | ) |
Sets the current working directory of the form builder to the specified directory.
Definition at line 2540 of file abstractformbuilder.cpp.
References m_workingDirectory.
Referenced by QDesignerActions::previewForm(), qdesigner_internal::QDesignerResource::QDesignerResource(), and qdesigner_internal::QSimpleResource::QSimpleResource().
02541 { 02542 m_workingDirectory = directory; 02543 }
Loads an XML representation of a widget from the given device, and constructs a new widget with the specified parent.
### check the result
Definition at line 183 of file abstractformbuilder.cpp.
References create(), QDomNode::firstChild(), DomUI::read(), QDomDocument::setContent(), and QDomNode::toElement().
Referenced by qdesigner_internal::QDesignerResource::create(), qdesigner_internal::QDesignerFormBuilder::createWidgetFromContents(), QDesignerActions::previewForm(), and qdesigner_internal::FormWindow::setContents().
00184 { 00185 QDomDocument doc; 00186 if (!doc.setContent(dev)) 00187 return 0; 00188 00189 QDomElement root = doc.firstChild().toElement(); 00190 DomUI ui; 00191 ui.read(root); 00192 00193 return create(&ui, parentWidget); 00194 }
Here is the call graph for this function:

Saves an XML representation of the given widget to the specified device in the standard {.ui} file format.
Definition at line 1160 of file abstractformbuilder.cpp.
References QDomNode::appendChild(), QHash< Key, T >::clear(), createDom(), m_laidout, saveDom(), DomUI::setAttributeVersion(), DomUI::setElementWidget(), QByteArray::size(), QDomDocument::toString(), QString::toUtf8(), QIODevice::write(), and DomUI::write().
Referenced by qdesigner_internal::QDesignerResource::save().
01161 { 01162 DomWidget *ui_widget = createDom(widget, 0); 01163 Q_ASSERT( ui_widget != 0 ); 01164 01165 DomUI *ui = new DomUI(); 01166 ui->setAttributeVersion(QLatin1String("4.0")); 01167 ui->setElementWidget(ui_widget); 01168 01169 saveDom(ui, widget); 01170 01171 QDomDocument doc; 01172 doc.appendChild(ui->write(doc)); 01173 QByteArray bytes = doc.toString().toUtf8(); 01174 dev->write(bytes, bytes.size()); 01175 01176 m_laidout.clear(); 01177 01178 delete ui; 01179 }
Here is the call graph for this function:

| void QAbstractFormBuilder::loadExtraInfo | ( | DomWidget * | ui_widget, | |
| QWidget * | widget, | |||
| QWidget * | parentWidget | |||
| ) | [protected, virtual] |
Definition at line 2444 of file abstractformbuilder.cpp.
References DomProperty::elementNumber(), DomWidget::elementProperty(), loadComboBoxExtraInfo(), loadListWidgetExtraInfo(), loadTableWidgetExtraInfo(), loadTreeWidgetExtraInfo(), propertyMap(), and value.
Referenced by create(), qdesigner_internal::QDesignerFormBuilder::loadExtraInfo(), and qdesigner_internal::QDesignerResource::loadExtraInfo().
02445 { 02446 if (QListWidget *listWidget = qobject_cast<QListWidget*>(widget)) { 02447 loadListWidgetExtraInfo(ui_widget, listWidget, parentWidget); 02448 } else if (QTreeWidget *treeWidget = qobject_cast<QTreeWidget*>(widget)) { 02449 loadTreeWidgetExtraInfo(ui_widget, treeWidget, parentWidget); 02450 } else if (QTableWidget *tableWidget = qobject_cast<QTableWidget*>(widget)) { 02451 loadTableWidgetExtraInfo(ui_widget, tableWidget, parentWidget); 02452 } else if (QComboBox *comboBox = qobject_cast<QComboBox*>(widget)) { 02453 if (!qobject_cast<QFontComboBox *>(widget)) 02454 loadComboBoxExtraInfo(ui_widget, comboBox, parentWidget); 02455 } else if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(widget)) { 02456 DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value("currentIndex"); 02457 if (currentIndex) 02458 tabWidget->setCurrentIndex(currentIndex->elementNumber()); 02459 } else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(widget)) { 02460 DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value("currentIndex"); 02461 if (currentIndex) 02462 stackedWidget->setCurrentIndex(currentIndex->elementNumber()); 02463 } else if (QToolBox *toolBox = qobject_cast<QToolBox*>(widget)) { 02464 DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value("currentIndex"); 02465 if (currentIndex) 02466 toolBox->setCurrentIndex(currentIndex->elementNumber()); 02467 } 02468 }
Here is the call graph for this function:

Definition at line 199 of file abstractformbuilder.cpp.
References applyTabStops(), createConnections(), createCustomWidgets(), createResources(), DomUI::elementConnections(), DomUI::elementCustomWidgets(), DomUI::elementLayoutDefault(), DomUI::elementResources(), DomUI::elementTabStops(), DomUI::elementWidget(), m_defaultMargin, m_defaultSpacing, and reset().
Referenced by create(), qdesigner_internal::QDesignerResource::create(), QFormBuilder::create(), and load().
00200 { 00201 if (DomLayoutDefault *def = ui->elementLayoutDefault()) { 00202 m_defaultMargin = def->hasAttributeMargin() ? def->attributeMargin() : INT_MIN; 00203 m_defaultSpacing = def->hasAttributeSpacing() ? def->attributeSpacing() : INT_MIN; 00204 } 00205 00206 DomWidget *ui_widget = ui->elementWidget(); 00207 if (!ui_widget) 00208 return 0; 00209 00210 createCustomWidgets(ui->elementCustomWidgets()); 00211 00212 if (QWidget *widget = create(ui_widget, parentWidget)) { 00213 createConnections(ui->elementConnections(), widget); 00214 createResources(ui->elementResources()); 00215 applyTabStops(widget, ui->elementTabStops()); 00216 reset(); 00217 00218 return widget; 00219 } 00220 00221 return 0; 00222 }
Here is the call graph for this function:

| QWidget * QAbstractFormBuilder::create | ( | DomWidget * | ui_widget, | |
| QWidget * | parentWidget | |||
| ) | [protected, virtual] |
Definition at line 227 of file abstractformbuilder.cpp.
References a, addItem(), addMenuAction(), applyProperties(), DomWidget::attributeClass(), DomWidget::attributeName(), DomActionRef::attributeName(), create(), createWidget(), DomWidget::elementAction(), DomWidget::elementActionGroup(), DomWidget::elementAddAction(), DomWidget::elementLayout(), DomWidget::elementProperty(), DomWidget::elementWidget(), g, loadExtraInfo(), m_actionGroups, m_actions, name, QAction::setSeparator(), QHash< Key, T >::value(), w, and Qt::WA_Moved.
00228 { 00229 QWidget *w = createWidget(ui_widget->attributeClass(), parentWidget, ui_widget->attributeName()); 00230 if (!w) 00231 return 0; 00232 00233 applyProperties(w, ui_widget->elementProperty()); 00234 00235 foreach (DomAction *ui_action, ui_widget->elementAction()) { 00236 QAction *child_action = create(ui_action, w); 00237 Q_UNUSED( child_action ); 00238 } 00239 00240 foreach (DomActionGroup *ui_action_group, ui_widget->elementActionGroup()) { 00241 QActionGroup *child_action_group = create(ui_action_group, w); 00242 Q_UNUSED( child_action_group ); 00243 } 00244 00245 foreach (DomWidget *ui_child, ui_widget->elementWidget()) { 00246 QWidget *child_w = create(ui_child, w); 00247 Q_UNUSED( child_w ); 00248 } 00249 00250 foreach (DomLayout *ui_lay, ui_widget->elementLayout()) { 00251 QLayout *child_lay = create(ui_lay, 0, w); 00252 Q_UNUSED( child_lay ); 00253 } 00254 00255 foreach (DomActionRef *ui_action_ref, ui_widget->elementAddAction()) { 00256 QString name = ui_action_ref->attributeName(); 00257 if (name == QLatin1String("separator")) { 00258 QAction *sep = new QAction(w); 00259 sep->setSeparator(true); 00260 w->addAction(sep); 00261 addMenuAction(sep); 00262 } else if (QAction *a = m_actions.value(name)) { 00263 w->addAction(a); 00264 } else if (QActionGroup *g = m_actionGroups.value(name)) { 00265 w->addActions(g->actions()); 00266 } else if (QMenu *menu = qFindChild<QMenu*>(w, name)) { 00267 w->addAction(menu->menuAction()); 00268 addMenuAction(menu->menuAction()); 00269 } 00270 } 00271 00272 loadExtraInfo(ui_widget, w, parentWidget); 00273 addItem(ui_widget, w, parentWidget); 00274 00275 if (qobject_cast<QDialog *>(w) && parentWidget) 00276 w->setAttribute(Qt::WA_Moved, false); // So that QDialog::setVisible(true) will center it 00277 00278 return w; 00279 }
Here is the call graph for this function:

| QLayout * QAbstractFormBuilder::create | ( | DomLayout * | ui_layout, | |
| QLayout * | layout, | |||
| QWidget * | parentWidget | |||
| ) | [protected, virtual] |
Definition at line 464 of file abstractformbuilder.cpp.
References addItem(), applyProperties(), DomLayout::attributeClass(), create(), createLayout(), DomLayout::elementItem(), DomLayout::elementProperty(), layout, QWidget::layout(), layoutInfo(), p, and spacing.
00465 { 00466 QObject *p = parentLayout; 00467 00468 if (p == 0) 00469 p = parentWidget; 00470 00471 Q_ASSERT(p != 0); 00472 00473 bool tracking = false; 00474 00475 if (p == parentWidget && parentWidget->layout()) { 00476 tracking = true; 00477 p = parentWidget->layout(); 00478 } 00479 00480 QLayout *layout = createLayout(ui_layout->attributeClass(), p, QString()); 00481 00482 if (layout == 0) 00483 return 0; 00484 00485 if (tracking && layout->parent() == 0) { 00486 QBoxLayout *box = qobject_cast<QBoxLayout*>(parentWidget->layout()); 00487 Q_ASSERT(box != 0); // only QBoxLayout is supported 00488 box->addLayout(layout); 00489 } 00490 00491 int margin = INT_MIN, spacing = INT_MIN; 00492 layoutInfo(ui_layout, p, &margin, &spacing); 00493 00494 if (margin != INT_MIN) 00495 layout->setMargin(margin); 00496 00497 if (spacing != INT_MIN) 00498 layout->setSpacing(spacing); 00499 00500 applyProperties(layout, ui_layout->elementProperty()); 00501 00502 foreach (DomLayoutItem *ui_item, ui_layout->elementItem()) { 00503 if (QLayoutItem *item = create(ui_item, layout, parentWidget)) { 00504 addItem(ui_item, item, layout); 00505 } 00506 } 00507 00508 return layout; 00509 }
Here is the call graph for this function:

| QLayoutItem * QAbstractFormBuilder::create | ( | DomLayoutItem * | ui_layoutItem, | |
| QLayout * | layout, | |||
| QWidget * | parentWidget | |||
| ) | [protected, virtual] |
Definition at line 541 of file abstractformbuilder.cpp.
References create(), DomLayoutItem::elementLayout(), DomSpacer::elementProperty(), DomLayoutItem::elementSpacer(), DomLayoutItem::elementWidget(), DomProperty::Enum, QSizePolicy::Expanding, QMetaEnum::keyToValue(), DomLayoutItem::kind(), DomLayoutItem::Layout, layout, QSizePolicy::Minimum, o, p, DomProperty::Size, size, DomLayoutItem::Spacer, toVariant(), Qt::Vertical, and DomLayoutItem::Widget.
00542 { 00543 switch (ui_layoutItem->kind()) { 00544 case DomLayoutItem::Widget: 00545 return new QWidgetItem(create(ui_layoutItem->elementWidget(), parentWidget)); 00546 00547 case DomLayoutItem::Spacer: { 00548 QSize size(0, 0); 00549 QSizePolicy::Policy sizeType = QSizePolicy::Expanding; 00550 bool isVspacer = false; 00551 00552 DomSpacer *ui_spacer = ui_layoutItem->elementSpacer(); 00553 00554 int e_index = QAbstractFormBuilderGadget::staticMetaObject.indexOfProperty("sizeType"); 00555 Q_ASSERT(e_index != -1); 00556 00557 QMetaEnum sizePolicy_enum = QAbstractFormBuilderGadget::staticMetaObject.property(e_index).enumerator(); 00558 00559 e_index = QAbstractFormBuilderGadget::staticMetaObject.indexOfProperty("orientation"); 00560 Q_ASSERT(e_index != -1); 00561 00562 QMetaEnum orientation_enum = QAbstractFormBuilderGadget::staticMetaObject.property(e_index).enumerator(); 00563 00564 foreach (DomProperty *p, ui_spacer->elementProperty()) { 00565 QVariant v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p); // ### remove me 00566 if (v.isNull()) 00567 continue; 00568 00569 if (p->attributeName() == QLatin1String("sizeHint") && p->kind() == DomProperty::Size) { 00570 size = v.toSize(); // ### remove me 00571 } else if (p->attributeName() == QLatin1String("sizeType") && p->kind() == DomProperty::Enum) { 00572 sizeType = static_cast<QSizePolicy::Policy>(sizePolicy_enum.keyToValue(p->elementEnum().toUtf8())); 00573 } else if (p->attributeName() == QLatin1String("orientation") && p->kind() == DomProperty::Enum) { 00574 Qt::Orientation o = static_cast<Qt::Orientation>(orientation_enum.keyToValue(p->elementEnum().toUtf8())); 00575 isVspacer = (o == Qt::Vertical); 00576 } 00577 } 00578 00579 QSpacerItem *spacer = 0; 00580 if (isVspacer) 00581 spacer = new QSpacerItem(size.width(), size.height(), QSizePolicy::Minimum, sizeType); 00582 else 00583 spacer = new QSpacerItem(size.width(), size.height(), sizeType, QSizePolicy::Minimum); 00584 return spacer; } 00585 00586 case DomLayoutItem::Layout: 00587 return create(ui_layoutItem->elementLayout(), layout, parentWidget); 00588 00589 default: 00590 break; 00591 } 00592 00593 return 0; 00594 }
Here is the call graph for this function:

| QAction * QAbstractFormBuilder::create | ( | DomAction * | ui_action, | |
| QObject * | parent | |||
| ) | [protected, virtual] |
Definition at line 284 of file abstractformbuilder.cpp.
References a, applyProperties(), DomAction::attributeName(), createAction(), and DomAction::elementProperty().
00285 { 00286 QAction *a = createAction(parent, ui_action->attributeName()); 00287 if (!a) 00288 return 0; 00289 00290 applyProperties(a, ui_action->elementProperty()); 00291 return a; 00292 }
Here is the call graph for this function:

| QActionGroup * QAbstractFormBuilder::create | ( | DomActionGroup * | ui_action_group, | |
| QObject * | parent | |||
| ) | [protected, virtual] |
Definition at line 297 of file abstractformbuilder.cpp.
References a, applyProperties(), DomActionGroup::attributeName(), create(), createActionGroup(), DomActionGroup::elementAction(), DomActionGroup::elementActionGroup(), DomActionGroup::elementProperty(), and g.
00298 { 00299 QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName()); 00300 if (!a) 00301 return 0; 00302 00303 applyProperties(a, ui_action_group->elementProperty()); 00304 00305 foreach (DomAction *ui_action, ui_action_group->elementAction()) { 00306 QAction *child_action = create(ui_action, a); 00307 Q_UNUSED( child_action ); 00308 } 00309 00310 foreach (DomActionGroup *g, ui_action_group->elementActionGroup()) { 00311 QActionGroup *child_action_group = create(g, parent); 00312 Q_UNUSED( child_action_group ); 00313 } 00314 00315 return a; 00316 }
Here is the call graph for this function:

| void QAbstractFormBuilder::addMenuAction | ( | QAction * | action | ) | [protected, virtual] |
| void QAbstractFormBuilder::applyProperties | ( | QObject * | o, | |
| const QList< DomProperty * > & | properties | |||
| ) | [protected, virtual] |
Definition at line 599 of file abstractformbuilder.cpp.
References QVariant::isNull(), o, p, properties, and toVariant().
Referenced by create().
00600 { 00601 foreach (DomProperty *p, properties) { 00602 QVariant v = toVariant(o->metaObject(), p); 00603 if (!v.isNull()) 00604 o->setProperty(p->attributeName().toUtf8(), v); 00605 } 00606 }
Here is the call graph for this function:

| void QAbstractFormBuilder::applyTabStops | ( | QWidget * | widget, | |
| DomTabStops * | tabStops | |||
| ) | [protected, virtual] |
Definition at line 1801 of file abstractformbuilder.cpp.
References DomTabStops::elementTabStop(), i, l, name, qWarning(), and QWidget::setTabOrder().
Referenced by create().
01802 { 01803 if (!tabStops) 01804 return; 01805 01806 QWidget *lastWidget = 0; 01807 01808 QStringList l = tabStops->elementTabStop(); 01809 for (int i=0; i<l.size(); ++i) { 01810 QString name = l.at(i); 01811 01812 QWidget *child = qFindChild<QWidget*>(widget, name); 01813 if (!child) { 01814 qWarning("'%s' isn't a valid widget\n", name.toUtf8().data()); 01815 continue; 01816 } 01817 01818 if (i == 0) { 01819 lastWidget = qFindChild<QWidget*>(widget, name); 01820 continue; 01821 } else if (!child || !lastWidget) { 01822 continue; 01823 } 01824 01825 QWidget::setTabOrder(lastWidget, child); 01826 01827 lastWidget = qFindChild<QWidget*>(widget, name); 01828 } 01829 }
Here is the call graph for this function:

| QWidget * QAbstractFormBuilder::createWidget | ( | const QString & | widgetName, | |
| QWidget * | parentWidget, | |||
| const QString & | name | |||
| ) | [protected, virtual] |
Definition at line 1110 of file abstractformbuilder.cpp.
References name.
Referenced by create().
01111 { 01112 Q_UNUSED(widgetName); 01113 Q_UNUSED(parentWidget); 01114 Q_UNUSED(name); 01115 return 0; 01116 }
| QLayout * QAbstractFormBuilder::createLayout | ( | const QString & | layoutName, | |
| QObject * | parent, | |||
| const QString & | name | |||
| ) | [protected, virtual] |
Definition at line 1121 of file abstractformbuilder.cpp.
References name.
Referenced by create().
01122 { 01123 Q_UNUSED(layoutName); 01124 Q_UNUSED(parent); 01125 Q_UNUSED(name); 01126 return 0; 01127 }
| QAction * QAbstractFormBuilder::createAction | ( | QObject * | parent, | |
| const QString & | name | |||
| ) | [protected, virtual] |
Definition at line 1132 of file abstractformbuilder.cpp.
References QHash< Key, T >::insert(), m_actions, name, and QObject::setObjectName().
Referenced by create(), and qdesigner_internal::QDesignerResource::createAction().
01133 { 01134 QAction *action = new QAction(parent); 01135 action->setObjectName(name); 01136 m_actions.insert(name, action); 01137 01138 return action; 01139 }
Here is the call graph for this function:

| QActionGroup * QAbstractFormBuilder::createActionGroup | ( | QObject * | parent, | |
| const QString & | name | |||
| ) | [protected, virtual] |
Definition at line 1144 of file abstractformbuilder.cpp.
References g, QHash< Key, T >::insert(), m_actionGroups, and name.
Referenced by create(), and qdesigner_internal::QDesignerResource::createActionGroup().
01145 { 01146 QActionGroup *g = new QActionGroup(parent); 01147 g->setObjectName(name); 01148 m_actionGroups.insert(name, g); 01149 01150 return g; 01151 }
Here is the call graph for this function:

| void QAbstractFormBuilder::createCustomWidgets | ( | DomCustomWidgets * | ) | [inline, protected, virtual] |
| void QAbstractFormBuilder::createConnections | ( | DomConnections * | , | |
| QWidget * | ||||
| ) | [inline, protected, virtual] |
| void QAbstractFormBuilder::createResources | ( | DomResources * | ) | [inline, protected, virtual] |
| bool QAbstractFormBuilder::addItem | ( | DomLayoutItem * | ui_item, | |
| QLayoutItem * | item, | |||
| QLayout * | layout | |||
| ) | [protected, virtual] |
Definition at line 514 of file abstractformbuilder.cpp.
References QLayoutItem::alignment(), DomLayoutItem::attributeColSpan(), DomLayoutItem::attributeColumn(), DomLayoutItem::attributeRow(), DomLayoutItem::attributeRowSpan(), DomLayoutItem::hasAttributeColSpan(), DomLayoutItem::hasAttributeRowSpan(), layout, QLayoutItem::layout(), QLayoutItem::spacerItem(), and QLayoutItem::widget().
Referenced by QFormBuilder::addItem(), qdesigner_internal::QDesignerResource::addItem(), and create().
00515 { 00516 if (item->widget()) { 00517 static_cast<QFriendlyLayout*>(layout)->addChildWidget(item->widget()); 00518 } else if (item->layout()) { 00519 static_cast<QFriendlyLayout*>(layout)->addChildLayout(item->layout()); 00520 } else if (item->spacerItem()) { 00521 // nothing to do 00522 } else { 00523 return false; 00524 } 00525 00526 if (QGridLayout *grid = qobject_cast<QGridLayout*>(layout)) { 00527 int rowSpan = ui_item->hasAttributeRowSpan() ? ui_item->attributeRowSpan() : 1; 00528 int colSpan = ui_item->hasAttributeColSpan() ? ui_item->attributeColSpan() : 1; 00529 grid->addItem(item, ui_item->attributeRow(), ui_item->attributeColumn(), 00530 rowSpan, colSpan, item->alignment()); 00531 } else { 00532 layout->addItem(item); 00533 } 00534 00535 return true; 00536 }
Here is the call graph for this function:

| bool QAbstractFormBuilder::addItem | ( | DomWidget * | ui_widget, | |
| QWidget * | widget, | |||
| QWidget * | parentWidget | |||
| ) | [protected, virtual] |
Definition at line 321 of file abstractformbuilder.cpp.
References area(), Qt::BottomDockWidgetArea, DomWidget::elementAttribute(), Qt::LeftDockWidgetArea, propertyMap(), Qt::RightDockWidgetArea, QWidget::setParent(), Qt::TopDockWidgetArea, toString(), toVariant(), and QHash< Key, T >::value().
00322 { 00323 QHash<QString, DomProperty*> attributes = propertyMap(ui_widget->elementAttribute()); 00324 00325 QString title = QLatin1String("Page"); 00326 if (DomProperty *ptitle = attributes.value(QLatin1String("title"))) { 00327 title = toString(ptitle->elementString()); 00328 } 00329 00330 QString label = QLatin1String(QLatin1String("Page")); 00331 if (DomProperty *plabel = attributes.value(QLatin1String("label"))) { 00332 label = toString(plabel->elementString()); 00333 } 00334 00335 if (QMainWindow *mw = qobject_cast<QMainWindow*>(parentWidget)) { 00336 00337 // the menubar 00338 if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(widget)) { 00339 mw->setMenuBar(menuBar); 00340 return true; 00341 } 00342 00343 // apply the toolbar's attributes 00344 else if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) { 00345 if (DomProperty *attr = attributes.value(QLatin1String("toolBarArea"))) { 00346 Qt::ToolBarArea area = static_cast<Qt::ToolBarArea>(attr->elementNumber()); 00347 mw->addToolBar(area, toolBar); 00348 } else { 00349 mw->addToolBar(toolBar); 00350 } 00351 return true; 00352 } 00353 00354 // statusBar 00355 else if (QStatusBar *statusBar = qobject_cast<QStatusBar*>(widget)) { 00356 mw->setStatusBar(statusBar); 00357 return true; 00358 } 00359 00360 // apply the dockwidget's attributes 00361 else if (QDockWidget *dockWidget = qobject_cast<QDockWidget*>(widget)) { 00362 if (DomProperty *attr = attributes.value(QLatin1String("dockWidgetArea"))) { 00363 Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(attr->elementNumber()); 00364 if (!dockWidget->isAreaAllowed(area)) { 00365 if (dockWidget->isAreaAllowed(Qt::LeftDockWidgetArea)) 00366 area = Qt::LeftDockWidgetArea; 00367 else if (dockWidget->isAreaAllowed(Qt::RightDockWidgetArea)) 00368 area = Qt::RightDockWidgetArea; 00369 else if (dockWidget->isAreaAllowed(Qt::TopDockWidgetArea)) 00370 area = Qt::TopDockWidgetArea; 00371 else if (dockWidget->isAreaAllowed(Qt::BottomDockWidgetArea)) 00372 area = Qt::BottomDockWidgetArea; 00373 } 00374 mw->addDockWidget(area, dockWidget); 00375 } else { 00376 mw->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); 00377 } 00378 return true; 00379 } 00380 00381 else if (! mw->centralWidget()) { 00382 mw->setCentralWidget(widget); 00383 return true; 00384 } 00385 } 00386 00387 else if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(parentWidget)) { 00388 widget->setParent(0); 00389 00390 int tabIndex = tabWidget->count(); 00391 tabWidget->addTab(widget, title); 00392 00393 if (DomProperty *picon = attributes.value(QLatin1String("icon"))) { 00394 tabWidget->setTabIcon(tabIndex, qvariant_cast<QIcon>(toVariant(0, picon))); 00395 } 00396 00397 if (DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) { 00398 tabWidget->setTabToolTip(tabIndex, toString(ptoolTip->elementString())); 00399 } 00400 00401 return true; 00402 } 00403 00404 else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) { 00405 int tabIndex = toolBox->count(); 00406 toolBox->addItem(widget, label); 00407 00408 if (DomProperty *picon = attributes.value(QLatin1String("icon"))) { 00409 toolBox->setItemIcon(tabIndex, qvariant_cast<QIcon>(toVariant(0, picon))); 00410 } 00411 00412 if (DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) { 00413 toolBox->setItemToolTip(tabIndex, toString(ptoolTip->elementString())); 00414 } 00415 00416 return true; 00417 } 00418 00419 else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(parentWidget)) { 00420 stackedWidget->addWidget(widget); 00421 return true; 00422 } 00423 00424 else if (QSplitter *splitter = qobject_cast<QSplitter*>(parentWidget)) { 00425 splitter->addWidget(widget); 00426 return true; 00427 } 00428 00429 else if (QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget)) { 00430 dockWidget->setWidget(widget); 00431 return true; 00432 } 00433 00434 return false; 00435 }
Here is the call graph for this function:

| void QAbstractFormBuilder::saveExtraInfo | ( | QWidget * | widget, | |
| DomWidget * | ui_widget, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected, virtual] |
Definition at line 2199 of file abstractformbuilder.cpp.
References saveComboBoxExtraInfo(), saveListWidgetExtraInfo(), saveTableWidgetExtraInfo(), and saveTreeWidgetExtraInfo().
Referenced by createDom().
02200 { 02201 if (QListWidget *listWidget = qobject_cast<QListWidget*>(widget)) { 02202 saveListWidgetExtraInfo(listWidget, ui_widget, ui_parentWidget); 02203 } else if (QTreeWidget *treeWidget = qobject_cast<QTreeWidget*>(widget)) { 02204 saveTreeWidgetExtraInfo(treeWidget, ui_widget, ui_parentWidget); 02205 } else if (QTableWidget *tableWidget = qobject_cast<QTableWidget*>(widget)) { 02206 saveTableWidgetExtraInfo(tableWidget, ui_widget, ui_parentWidget); 02207 } else if (QComboBox *comboBox = qobject_cast<QComboBox*>(widget)) { 02208 if (!qobject_cast<QFontComboBox*>(widget)) 02209 saveComboBoxExtraInfo(comboBox, ui_widget, ui_parentWidget); 02210 } 02211 }
Here is the call graph for this function:

Definition at line 1184 of file abstractformbuilder.cpp.
References QObject::objectName(), saveConnections(), saveCustomWidgets(), saveResources(), saveTabStops(), DomUI::setElementClass(), DomUI::setElementConnections(), DomUI::setElementCustomWidgets(), DomUI::setElementResources(), and DomUI::setElementTabStops().
Referenced by save(), and qdesigner_internal::QDesignerResource::saveDom().
01185 { 01186 ui->setElementClass(widget->objectName()); 01187 01188 if (DomConnections *ui_connections = saveConnections()) { 01189 ui->setElementConnections(ui_connections); 01190 } 01191 01192 if (DomCustomWidgets *ui_customWidgets = saveCustomWidgets()) { 01193 ui->setElementCustomWidgets(ui_customWidgets); 01194 } 01195 01196 if (DomTabStops *ui_tabStops = saveTabStops()) { 01197 ui->setElementTabStops(ui_tabStops); 01198 } 01199 01200 if (DomResources *ui_resources = saveResources()) { 01201 ui->setElementResources(ui_resources); 01202 } 01203 }
Here is the call graph for this function:

| DomActionRef * QAbstractFormBuilder::createActionRefDom | ( | QAction * | action | ) | [protected, virtual] |
Definition at line 1319 of file abstractformbuilder.cpp.
References QAction::isSeparator(), QAction::menu(), name, QObject::objectName(), and DomActionRef::setAttributeName().
Referenced by qdesigner_internal::QDesignerResource::createActionRefDom(), and createDom().
01320 { 01321 QString name = action->objectName(); 01322 01323 if (action->menu() != 0) 01324 name = action->menu()->objectName(); 01325 01326 DomActionRef *ui_action_ref = new DomActionRef(); 01327 if (action->isSeparator()) 01328 ui_action_ref->setAttributeName(QLatin1String("separator")); 01329 else 01330 ui_action_ref->setAttributeName(name); 01331 01332 return ui_action_ref; 01333 }
Here is the call graph for this function:

| DomWidget * QAbstractFormBuilder::createDom | ( | QWidget * | widget, | |
| DomWidget * | ui_parentWidget, | |||
| bool | recursive = true | |||
| ) | [protected, virtual] |
Definition at line 1216 of file abstractformbuilder.cpp.
References QList< T >::append(), computeProperties(), QHash< Key, T >::contains(), createActionRefDom(), i, QWidget::layout(), m_laidout, qobject_cast< QWidget * >(), saveExtraInfo(), DomWidget::setAttributeClass(), DomWidget::setElementAction(), DomWidget::setElementActionGroup(), DomWidget::setElementAddAction(), DomWidget::setElementLayout(), DomWidget::setElementProperty(), and DomWidget::setElementWidget().
Referenced by qdesigner_internal::QDesignerResource::createDom(), qdesigner_internal::QDesignerFormBuilder::createDom(), createDom(), save(), and qdesigner_internal::QDesignerResource::saveWidget().
01217 { 01218 DomWidget *ui_widget = new DomWidget(); 01219 ui_widget->setAttributeClass(QLatin1String(widget->metaObject()->className())); 01220 ui_widget->setElementProperty(computeProperties(widget)); 01221 01222 if (recursive) { 01223 if (QLayout *layout = widget->layout()) { 01224 if (DomLayout *ui_layout = createDom(layout, 0, ui_parentWidget)) { 01225 QList<DomLayout*> ui_layouts; 01226 ui_layouts.append(ui_layout); 01227 01228 ui_widget->setElementLayout(ui_layouts); 01229 } 01230 } 01231 } 01232 01233 // widgets, actions and action groups 01234 QList<DomWidget*> ui_widgets; 01235 QList<DomAction*> ui_actions; 01236 QList<DomActionGroup*> ui_action_groups; 01237 01238 QList<QObject*> children; 01239 01240 // splitters need to store their children in the order specified by child indexes, 01241 // not the order of the child list. 01242 if (QSplitter *splitter = qobject_cast<QSplitter*>(widget)) { 01243 for (int i = 0; i < splitter->count(); ++i) 01244 children.append(splitter->widget(i)); 01245 } else { 01246 children = widget->children(); 01247 } 01248 01249 if (qobject_cast<QMainWindow *>(widget) && widget->parent() && widget->parent()->metaObject()->className() == QLatin1String("qdesigner_internal::QDesignerPromotedWidget")) { 01250 // add actions of parent promoted widget 01251 QObjectList list = widget->parent()->children(); 01252 QListIterator<QObject *> it(list); 01253 while (it.hasNext()) { 01254 QObject *obj = it.next(); 01255 if (qobject_cast<QAction *>(obj) || qobject_cast<QActionGroup *>(obj)) 01256 children.append(obj); 01257 } 01258 } 01259 01260 foreach (QObject *obj, children) { 01261 if (QWidget *childWidget = qobject_cast<QWidget*>(obj)) { 01262 if (m_laidout.contains(childWidget) || recursive == false) 01263 continue; 01264 01265 if (QMenu *menu = qobject_cast<QMenu *>(childWidget)) { 01266 QList<QAction *> actions = menu->parentWidget()->actions(); 01267 QListIterator<QAction *> it(actions); 01268 bool found = false; 01269 while (it.hasNext()) { 01270 if (it.next()->menu() == menu) 01271 found = true; 01272 } 01273 if (!found) 01274 continue; 01275 } 01276 01277 if (DomWidget *ui_child = createDom(childWidget, ui_widget)) { 01278 ui_widgets.append(ui_child); 01279 } 01280 } else if (QAction *childAction = qobject_cast<QAction*>(obj)) { 01281 if (childAction->actionGroup() != 0) { 01282 // it will be added later. 01283 continue; 01284 } 01285 01286 if (DomAction *ui_action = createDom(childAction)) { 01287 ui_actions.append(ui_action); 01288 } 01289 } else if (QActionGroup *childActionGroup = qobject_cast<QActionGroup*>(obj)) { 01290 if (DomActionGroup *ui_action_group = createDom(childActionGroup)) { 01291 ui_action_groups.append(ui_action_group); 01292 } 01293 } 01294 } 01295 01296 // add-action 01297 QList<DomActionRef*> ui_action_refs; 01298 foreach (QAction *action, widget->actions()) { 01299 if (DomActionRef *ui_action_ref = createActionRefDom(action)) { 01300 ui_action_refs.append(ui_action_ref); 01301 } 01302 } 01303 01304 if (recursive) 01305 ui_widget->setElementWidget(ui_widgets); 01306 01307 ui_widget->setElementAction(ui_actions); 01308 ui_widget->setElementActionGroup(ui_action_groups); 01309 ui_widget->setElementAddAction(ui_action_refs); 01310 01311 saveExtraInfo(widget, ui_widget, ui_parentWidget); 01312 01313 return ui_widget; 01314 }
Here is the call graph for this function:

| DomLayout * QAbstractFormBuilder::createDom | ( | QLayout * | layout, | |
| DomLayout * | ui_layout, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected, virtual] |
Definition at line 1338 of file abstractformbuilder.cpp.
References QList< T >::append(), computeProperties(), createDom(), layout, DomLayout::setAttributeClass(), DomLayout::setElementItem(), and DomLayout::setElementProperty().
01339 { 01340 Q_UNUSED(ui_layout) 01341 DomLayout *lay = new DomLayout(); 01342 lay->setAttributeClass(QLatin1String(layout->metaObject()->className())); 01343 lay->setElementProperty(computeProperties(layout)); 01344 01345 QList<DomLayoutItem*> ui_items; 01346 01347 01348 for (int idx=0; layout->itemAt(idx); ++idx) { 01349 QLayoutItem *item = layout->itemAt(idx); 01350 01351 DomLayoutItem *ui_item = createDom(item, lay, ui_parentWidget); 01352 if (ui_item) 01353 ui_items.append(ui_item); 01354 } 01355 01356 lay->setElementItem(ui_items); 01357 01358 return lay; 01359 }
Here is the call graph for this function:

| DomLayoutItem * QAbstractFormBuilder::createDom | ( | QLayoutItem * | item, | |
| DomLayout * | ui_parentLayout, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected, virtual] |
Definition at line 1364 of file abstractformbuilder.cpp.
References createDom(), QHash< Key, T >::insert(), QLayoutItem::layout(), m_laidout, DomLayoutItem::setElementLayout(), DomLayoutItem::setElementSpacer(), DomLayoutItem::setElementWidget(), QLayoutItem::spacerItem(), and QLayoutItem::widget().
01365 { 01366 DomLayoutItem *ui_item = new DomLayoutItem(); 01367 01368 if (item->widget()) { 01369 ui_item->setElementWidget(createDom(item->widget(), ui_parentWidget)); 01370 m_laidout.insert(item->widget(), true); 01371 } else if (item->layout()) { 01372 ui_item->setElementLayout(createDom(item->layout(), ui_layout, ui_parentWidget)); 01373 } else if (item->spacerItem()) { 01374 ui_item->setElementSpacer(createDom(item->spacerItem(), ui_layout, ui_parentWidget)); 01375 } 01376 01377 return ui_item; 01378 }
Here is the call graph for this function:

| DomSpacer * QAbstractFormBuilder::createDom | ( | QSpacerItem * | spacer, | |
| DomLayout * | ui_parentLayout, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected, virtual] |
Definition at line 1383 of file abstractformbuilder.cpp.
References DomProperty::elementSize(), QSpacerItem::expandingDirections(), QSize::height(), Qt::Horizontal, properties, DomProperty::setAttributeName(), DomProperty::setElementEnum(), DomSize::setElementHeight(), DomSpacer::setElementProperty(), DomProperty::setElementSize(), DomSize::setElementWidth(), QSpacerItem::sizeHint(), and QSize::width().
01384 { 01385 Q_UNUSED(ui_layout); 01386 Q_UNUSED(ui_parentWidget); 01387 01388 DomSpacer *ui_spacer = new DomSpacer(); 01389 QList<DomProperty*> properties; 01390 01391 DomProperty *prop = 0; 01392 01393 // sizeHint property 01394 prop = new DomProperty(); 01395 prop->setAttributeName(QLatin1String("sizeHint")); 01396 prop->setElementSize(new DomSize()); 01397 prop->elementSize()->setElementWidth(spacer->sizeHint().width()); 01398 prop->elementSize()->setElementHeight(spacer->sizeHint().height()); 01399 properties.append(prop); 01400 01401 // orientation property 01402 prop = new DomProperty(); // ### we don't implemented the case where expandingDirections() is both Vertical and Horizontal 01403 prop->setAttributeName(QLatin1String("orientation")); 01404 prop->setElementEnum((spacer->expandingDirections() & Qt::Horizontal) ? QLatin1String("Qt::Horizontal") : QLatin1String("Qt::Vertical")); 01405 properties.append(prop); 01406 01407 ui_spacer->setElementProperty(properties); 01408 return ui_spacer; 01409 }
Here is the call graph for this function:

Definition at line 2548 of file abstractformbuilder.cpp.
References computeProperties(), QAction::isSeparator(), QAction::menu(), QObject::objectName(), QAction::parentWidget(), properties, DomAction::setAttributeName(), and DomAction::setElementProperty().
02549 { 02550 if (action->parentWidget() == action->menu() || action->isSeparator()) 02551 return 0; 02552 02553 DomAction *ui_action = new DomAction; 02554 ui_action->setAttributeName(action->objectName()); 02555 02556 QList<DomProperty*> properties = computeProperties(action); 02557 ui_action->setElementProperty(properties); 02558 02559 return ui_action; 02560 }
Here is the call graph for this function:

| DomActionGroup * QAbstractFormBuilder::createDom | ( | QActionGroup * | actionGroup | ) | [protected, virtual] |
Definition at line 2565 of file abstractformbuilder.cpp.
References QActionGroup::actions(), QList< T >::append(), computeProperties(), createDom(), QObject::objectName(), properties, DomActionGroup::setAttributeName(), DomActionGroup::setElementAction(), and DomActionGroup::setElementProperty().
02566 { 02567 DomActionGroup *ui_action_group = new DomActionGroup; 02568 ui_action_group->setAttributeName(actionGroup->objectName()); 02569 02570 QList<DomProperty*> properties = computeProperties(actionGroup); 02571 ui_action_group->setElementProperty(properties); 02572 02573 QList<DomAction*> ui_actions; 02574 02575 foreach (QAction *action, actionGroup->actions()) { 02576 if (DomAction *ui_action = createDom(action)) { 02577 ui_actions.append(ui_action); 02578 } 02579 } 02580 02581 ui_action_group->setElementAction(ui_actions); 02582 02583 return ui_action_group; 02584 }
Here is the call graph for this function:

| DomConnections * QAbstractFormBuilder::saveConnections | ( | ) | [protected, virtual] |
Definition at line 1208 of file abstractformbuilder.cpp.
Referenced by saveDom().
01209 { 01210 return new DomConnections; 01211 }
| DomCustomWidgets * QAbstractFormBuilder::saveCustomWidgets | ( | ) | [protected, virtual] |
| DomTabStops * QAbstractFormBuilder::saveTabStops | ( | ) | [protected, virtual] |
| DomResources * QAbstractFormBuilder::saveResources | ( | ) | [protected, virtual] |
| QList< DomProperty * > QAbstractFormBuilder::computeProperties | ( | QObject * | obj | ) | [protected, virtual] |
Definition at line 1707 of file abstractformbuilder.cpp.
References QList< T >::append(), QList< T >::at(), checkProperty(), createProperty(), QMetaProperty::enumerator(), QString::fromUtf8(), i, QMetaObject::indexOfProperty(), QVariant::Int, QMetaProperty::isEnumType(), QMetaProperty::isFlagType(), QMetaProperty::isWritable(), DomProperty::kind(), QMetaProperty::name(), properties, QMetaObject::property(), QMetaObject::propertyCount(), qWarning(), QMetaProperty::read(), QMetaEnum::scope(), DomProperty::setAttributeName(), DomProperty::setElementEnum(), DomProperty::setElementNumber(), QList< T >::size(), QString::size(), QVariant::toInt(), QVariant::type(), DomProperty::Unknown, and QMetaEnum::valueToKey().
Referenced by createDom().
01708 { 01709 QList<DomProperty*> lst; 01710 01711 const QMetaObject *meta = obj->metaObject(); 01712 01713 QHash<QByteArray, bool> properties; 01714 for(int i=0; i<meta->propertyCount(); ++i) 01715 properties.insert(meta->property(i).name(), true); 01716 01717 QList<QByteArray> propertyNames = properties.keys(); 01718 01719 for(int i=0; i<propertyNames.size(); ++i) { 01720 QString pname = QString::fromUtf8(propertyNames.at(i)); 01721 QMetaProperty prop = meta->property(meta->indexOfProperty(pname.toUtf8())); 01722 01723 if (!prop.isWritable() || !checkProperty(obj, QLatin1String(prop.name()))) 01724 continue; 01725 01726 QVariant v = prop.read(obj); 01727 01728 DomProperty *dom_prop = 0; 01729 if (v.type() == QVariant::Int) { 01730 dom_prop = new DomProperty(); 01731 01732 if (prop.isFlagType()) 01733 qWarning("flags property not supported yet!!"); 01734 01735 if (prop.isEnumType()) { 01736 QString scope = QString::fromUtf8(prop.enumerator().scope()); 01737 if (scope.size()) 01738 scope += QString::fromUtf8("::"); 01739 QString e = QString::fromUtf8(prop.enumerator().valueToKey(v.toInt())); 01740 if (e.size()) 01741 dom_prop->setElementEnum(scope + e); 01742 } else 01743 dom_prop->setElementNumber(v.toInt()); 01744 dom_prop->setAttributeName(pname); 01745 } else { 01746 dom_prop = createProperty(obj, pname, v); 01747 } 01748 01749 if (!dom_prop || dom_prop->kind() == DomProperty::Unknown) 01750 delete dom_prop; 01751 else 01752 lst.append(dom_prop); 01753 } 01754 01755 return lst; 01756 }
Here is the call graph for this function:

| bool QAbstractFormBuilder::checkProperty | ( | QObject * | obj, | |
| const QString & | prop | |||
| ) | const [protected, virtual] |
Definition at line 1782 of file abstractformbuilder.cpp.
Referenced by computeProperties(), and createProperty().
| DomProperty * QAbstractFormBuilder::createProperty | ( | QObject * | object, | |
| const QString & | propertyName, | |||
| const QVariant & | value | |||
| ) | [protected, virtual] |
Definition at line 1414 of file abstractformbuilder.cpp.
References QPalette::Active, QColor::blue, QFont::bold(), QVariant::Bool, QVariant::ByteArray, QVariant::Char, checkProperty(), QVariant::Color, QVariant::Cursor, QVariant::Date, QDateTime::date(), QVariant::DateTime, QDate::day(), QPalette::Disabled, QVariant::Double, QFont::family(), QFontPrivate::Family, QVariant::Font, QString::fromUtf8(), QColor::green, QMetaProperty::hasStdCppSet(), QRectF::height(), QRect::height(), QSizeF::height(), QSizePolicy::horizontalPolicy(), QSizePolicy::horizontalStretch(), QTime::hour(), QVariant::Icon, iconToFilePath(), iconToQrcPath(), QPalette::Inactive, QMetaObject::indexOfProperty(), QVariant::Int, QString::isEmpty(), QFont::italic(), QFontPrivate::Kerning, QFont::kerning(), QVariant::KeySequence, DomProperty::kind(), QVariant::LongLong, mask, QTime::minute(), QDate::month(), palette, QVariant::Palette, QVariant::Pixmap, pixmapToFilePath(), pixmapToQrcPath(), QVariant::Point, QVariant::PointF, QFont::pointSize(), QKeySequence::PortableText, QFont::PreferDefault, QMetaObject::property(), qWarning(), QVariant::Rect, QVariant::RectF, QColor::red, QDir::relativeFilePath(), QString::replace(), QFont::resolve(), s, saveColorGroup(), QTime::second(), DomProperty::setAttributeName(), DomResourcePixmap::setAttributeResource(), DomProperty::setAttributeStdset(), DomPalette::setElementActive(), DomFont::setElementAntialiasing(), DomColor::setElementBlue(), DomFont::setElementBold(), DomProperty::setElementBool(), DomProperty::setElementChar(), DomProperty::setElementColor(), DomProperty::setElementCstring(), DomProperty::setElementCursor(), DomProperty::setElementDate(), DomProperty::setElementDateTime(), DomDateTime::setElementDay(), DomDate::setElementDay(), DomPalette::setElementDisabled(), DomProperty::setElementDouble(), DomFont::setElementFamily(), DomProperty::setElementFont(), DomColor::setElementGreen(), DomRect::setElementHeight(), DomSize::setElementHeight(), DomSizeF::setElementHeight(), DomRectF::setElementHeight(), DomSizePolicy::setElementHorStretch(), DomTime::setElementHour(), DomDateTime::setElementHour(), DomSizePolicy::setElementHSizeType(), DomProperty::setElementIconSet(), DomPalette::setElementInactive(), DomFont::setElementItalic(), DomFont::setElementKerning(), DomProperty::setElementLongLong(), DomDateTime::setElementMinute(), DomTime::setElementMinute(), DomDate::setElementMonth(), DomDateTime::setElementMonth(), DomProperty::setElementNumber(), DomProperty::setElementPalette(), DomProperty::setElementPixmap(), DomProperty::setElementPoint(), DomProperty::setElementPointF(), DomFont::setElementPointSize(), DomProperty::setElementRect(), DomProperty::setElementRectF(), DomColor::setElementRed(), DomDateTime::setElementSecond(), DomTime::setElementSecond(), DomProperty::setElementSize(), DomProperty::setElementSizeF(), DomProperty::setElementSizePolicy(), DomFont::setElementStrikeOut(), DomProperty::setElementString(), DomUrl::setElementString(), DomStringList::setElementString(), DomProperty::setElementStringList(), DomProperty::setElementTime(), DomFont::setElementUnderline(), DomChar::setElementUnicode(), DomProperty::setElementUrl(), DomSizePolicy::setElementVerStretch(), DomSizePolicy::setElementVSizeType(), DomFont::setElementWeight(), DomSize::setElementWidth(), DomRect::setElementWidth(), DomRectF::setElementWidth(), DomSizeF::setElementWidth(), DomPoint::setElementX(), DomPointF::setElementX(), DomRect::setElementX(), DomRectF::setElementX(), DomPointF::setElementY(), DomRect::setElementY(), DomRectF::setElementY(), DomPoint::setElementY(), DomDate::setElementYear(), DomDateTime::setElementYear(), DomString::setText(), DomResourcePixmap::setText(), QVariant::Size, QFontPrivate::Size, size, QVariant::SizeF, QVariant::SizePolicy, QFontPrivate::StrikeOut, QFont::strikeOut(), QVariant::String, QVariant::StringList, QFontPrivate::Style, QFont::styleStrategy(), QFontPrivate::StyleStrategy, QDateTime::time(), QVariant::Time, QVariant::toBool(), QVariant::toByteArray(), QVariant::toChar(), QVariant::toDouble(), QVariant::toInt(), QVariant::toLongLong(), QVariant::toPoint(), QVariant::toPointF(), QVariant::toRect(), QVariant::toRectF(), QVariant::toSize(), QVariant::toSizeF(), QUrl::toString(), QVariant::toString(), toString(), QVariant::toUInt(), QVariant::toULongLong(), QVariant::toUrl(), QVariant::type(), QVariant::UInt, QVariant::ULongLong, QFont::underline(), QFontPrivate::Underline, QChar::unicode(), DomProperty::Unknown, QVariant::Url, QSizePolicy::verticalPolicy(), QSizePolicy::verticalStretch(), QFont::weight(), QFontPrivate::Weight, QRect::width(), QRectF::width(), QSizeF::width(), workingDirectory(), QRect::x(), QRectF::x(), QPoint::x(), QPointF::x(), QRect::y(), QRectF::y(), QPoint::y(), QPointF::y(), and QDate::year().
Referenced by computeProperties(), and qdesigner_internal::QDesignerResource::createProperty().
01415 { 01416 if (!checkProperty(obj, pname)) { 01417 return 0; 01418 } 01419 01420 DomProperty *dom_prop = new DomProperty(); 01421 01422 const QMetaObject *meta = obj->metaObject(); 01423 int pindex = meta->indexOfProperty(pname.toLatin1()); 01424 if (pindex != -1) { 01425 QMetaProperty meta_property = meta->property(pindex); 01426 if (!meta_property.hasStdCppSet()) 01427 dom_prop->setAttributeStdset(0); 01428 } 01429 01430 switch (v.type()) { 01431 case QVariant::String: { 01432 DomString *str = new DomString(); 01433 str->setText(v.toString()); 01434 01435 if (pname == QLatin1String("objectName")) 01436 str->setAttributeNotr(QLatin1String("true")); 01437 01438 dom_prop->setElementString(str); 01439 } break; 01440 01441 case QVariant::ByteArray: { 01442 dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray())); 01443 } break; 01444 01445 case QVariant::Int: { 01446 dom_prop->setElementNumber(v.toInt()); 01447 } break; 01448 01449 case QVariant::UInt: { 01450 dom_prop->setElementNumber(v.toUInt()); 01451 } break; 01452 01453 case QVariant::LongLong: { 01454 dom_prop->setElementLongLong(v.toLongLong()); 01455 } break; 01456 01457 case QVariant::ULongLong: { 01458 dom_prop->setElementLongLong(v.toULongLong()); 01459 } break; 01460 01461 case QVariant::Double: { 01462 dom_prop->setElementDouble(v.toDouble()); 01463 } break; 01464 01465 case QVariant::Bool: { 01466 dom_prop->setElementBool(v.toBool() ? QLatin1String("true") : QLatin1String("false")); 01467 } break; 01468 01469 case QVariant::Char: { 01470 DomChar *ch = new DomChar(); 01471 QChar character = v.toChar(); 01472 ch->setElementUnicode(character.unicode()); 01473 dom_prop->setElementChar(ch); 01474 } break; 01475 01476 case QVariant::Point: { 01477 DomPoint *pt = new DomPoint(); 01478 QPoint point = v.toPoint(); 01479 pt->setElementX(point.x()); 01480 pt->setElementY(point.y()); 01481 dom_prop->setElementPoint(pt); 01482 } break; 01483 01484 case QVariant::PointF: { 01485 DomPointF *ptf = new DomPointF(); 01486 QPointF pointf = v.toPointF(); 01487 ptf->setElementX(pointf.x()); 01488 ptf->setElementY(pointf.y()); 01489 dom_prop->setElementPointF(ptf); 01490 } break; 01491 01492 case QVariant::Color: { 01493 DomColor *clr = new DomColor(); 01494 QColor color = qvariant_cast<QColor>(v); 01495 clr->setElementRed(color.red()); 01496 clr->setElementGreen(color.green()); 01497 clr->setElementBlue(color.blue()); 01498 dom_prop->setElementColor(clr); 01499 } break; 01500 01501 case QVariant::Size: { 01502 DomSize *sz = new DomSize(); 01503 QSize size = v.toSize(); 01504 sz->setElementWidth(size.width()); 01505 sz->setElementHeight(size.height()); 01506 dom_prop->setElementSize(sz); 01507 } break; 01508 01509 case QVariant::SizeF: { 01510 DomSizeF *szf = new DomSizeF(); 01511 QSizeF sizef = v.toSizeF(); 01512 szf->setElementWidth(sizef.width()); 01513 szf->setElementHeight(sizef.height()); 01514 dom_prop->setElementSizeF(szf); 01515 } break; 01516 01517 case QVariant::Rect: { 01518 DomRect *rc = new DomRect(); 01519 QRect rect = v.toRect(); 01520 rc->setElementX(rect.x()); 01521 rc->setElementY(rect.y()); 01522 rc->setElementWidth(rect.width()); 01523 rc->setElementHeight(rect.height()); 01524 dom_prop->setElementRect(rc); 01525 } break; 01526 01527 case QVariant::RectF: { 01528 DomRectF *rcf = new DomRectF(); 01529 QRectF rectf = v.toRectF(); 01530 rcf->setElementX(rectf.x()); 01531 rcf->setElementY(rectf.y()); 01532 rcf->setElementWidth(rectf.width()); 01533 rcf->setElementHeight(rectf.height()); 01534 dom_prop->setElementRectF(rcf); 01535 } break; 01536 01537 case QVariant::Font: { 01538 DomFont *fnt = new DomFont(); 01539 QFont font = qvariant_cast<QFont>(v); 01540 uint mask = font.resolve(); 01541 if (mask & QFontPrivate::Weight) { 01542 fnt->setElementBold(font.bold()); 01543 fnt->setElementWeight(font.weight()); 01544 } 01545 if (mask & QFontPrivate::Family) 01546 fnt->setElementFamily(font.family()); 01547 if (mask & QFontPrivate::Style) 01548 fnt->setElementItalic(font.italic()); 01549 if (mask & QFontPrivate::Size) 01550 fnt->setElementPointSize(font.pointSize()); 01551 if (mask & QFontPrivate::StrikeOut) 01552 fnt->setElementStrikeOut(font.strikeOut()); 01553 if (mask & QFontPrivate::Underline) 01554 fnt->setElementUnderline(font.underline()); 01555 if (mask & QFontPrivate::Kerning) 01556 fnt->setElementKerning(font.kerning()); 01557 if (mask & QFontPrivate::StyleStrategy) 01558 fnt->setElementAntialiasing(font.styleStrategy() == QFont::PreferDefault); 01559 dom_prop->setElementFont(fnt); 01560 } break; 01561 01562 case QVariant::Cursor: { 01563 dom_prop->setElementCursor(qvariant_cast<QCursor>(v).shape()); 01564 } break; 01565 01566 case QVariant::KeySequence: { 01567 DomString *s = new DomString(); 01568 s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText)); 01569 dom_prop->setElementString(s); 01570 } break; 01571 01572 case QVariant::Palette: { 01573 DomPalette *dom = new DomPalette(); 01574 QPalette palette = qvariant_cast<QPalette>(v); 01575 01576 palette.setCurrentColorGroup(QPalette::Active); 01577 dom->setElementActive(saveColorGroup(palette)); 01578 01579 palette.setCurrentColorGroup(QPalette::Inactive); 01580 dom->setElementInactive(saveColorGroup(palette)); 01581 01582 palette.setCurrentColorGroup(QPalette::Disabled); 01583 dom->setElementDisabled(saveColorGroup(palette)); 01584 01585 dom_prop->setElementPalette(dom); 01586 } break; 01587 01588 case QVariant::SizePolicy: { 01589 DomSizePolicy *dom = new DomSizePolicy(); 01590 QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v); 01591 01592 dom->setElementHorStretch(sizePolicy.horizontalStretch()); 01593 dom->setElementVerStretch(sizePolicy.verticalStretch()); 01594 01595 dom->setElementHSizeType(sizePolicy.horizontalPolicy()); 01596 dom->setElementVSizeType(sizePolicy.verticalPolicy()); 01597 01598 dom_prop->setElementSizePolicy(dom); 01599 } break; 01600 01601 case QVariant::Date: { 01602 DomDate *dom = new DomDate(); 01603 QDate date = qvariant_cast<QDate>(v); 01604 01605 dom->setElementYear(date.year()); 01606 dom->setElementMonth(date.month()); 01607 dom->setElementDay(date.day()); 01608 01609 dom_prop->setElementDate(dom); 01610 } break; 01611 01612 case QVariant::Time: { 01613 DomTime *dom = new DomTime(); 01614 QTime time = qvariant_cast<QTime>(v); 01615 01616 dom->setElementHour(time.hour()); 01617 dom->setElementMinute(time.minute()); 01618 dom->setElementSecond(time.second()); 01619 01620 dom_prop->setElementTime(dom); 01621 } break; 01622 01623 case QVariant::DateTime: { 01624 DomDateTime *dom = new DomDateTime(); 01625 QDateTime dateTime = qvariant_cast<QDateTime>(v); 01626 01627 dom->setElementHour(dateTime.time().hour()); 01628 dom->setElementMinute(dateTime.time().minute()); 01629 dom->setElementSecond(dateTime.time().second()); 01630 dom->setElementYear(dateTime.date().year()); 01631 dom->setElementMonth(dateTime.date().month()); 01632 dom->setElementDay(dateTime.date().day()); 01633 01634 dom_prop->setElementDateTime(dom); 01635 } break; 01636 01637 case QVariant::Url: { 01638 DomUrl *dom = new DomUrl(); 01639 QUrl url = v.toUrl(); 01640 01641 DomString *str = new DomString(); 01642 str->setText(url.toString()); 01643 dom->setElementString(str); 01644 01645 dom_prop->setElementUrl(dom); 01646 } break; 01647 01648 case QVariant::Pixmap: 01649 case QVariant::Icon: { 01650 DomResourcePixmap *r = new DomResourcePixmap; 01651 QString icon_path; 01652 QString qrc_path; 01653 if (v.type() == QVariant::Icon) { 01654 QIcon icon = qvariant_cast<QIcon>(v); 01655 icon_path = iconToFilePath(icon); 01656 qrc_path = iconToQrcPath(icon); 01657 } else { 01658 QPixmap pixmap = qvariant_cast<QPixmap>(v); 01659 icon_path = pixmapToFilePath(pixmap); 01660 qrc_path = pixmapToQrcPath(pixmap); 01661 } 01662 01663 if (qrc_path.isEmpty()) 01664 icon_path = workingDirectory().relativeFilePath(icon_path); 01665 else 01666 qrc_path = workingDirectory().relativeFilePath(qrc_path); 01667 01668 icon_path = icon_path.replace(QLatin1Char('\\'), QLatin1Char('/')); 01669 qrc_path = qrc_path.replace(QLatin1Char('\\'), QLatin1Char('/')); 01670 01671 r->setText(icon_path); 01672 if (!qrc_path.isEmpty()) 01673 r->setAttributeResource(qrc_path); 01674 01675 if (v.type() == QVariant::Icon) 01676 dom_prop->setElementIconSet(r); 01677 else 01678 dom_prop->setElementPixmap(r); 01679 } break; 01680 01681 case QVariant::StringList: { 01682 DomStringList *sl = new DomStringList; 01683 sl->setElementString(qvariant_cast<QStringList>(v)); 01684 dom_prop->setElementStringList(sl); 01685 } break; 01686 01687 default: { 01688 qWarning("support for property `%s' of type `%d' not implemented yet!!", 01689 pname.toUtf8().data(), v.type()); 01690 } break; 01691 } 01692 01693 dom_prop->setAttributeName(pname); 01694 // ### dom_prop->setAttributeStdset(true); 01695 01696 if (dom_prop->kind() == DomProperty::Unknown) { 01697 delete dom_prop; 01698 dom_prop = 0; 01699 } 01700 01701 return dom_prop; 01702 }
Here is the call graph for this function:

| void QAbstractFormBuilder::layoutInfo | ( | DomLayout * | layout, | |
| QObject * | parent, | |||
| int * | margin, | |||
| int * | spacing | |||
| ) | [protected, virtual] |
Definition at line 440 of file abstractformbuilder.cpp.
References DomLayout::elementProperty(), m_defaultMargin, m_defaultSpacing, properties, propertyMap(), and qstrcmp().
Referenced by create(), and qdesigner_internal::QDesignerResource::layoutInfo().
00441 { 00442 QHash<QString, DomProperty*> properties = propertyMap(ui_layout->elementProperty()); 00443 00444 if (margin) 00445 *margin = properties.contains(QLatin1String("margin")) 00446 ? properties.value(QLatin1String("margin"))->elementNumber() 00447 : m_defaultMargin; 00448 00449 if (spacing) 00450 *spacing = properties.contains(QLatin1String("spacing")) 00451 ? properties.value(QLatin1String("spacing"))->elementNumber() 00452 : m_defaultSpacing; 00453 00454 if (margin && m_defaultMargin == INT_MIN) { 00455 Q_ASSERT(parent); 00456 if (qstrcmp(parent->metaObject()->className(), "QLayoutWidget") == 0) 00457 *margin = INT_MIN; 00458 } 00459 }
Here is the call graph for this function:

| QIcon QAbstractFormBuilder::nameToIcon | ( | const QString & | filePath, | |
| const QString & | qrcPath | |||
| ) | [protected, virtual] |
Definition at line 2473 of file abstractformbuilder.cpp.
References QFileInfo::absoluteFilePath(), and workingDirectory().
Referenced by loadComboBoxExtraInfo(), loadListWidgetExtraInfo(), loadTableWidgetExtraInfo(), loadTreeWidgetExtraInfo(), and toVariant().
02474 { 02475 Q_UNUSED(qrcPath); 02476 QFileInfo fileInfo(workingDirectory(), filePath); 02477 return QIcon(fileInfo.absoluteFilePath()); 02478 }
Here is the call graph for this function:

Definition at line 2483 of file abstractformbuilder.cpp.
Referenced by createProperty(), saveComboBoxExtraInfo(), saveListWidgetExtraInfo(), saveTableWidgetExtraInfo(), and saveTreeWidgetExtraInfo().
02484 { 02485 Q_UNUSED(pm); 02486 return QString(); 02487 }
Definition at line 2492 of file abstractformbuilder.cpp.
Referenced by createProperty(), saveComboBoxExtraInfo(), saveListWidgetExtraInfo(), saveTableWidgetExtraInfo(), and saveTreeWidgetExtraInfo().
02493 { 02494 Q_UNUSED(pm); 02495 return QString(); 02496 }
| QPixmap QAbstractFormBuilder::nameToPixmap | ( | const QString & | filePath, | |
| const QString & | qrcPath | |||
| ) | [protected, virtual] |
Definition at line 2501 of file abstractformbuilder.cpp.
References QFileInfo::absoluteFilePath(), and workingDirectory().
Referenced by setupBrush(), and toVariant().
02502 { 02503 Q_UNUSED(qrcPath); 02504 QFileInfo fileInfo(workingDirectory(), filePath); 02505 return QPixmap(fileInfo.absoluteFilePath()); 02506 }
Here is the call graph for this function:

Definition at line 2511 of file abstractformbuilder.cpp.
Referenced by createProperty(), and saveBrush().
02512 { 02513 Q_UNUSED(pm); 02514 return QString(); 02515 }
Definition at line 2520 of file abstractformbuilder.cpp.
Referenced by createProperty(), and saveBrush().
02521 { 02522 Q_UNUSED(pm); 02523 return QString(); 02524 }
| void QAbstractFormBuilder::loadListWidgetExtraInfo | ( | DomWidget * | ui_widget, | |
| QListWidget * | listWidget, | |||
| QWidget * | parentWidget | |||
| ) | [protected] |
Definition at line 2216 of file abstractformbuilder.cpp.
References DomWidget::elementItem(), DomProperty::elementNumber(), DomItem::elementProperty(), DomWidget::elementProperty(), DomProperty::IconSet, nameToIcon(), p, properties, propertyMap(), QListWidget::setCurrentRow(), QListWidgetItem::setIcon(), QListWidgetItem::setText(), DomProperty::String, and value.
Referenced by loadExtraInfo().
02217 { 02218 Q_UNUSED(parentWidget); 02219 02220 foreach (DomItem *ui_item, ui_widget->elementItem()) { 02221 QHash<QString, DomProperty*> properties = propertyMap(ui_item->elementProperty()); 02222 QListWidgetItem *item = new QListWidgetItem(listWidget); 02223 02224 DomProperty *p = 0; 02225 02226 p = properties.value(QLatin1String("text")); 02227 if (p && p->kind() == DomProperty::String) { 02228 item->setText(p->elementString()->text()); 02229 } 02230 02231 p = properties.value(QLatin1String("icon")); 02232 if (p && p->kind() == DomProperty::IconSet) { 02233 DomResourcePixmap *icon = p->elementIconSet(); 02234 Q_ASSERT(icon != 0); 02235 QString iconPath = icon->text(); 02236 QString qrcPath = icon->attributeResource(); 02237 02238 item->setIcon(nameToIcon(iconPath, qrcPath)); 02239 } 02240 } 02241 02242 DomProperty *currentRow = propertyMap(ui_widget->elementProperty()).value("currentRow"); 02243 if (currentRow) 02244 listWidget->setCurrentRow(currentRow->elementNumber()); 02245 }
Here is the call graph for this function:

| void QAbstractFormBuilder::loadTreeWidgetExtraInfo | ( | DomWidget * | ui_widget, | |
| QTreeWidget * | treeWidget, | |||
| QWidget * | parentWidget | |||
| ) | [protected] |
Definition at line 2250 of file abstractformbuilder.cpp.
References QList< T >::at(), DomProperty::attributeName(), c, QList< T >::count(), QQueue< T >::dequeue(), DomWidget::elementColumn(), DomProperty::elementIconSet(), DomItem::elementItem(), DomWidget::elementItem(), DomItem::elementProperty(), DomProperty::elementString(), QQueue< T >::enqueue(), QTreeWidget::headerItem(), i, DomProperty::IconSet, QList< T >::isEmpty(), DomProperty::kind(), nameToIcon(), properties, propertyMap(), qMakePair(), QTreeWidget::setColumnCount(), QTreeWidgetItem::setIcon(), QTreeWidgetItem::setText(), and DomString::text().
Referenced by loadExtraInfo().
02251 { 02252 Q_UNUSED(parentWidget); 02253 02254 QList<DomColumn*> columns = ui_widget->elementColumn(); 02255 02256 treeWidget->setColumnCount(columns.count()); 02257 02258 for (int i = 0; i<columns.count(); ++i) { 02259 DomColumn *c = columns.at(i); 02260 QHash<QString, DomProperty*> properties = propertyMap(c->elementProperty()); 02261 02262 DomProperty *ptext = properties.value(QLatin1String("text")); 02263 DomProperty *picon = properties.value(QLatin1String("icon")); 02264 02265 if (ptext != 0 && ptext->elementString()) 02266 treeWidget->headerItem()->setText(i, ptext->elementString()->text()); 02267 02268 if (picon && picon->kind() == DomProperty::IconSet) { 02269 DomResourcePixmap *icon = picon->elementIconSet(); 02270 Q_ASSERT(icon != 0); 02271 QString iconPath = icon->text(); 02272 QString qrcPath = icon->attributeResource(); 02273 02274 treeWidget->headerItem()->setIcon(i, nameToIcon(iconPath, qrcPath)); 02275 } 02276 } 02277 02278 QQueue<QPair<DomItem *, QTreeWidgetItem *> > pendingQueue; 02279 foreach (DomItem *ui_item, ui_widget->elementItem()) 02280 pendingQueue.enqueue(qMakePair(ui_item, (QTreeWidgetItem *)0)); 02281 02282 while (!pendingQueue.isEmpty()) { 02283 QPair<DomItem *, QTreeWidgetItem *> pair = pendingQueue.dequeue(); 02284 DomItem *domItem = pair.first; 02285 QTreeWidgetItem *parentItem = pair.second; 02286 02287 QTreeWidgetItem *currentItem = 0; 02288 02289 if (parentItem) 02290 currentItem = new QTreeWidgetItem(parentItem); 02291 else 02292 currentItem = new QTreeWidgetItem(treeWidget); 02293 02294 QList<DomProperty *> properties = domItem->elementProperty(); 02295 int col = 0; 02296 foreach (DomProperty *property, properties) { 02297 if (property->attributeName() == QLatin1String("text") && 02298 property->elementString()) { 02299 currentItem->setText(col, property->elementString()->text()); 02300 col++; 02301 } else if (property->attributeName() == QLatin1String("icon") && 02302 property->kind() == DomProperty::IconSet && col > 0) { 02303 DomResourcePixmap *icon = property->elementIconSet(); 02304 Q_ASSERT(icon != 0); 02305 QString iconPath = icon->text(); 02306 QString qrcPath = icon->attributeResource(); 02307 02308 currentItem->setIcon(col - 1, nameToIcon(iconPath, qrcPath)); 02309 } 02310 } 02311 02312 02313 foreach (DomItem *childItem, domItem->elementItem()) 02314 pendingQueue.enqueue(qMakePair(childItem, currentItem)); 02315 02316 } 02317 }
Here is the call graph for this function:

| void QAbstractFormBuilder::loadTableWidgetExtraInfo | ( | DomWidget * | ui_widget, | |
| QTableWidget * | tableWidget, | |||
| QWidget * | parentWidget | |||
| ) | [protected] |
Definition at line 2322 of file abstractformbuilder.cpp.
References QList< T >::at(), DomItem::attributeColumn(), DomItem::attributeRow(), c, QList< T >::count(), DomWidget::elementColumn(), DomProperty::elementIconSet(), DomWidget::elementItem(), DomItem::elementProperty(), DomWidget::elementRow(), DomItem::hasAttributeColumn(), DomItem::hasAttributeRow(), i, DomProperty::IconSet, DomProperty::kind(), nameToIcon(), properties, propertyMap(), QTableWidget::setColumnCount(), QTableWidget::setHorizontalHeaderItem(), QTableWidgetItem::setIcon(), QTableWidget::setItem(), QTableWidget::setRowCount(), QTableWidgetItem::setText(), and QTableWidget::setVerticalHeaderItem().
Referenced by loadExtraInfo().
02323 { 02324 Q_UNUSED(parentWidget); 02325 02326 QList<DomColumn*> columns = ui_widget->elementColumn(); 02327 tableWidget->setColumnCount(columns.count()); 02328 for (int i = 0; i< columns.count(); i++) { 02329 DomColumn *c = columns.at(i); 02330 QHash<QString, DomProperty*> properties = propertyMap(c->elementProperty()); 02331 02332 DomProperty *ptext = properties.value(QLatin1String("text")); 02333 DomProperty *picon = properties.value(QLatin1String("icon")); 02334 02335 if (ptext || picon) { 02336 QTableWidgetItem *item = new QTableWidgetItem; 02337 if (ptext != 0 && ptext->elementString()) { 02338 item->setText(ptext->elementString()->text()); 02339 } 02340 02341 if (picon && picon->kind() == DomProperty::IconSet) { 02342 DomResourcePixmap *icon = picon->elementIconSet(); 02343 Q_ASSERT(icon != 0); 02344 QString iconPath = icon->text(); 02345 QString qrcPath = icon->attributeResource(); 02346 02347 item->setIcon(nameToIcon(iconPath, qrcPath)); 02348 } 02349 tableWidget->setHorizontalHeaderItem(i, item); 02350 } 02351 } 02352 02353 QList<DomRow*> rows = ui_widget->elementRow(); 02354 tableWidget->setRowCount(rows.count()); 02355 for (int i = 0; i< rows.count(); i++) { 02356 DomRow *r = rows.at(i); 02357 QHash<QString, DomProperty*> properties = propertyMap(r->elementProperty()); 02358 02359 DomProperty *ptext = properties.value(QLatin1String("text")); 02360 DomProperty *picon = properties.value(QLatin1String("icon")); 02361 02362 if (ptext || picon) { 02363 QTableWidgetItem *item = new QTableWidgetItem; 02364 if (ptext != 0 && ptext->elementString()) { 02365 item->setText(ptext->elementString()->text()); 02366 } 02367 02368 if (picon && picon->kind() == DomProperty::IconSet) { 02369 DomResourcePixmap *icon = picon->elementIconSet(); 02370 Q_ASSERT(icon != 0); 02371 QString iconPath = icon->text(); 02372 QString qrcPath = icon->attributeResource(); 02373 02374 item->setIcon(nameToIcon(iconPath, qrcPath)); 02375 } 02376 tableWidget->setVerticalHeaderItem(i, item); 02377 } 02378 } 02379 02380 foreach (DomItem *ui_item, ui_widget->elementItem()) { 02381 if (ui_item->hasAttributeRow() && ui_item->hasAttributeColumn()) { 02382 QTableWidgetItem *item = new QTableWidgetItem; 02383 foreach (DomProperty *property, ui_item->elementProperty()) { 02384 if (property->attributeName() == QLatin1String("text") && 02385 property->elementString()) { 02386 item->setText(property->elementString()->text()); 02387 } else if (property->attributeName() == QLatin1String("icon") && 02388 property->kind() == DomProperty::IconSet) { 02389 DomResourcePixmap *icon = property->elementIconSet(); 02390 Q_ASSERT(icon != 0); 02391 QString iconPath = icon->text(); 02392 QString qrcPath = icon->attributeResource(); 02393 02394 item->setIcon(nameToIcon(iconPath, qrcPath)); 02395 } 02396 02397 } 02398 tableWidget->setItem(ui_item->attributeRow(), ui_item->attributeColumn(), item); 02399 } 02400 } 02401 }
Here is the call graph for this function:

| void QAbstractFormBuilder::loadComboBoxExtraInfo | ( | DomWidget * | ui_widget, | |
| QComboBox * | comboBox, | |||
| QWidget * | parentWidget | |||
| ) | [protected] |
Definition at line 2406 of file abstractformbuilder.cpp.
References QComboBox::addItem(), QComboBox::count(), DomWidget::elementItem(), DomProperty::elementNumber(), DomItem::elementProperty(), DomWidget::elementProperty(), DomProperty::IconSet, nameToIcon(), p, properties, propertyMap(), QComboBox::setCurrentIndex(), QComboBox::setItemData(), and value.
Referenced by loadExtraInfo().
02407 { 02408 Q_UNUSED(parentWidget); 02409 02410 foreach (DomItem *ui_item, ui_widget->elementItem()) { 02411 QHash<QString, DomProperty*> properties = propertyMap(ui_item->elementProperty()); 02412 QString text; 02413 QIcon icon; 02414 02415 DomProperty *p = 0; 02416 02417 p = properties.value(QLatin1String("text")); 02418 if (p && p->elementString()) { 02419 text = p->elementString()->text(); 02420 } 02421 02422 p = properties.value(QLatin1String("icon")); 02423 if (p && p->kind() == DomProperty::IconSet) { 02424 DomResourcePixmap *picon = p->elementIconSet(); 02425 Q_ASSERT(picon != 0); 02426 QString iconPath = picon->text(); 02427 QString qrcPath = picon->attributeResource(); 02428 02429 icon = nameToIcon(iconPath, qrcPath); 02430 } 02431 02432 comboBox->addItem(icon, text); 02433 comboBox->setItemData((comboBox->count()-1), icon); 02434 } 02435 02436 DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value("currentIndex"); 02437 if (currentIndex) 02438 comboBox->setCurrentIndex(currentIndex->elementNumber()); 02439 }
Here is the call graph for this function:

| void QAbstractFormBuilder::saveListWidgetExtraInfo | ( | QListWidget * | widget, | |
| DomWidget * | ui_widget, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected] |
Definition at line 2097 of file abstractformbuilder.cpp.
References QList< T >::append(), QListWidget::count(), DomWidget::elementItem(), i, iconToFilePath(), iconToQrcPath(), QString::isEmpty(), QListWidget::item(), p, properties, DomResourcePixmap::setAttributeResource(), DomWidget::setElementItem(), DomItem::setElementProperty(), DomString::setText(), and DomResourcePixmap::setText().
Referenced by saveExtraInfo().
02098 { 02099 Q_UNUSED(ui_parentWidget); 02100 02101 QList<DomItem*> ui_items = ui_widget->elementItem(); 02102 02103 for (int i=0; i<listWidget->count(); ++i) { 02104 QListWidgetItem *item = listWidget->item(i); 02105 DomItem *ui_item = new DomItem(); 02106 02107 QList<DomProperty*> properties; 02108 02109 // text 02110 DomString *str = new DomString; 02111 str->setText(item->text()); 02112 02113 DomProperty *p = 0; 02114 02115 p = new DomProperty; 02116 p->setAttributeName(QLatin1String("text")); 02117 p->setElementString(str); 02118 properties.append(p); 02119 02120 if (!item->icon().isNull()) { 02121 QString iconPath = iconToFilePath(item->icon()); 02122 QString qrcPath = iconToQrcPath(item->icon()); 02123 02124 p = new DomProperty; 02125 02126 DomResourcePixmap *pix = new DomResourcePixmap; 02127 if (!qrcPath.isEmpty()) 02128 pix->setAttributeResource(qrcPath); 02129 02130 pix->setText(iconPath); 02131 02132 p->setAttributeName(QLatin1String("icon")); 02133 p->setElementIconSet(pix); 02134 02135 properties.append(p); 02136 } 02137 02138 ui_item->setElementProperty(properties); 02139 ui_items.append(ui_item); 02140 } 02141 02142 ui_widget->setElementItem(ui_items); 02143 }
Here is the call graph for this function:

| void QAbstractFormBuilder::saveTreeWidgetExtraInfo | ( | QTreeWidget * | treeWidget, | |
| DomWidget * | ui_widget, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected] |
Definition at line 1858 of file abstractformbuilder.cpp.
References QList< T >::append(), c, QTreeWidgetItem::child(), QTreeWidgetItem::childCount(), QTreeWidget::columnCount(), QQueue< T >::dequeue(), DomItem::elementItem(), DomWidget::elementItem(), QQueue< T >::enqueue(), QTreeWidget::headerItem(), i, QTreeWidgetItem::icon(), iconToFilePath(), iconToQrcPath(), QList< T >::isEmpty(), QString::isEmpty(), QIcon::isNull(), p, properties, qMakePair(), DomProperty::setAttributeName(), DomResourcePixmap::setAttributeResource(), DomWidget::setElementColumn(), DomItem::setElementItem(), DomWidget::setElementItem(), DomItem::setElementProperty(), DomProperty::setElementString(), DomString::setText(), DomResourcePixmap::setText(), QTreeWidgetItem::text(), QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by saveExtraInfo().
01859 { 01860 Q_UNUSED(ui_parentWidget); 01861 01862 QList<DomColumn*> columns; 01863 01864 // save the header 01865 for (int c = 0; c<treeWidget->columnCount(); ++c) { 01866 DomColumn *column = new DomColumn; 01867 01868 QList<DomProperty*> properties; 01869 01870 // property text 01871 DomProperty *ptext = new DomProperty; 01872 DomString *str = new DomString; 01873 str->setText(treeWidget->headerItem()->text(c)); 01874 ptext->setAttributeName(QLatin1String("text")); 01875 ptext->setElementString(str); 01876 properties.append(ptext); 01877 01878 QIcon icon = treeWidget->headerItem()->icon(c); 01879 if (!icon.isNull()) { 01880 QString iconPath = iconToFilePath(icon); 01881 QString qrcPath = iconToQrcPath(icon); 01882 01883 DomProperty *p = new DomProperty; 01884 01885 DomResourcePixmap *pix = new DomResourcePixmap; 01886 if (!qrcPath.isEmpty()) 01887 pix->setAttributeResource(qrcPath); 01888 01889 pix->setText(iconPath); 01890 01891 p->setAttributeName(QLatin1String("icon")); 01892 p->setElementIconSet(pix); 01893 01894 properties.append(p); 01895 } 01896 01897 column->setElementProperty(properties); 01898 columns.append(column); 01899 } 01900 01901 ui_widget->setElementColumn(columns); 01902 01903 QList<DomItem *> items = ui_widget->elementItem(); 01904 01905 QQueue<QPair<QTreeWidgetItem *, DomItem *> > pendingQueue; 01906 for (int i = 0; i < treeWidget->topLevelItemCount(); i++) 01907 pendingQueue.enqueue(qMakePair(treeWidget->topLevelItem(i), (DomItem *)0)); 01908 01909 while (!pendingQueue.isEmpty()) { 01910 QPair<QTreeWidgetItem *, DomItem *> pair = pendingQueue.dequeue(); 01911 QTreeWidgetItem *item = pair.first; 01912 DomItem *parentDomItem = pair.second; 01913 01914 DomItem *currentDomItem = new DomItem; 01915 01916 QList<DomProperty*> properties; 01917 for (int c = 0; c < treeWidget->columnCount(); c++) { 01918 DomProperty *ptext = new DomProperty; 01919 DomString *str = new DomString; 01920 str->setText(item->text(c)); 01921 ptext->setAttributeName(QLatin1String("text")); 01922 ptext->setElementString(str); 01923 properties.append(ptext); 01924 01925 QIcon icon = item->icon(c); 01926 if (!icon.isNull()) { 01927 QString iconPath = iconToFilePath(icon); 01928 QString qrcPath = iconToQrcPath(icon); 01929 01930 DomProperty *p = new DomProperty; 01931 01932 DomResourcePixmap *pix = new DomResourcePixmap; 01933 if (!qrcPath.isEmpty()) 01934 pix->setAttributeResource(qrcPath); 01935 01936 pix->setText(iconPath); 01937 01938 p->setAttributeName(QLatin1String("icon")); 01939 p->setElementIconSet(pix); 01940 01941 properties.append(p); 01942 } 01943 01944 } 01945 currentDomItem->setElementProperty(properties); 01946 01947 if (parentDomItem) { 01948 QList<DomItem *> childrenItems = parentDomItem->elementItem(); 01949 childrenItems.append(currentDomItem); 01950 parentDomItem->setElementItem(childrenItems); 01951 } else 01952 items.append(currentDomItem); 01953 01954 for (int i = 0; i < item->childCount(); i++) 01955 pendingQueue.enqueue(qMakePair(item->child(i), currentDomItem)); 01956 } 01957 01958 ui_widget->setElementItem(items); 01959 }
Here is the call graph for this function:

| void QAbstractFormBuilder::saveTableWidgetExtraInfo | ( | QTableWidget * | tablWidget, | |
| DomWidget * | ui_widget, | |||
| DomWidget * | ui_parentWidget | |||
| ) | [protected] |
Definition at line 1964 of file abstractformbuilder.cpp.
References QList< T >::append(), c, QTableWidget::columnCount(), DomWidget::elementItem(), QTableWidget::horizontalHeaderItem(), QTableWidgetItem::icon(), iconToFilePath(), iconToQrcPath(), QString::isEmpty(), QIcon::isNull(), QTableWidget::item(), p, properties, row, QTableWidget::rowCount(), DomItem::setAttributeColumn(), DomProperty::setAttributeName(), DomResourcePixmap::setAttributeResource(), DomItem::setAttributeRow(), DomWidget::setElementColumn(), DomWidget::setElementItem(), DomItem::setElementProperty(), DomWidget::setElementRow(), DomProperty::setElementString(), DomString::setText(), DomResourcePixmap::setText(), QTableWidgetItem::text(), and QTableWidget::verticalHeaderItem().
Referenced by saveExtraInfo().
01965 { 01966 Q_UNUSED(ui_parentWidget); 01967 01968 // save the horizontal header 01969 QList<DomColumn*> columns; 01970 for (int c = 0; c < tableWidget->columnCount(); c++) { 01971 DomColumn *column = new DomColumn; 01972 QList<DomProperty*> properties; 01973 QTableWidgetItem *item = tableWidget->horizontalHeaderItem(c); 01974 if (item) { 01975 // property text 01976 DomProperty *ptext = new DomProperty; 01977 DomString *str = new DomString; 01978 str->setText(item->text()); 01979 ptext->setAttributeName(QLatin1String("text")); 01980 ptext->setElementString(str); 01981 properties.append(ptext); 01982 01983 QIcon icon = item->icon(); 01984 if (!icon.isNull()) { 01985 QString iconPath = iconToFilePath(icon); 01986 QString qrcPath = iconToQrcPath(icon); 01987 01988 DomProperty *p = new DomProperty; 01989 01990 DomResourcePixmap *pix = new DomResourcePixmap; 01991 if (!qrcPath.isEmpty()) 01992 pix->setAttributeResource(qrcPath); 01993 01994 pix->setText(iconPath); 01995 01996 p->setAttributeName(QLatin1String("icon")); 01997 p->setElementIconSet(pix); 01998 01999 properties.append(p); 02000 } 02001 } 02002 02003 column->setElementProperty(properties); 02004 columns.append(column); 02005 } 02006 ui_widget->setElementColumn(columns); 02007 02008 // save the vertical header 02009 QList<DomRow*> rows; 02010 for (int r = 0; r < tableWidget->rowCount(); r++) { 02011 DomRow *row = new DomRow; 02012 QList<DomProperty*> properties; 02013 QTableWidgetItem *item = tableWidget->verticalHeaderItem(r); 02014 if (item) { 02015 // property text 02016 DomProperty *ptext = new DomProperty; 02017 DomString *str = new DomString; 02018 str->setText(item->text()); 02019 ptext->setAttributeName(QLatin1String("text")); 02020 ptext->setElementString(str); 02021 properties.append(ptext); 02022 02023 QIcon icon = item->icon(); 02024 if (!icon.isNull()) { 02025 QString iconPath = iconToFilePath(icon); 02026 QString qrcPath = iconToQrcPath(icon); 02027 02028 DomProperty *p = new DomProperty; 02029 02030 DomResourcePixmap *pix = new DomResourcePixmap; 02031 if (!qrcPath.isEmpty()) 02032 pix->setAttributeResource(qrcPath); 02033 02034 pix->setText(iconPath); 02035 02036 p->setAttributeName(QLatin1String("icon")); 02037 p->setElementIconSet(pix); 02038 02039 properties.append(p); 02040 } 02041 } 02042 02043 row->setElementProperty(properties); 02044 rows.append(row); 02045 } 02046 ui_widget->setElementRow(rows); 02047 02048 QList<DomItem *> items = ui_widget->elementItem(); 02049 02050 for (int r = 0; r < tableWidget->rowCount(); r++) 02051 for (int c = 0; c < tableWidget->columnCount(); c++) { 02052 QTableWidgetItem *item = tableWidget->item(r, c); 02053 if (item) { 02054 DomItem *domItem = new DomItem; 02055 domItem->setAttributeRow(r); 02056 domItem->setAttributeColumn(c); 02057 QList<DomProperty*> properties; 02058 02059 DomProperty *pt