

Definition at line 167 of file widgetbox.cpp.
Definition at line 172 of file widgetbox.cpp.
Definition at line 173 of file widgetbox.cpp.
| typedef QDesignerWidgetBoxInterface::CategoryList qdesigner_internal::WidgetBoxTreeView::CategoryList |
Definition at line 174 of file widgetbox.cpp.
| WidgetBoxTreeView::WidgetBoxTreeView | ( | QDesignerFormEditorInterface * | core, | |
| QWidget * | parent = 0 | |||
| ) |
Definition at line 247 of file widgetbox.cpp.
References QAbstractItemView::AnyKeyPressed, QObject::connect(), handleMousePress(), QTreeView::header(), QWidget::hide(), QTreeWidget::itemChanged(), QTreeWidget::itemPressed(), m_core, Qt::NoFocus, QTreeWidget::setColumnCount(), QAbstractItemView::setEditTriggers(), QWidget::setFocusPolicy(), QAbstractItemView::setIconSize(), QAbstractItemView::setItemDelegate(), QHeaderView::setResizeMode(), QTreeView::setRootIsDecorated(), SIGNAL, SLOT, QHeaderView::Stretch, and updateItemData().
00248 : QTreeWidget(parent) 00249 { 00250 setFocusPolicy(Qt::NoFocus); 00251 setIconSize(QSize(22, 22)); 00252 00253 setItemDelegate(new WidgetBoxItemDelegate(this, this)); 00254 setRootIsDecorated(false); 00255 setColumnCount(1); 00256 header()->hide(); 00257 header()->setResizeMode(QHeaderView::Stretch); 00258 00259 m_core = core; 00260 00261 connect(this, SIGNAL(itemPressed(QTreeWidgetItem*,int)), 00262 this, SLOT(handleMousePress(QTreeWidgetItem*))); 00263 connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), 00264 this, SLOT(updateItemData(QTreeWidgetItem*))); 00265 00266 setEditTriggers(QAbstractItemView::AnyKeyPressed); 00267 }
Here is the call graph for this function:

| WidgetBoxTreeView::~WidgetBoxTreeView | ( | ) |
Definition at line 269 of file widgetbox.cpp.
References QList< T >::append(), QSettings::beginGroup(), categoryCount(), QSettings::endGroup(), i, QTreeWidget::isItemExpanded(), QSettings::setValue(), and QTreeWidget::topLevelItem().
00270 { 00271 QSettings settings; 00272 settings.beginGroup(QLatin1String("WidgetBox")); 00273 00274 QStringList open_cat; 00275 for (int i = 0; i < categoryCount(); ++i) { 00276 QTreeWidgetItem *cat_item = topLevelItem(i); 00277 if (isItemExpanded(cat_item)) 00278 open_cat.append(cat_item->text(0)); 00279 } 00280 settings.setValue(QLatin1String("open categories"), open_cat); 00281 00282 settings.endGroup(); 00283 }
Here is the call graph for this function:

| int WidgetBoxTreeView::categoryCount | ( | ) | const |
Definition at line 649 of file widgetbox.cpp.
References QTreeWidget::topLevelItemCount().
Referenced by qdesigner_internal::WidgetBox::categoryCount(), indexOfScratchpad(), save(), and ~WidgetBoxTreeView().
00650 { 00651 return topLevelItemCount(); 00652 }
Here is the call graph for this function:

| WidgetBoxTreeView::Category WidgetBoxTreeView::category | ( | int | cat_idx | ) | const |
Definition at line 654 of file widgetbox.cpp.
References QDesignerWidgetBoxInterface::Category::addWidget(), QTreeWidgetItem::child(), QTreeWidgetItem::childCount(), QTreeWidgetItem::data(), QDesignerWidgetBoxInterface::Category::Default, i, itemToWidget(), j, QDesignerWidgetBoxInterface::Category::Scratchpad, SCRATCHPAD_ITEM, QDesignerWidgetBoxInterface::Category::setName(), QDesignerWidgetBoxInterface::Category::setType(), QTreeWidgetItem::text(), QVariant::toInt(), QTreeWidget::topLevelItem(), QTreeWidget::topLevelItemCount(), and Qt::UserRole.
Referenced by qdesigner_internal::WidgetBox::category(), and save().
00655 { 00656 Category result; 00657 00658 if (cat_idx >= topLevelItemCount()) 00659 return result; 00660 00661 QTreeWidgetItem *cat_item = topLevelItem(cat_idx); 00662 result.setName(cat_item->text(0)); 00663 00664 for (int i = 0; i < cat_item->childCount(); ++i) { 00665 QTreeWidgetItem *child = cat_item->child(i); 00666 result.addWidget(itemToWidget(child)); 00667 } 00668 00669 int j = cat_item->data(0, Qt::UserRole).toInt(); 00670 if (j == SCRATCHPAD_ITEM) 00671 result.setType(Category::Scratchpad); 00672 else 00673 result.setType(Category::Default); 00674 00675 return result; 00676 }
Here is the call graph for this function:

| void WidgetBoxTreeView::addCategory | ( | const Category & | cat | ) |
Definition at line 678 of file widgetbox.cpp.
References i, indexOfCategory(), QDesignerWidgetBoxInterface::Category::name(), QDesignerWidgetBoxInterface::Category::Scratchpad, SCRATCHPAD_ITEM, QTreeWidget::setItemExpanded(), QTreeWidget::topLevelItem(), QDesignerWidgetBoxInterface::Category::type(), Qt::UserRole, QDesignerWidgetBoxInterface::Category::widget(), QDesignerWidgetBoxInterface::Category::widgetCount(), and widgetToItem().
Referenced by qdesigner_internal::WidgetBox::addCategory(), and load().
00679 { 00680 if (cat.widgetCount() == 0) 00681 return; 00682 00683 int idx = indexOfCategory(cat.name()); 00684 QTreeWidgetItem *cat_item = 0; 00685 if (idx == -1) { 00686 cat_item = new QTreeWidgetItem(this); 00687 cat_item->setText(0, cat.name()); 00688 setItemExpanded(cat_item, true); 00689 00690 if (cat.type() == Category::Scratchpad) 00691 cat_item->setData(0, Qt::UserRole, SCRATCHPAD_ITEM); 00692 } else { 00693 cat_item = topLevelItem(idx); 00694 } 00695 00696 for (int i = 0; i < cat.widgetCount(); ++i) 00697 widgetToItem(cat.widget(i), cat_item, cat.type() == Category::Scratchpad); 00698 }
Here is the call graph for this function:

| void WidgetBoxTreeView::removeCategory | ( | int | cat_idx | ) |
Definition at line 700 of file widgetbox.cpp.
References QTreeWidget::takeTopLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by qdesigner_internal::WidgetBox::removeCategory().
00701 { 00702 if (cat_idx >= topLevelItemCount()) 00703 return; 00704 delete takeTopLevelItem(cat_idx); 00705 }
Here is the call graph for this function:

| int WidgetBoxTreeView::widgetCount | ( | int | cat_idx | ) | const |
Definition at line 707 of file widgetbox.cpp.
References QTreeWidgetItem::childCount(), QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by qdesigner_internal::WidgetBox::widgetCount().
00708 { 00709 if (cat_idx >= topLevelItemCount()) 00710 return 0; 00711 00712 return topLevelItem(cat_idx)->childCount(); 00713 }
Here is the call graph for this function:

| WidgetBoxTreeView::Widget WidgetBoxTreeView::widget | ( | int | cat_idx, | |
| int | wgt_idx | |||
| ) | const |
Definition at line 715 of file widgetbox.cpp.
References QTreeWidgetItem::child(), QTreeWidgetItem::childCount(), itemToWidget(), QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by updateItemData(), qdesigner_internal::WidgetBox::widget(), and widgetDomXml().
00716 { 00717 if (cat_idx >= topLevelItemCount()) 00718 return Widget(); 00719 00720 QTreeWidgetItem *cat_item = topLevelItem(cat_idx); 00721 00722 if (wgt_idx >= cat_item->childCount()) 00723 return Widget(); 00724 00725 return itemToWidget(cat_item->child(wgt_idx)); 00726 }
Here is the call graph for this function:

| void WidgetBoxTreeView::addWidget | ( | int | cat_idx, | |
| const Widget & | wgt | |||
| ) |
Definition at line 728 of file widgetbox.cpp.
References QTreeWidgetItem::data(), SCRATCHPAD_ITEM, QVariant::toInt(), QTreeWidget::topLevelItem(), QTreeWidget::topLevelItemCount(), Qt::UserRole, and widgetToItem().
Referenced by qdesigner_internal::WidgetBox::addWidget().
00729 { 00730 if (cat_idx >= topLevelItemCount()) 00731 return; 00732 00733 QTreeWidgetItem *cat_item = topLevelItem(cat_idx); 00734 00735 bool scratch = cat_item->data(0, Qt::UserRole).toInt() == SCRATCHPAD_ITEM; 00736 widgetToItem(wgt, cat_item, scratch); 00737 }
Here is the call graph for this function:

| void WidgetBoxTreeView::removeWidget | ( | int | cat_idx, | |
| int | wgt_idx | |||
| ) |
Definition at line 739 of file widgetbox.cpp.
References QTreeWidgetItem::childCount(), QTreeWidgetItem::takeChild(), QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by qdesigner_internal::WidgetBox::removeWidget().
00740 { 00741 if (cat_idx >= topLevelItemCount()) 00742 return; 00743 00744 QTreeWidgetItem *cat_item = topLevelItem(cat_idx); 00745 00746 if (wgt_idx >= cat_item->childCount()) 00747 return; 00748 00749 delete cat_item->takeChild(wgt_idx); 00750 }
Here is the call graph for this function:

| void WidgetBoxTreeView::dropWidgets | ( | const QList< QDesignerDnDItemInterface * > & | item_list | ) |
Definition at line 843 of file widgetbox.cpp.
References domToString(), QDesignerDnDItemInterface::domUi(), indexOfScratchpad(), save(), QApplication::setActiveWindow(), QTreeWidget::setCurrentItem(), QTreeWidget::setItemExpanded(), QTreeWidget::topLevelItem(), w, QDesignerDnDItemInterface::widget(), widgetToItem(), and DomUI::write().
Referenced by qdesigner_internal::WidgetBox::dropWidgets().
00844 { 00845 QTreeWidgetItem *last_item = 0; 00846 00847 foreach (QDesignerDnDItemInterface *item, item_list) { 00848 QWidget *w = item->widget(); 00849 if (w == 0) 00850 continue; 00851 00852 DomUI *dom_ui = item->domUi(); 00853 if (dom_ui == 0) 00854 continue; 00855 00856 int scratch_idx = indexOfScratchpad(); 00857 QTreeWidgetItem *scratch_item = topLevelItem(scratch_idx); 00858 00859 QDomDocument dom; 00860 QDomElement elt = dom_ui->write(dom); 00861 QString xml = domToString(elt 00862 .firstChildElement(QLatin1String("widget")) 00863 .firstChildElement(QLatin1String("widget"))); 00864 00865 last_item = widgetToItem(Widget(w->objectName(), xml), scratch_item, true); 00866 setItemExpanded(scratch_item, true); 00867 } 00868 00869 if (last_item != 0) { 00870 save(); 00871 QApplication::setActiveWindow(this); 00872 setCurrentItem(last_item); 00873 } 00874 }
Here is the call graph for this function:

| void WidgetBoxTreeView::setFileName | ( | const QString & | file_name | ) |
Definition at line 326 of file widgetbox.cpp.
References m_file_name.
Referenced by qdesigner_internal::WidgetBox::setFileName().
00327 { 00328 m_file_name = file_name; 00329 }
| QString WidgetBoxTreeView::fileName | ( | ) | const |
Definition at line 331 of file widgetbox.cpp.
References m_file_name.
Referenced by qdesigner_internal::WidgetBox::fileName(), load(), and save().
00332 { 00333 return m_file_name; 00334 }
| bool WidgetBoxTreeView::load | ( | ) |
Definition at line 396 of file widgetbox.cpp.
References addCategory(), QList< T >::append(), domToCateogryList(), error_msg, fileName(), i, indexOfCategory(), QTreeWidget::isItemExpanded(), loadCustomCategoryList(), name, QFile::open(), qWarning(), QIODevice::ReadOnly, QDesignerWidgetBoxInterface::Category::Scratchpad, QDomDocument::setContent(), QTreeWidget::setItemExpanded(), QList< T >::size(), QTreeWidget::topLevelItem(), QTreeWidget::topLevelItemCount(), QDesignerWidgetBoxInterface::Category::type(), and QList< T >::value().
Referenced by qdesigner_internal::WidgetBox::load().
00397 { 00398 QString name = fileName(); 00399 00400 QFile f(name); 00401 if (!f.open(QIODevice::ReadOnly)) { 00402 return false; 00403 } 00404 00405 QString error_msg; 00406 int line, col; 00407 QDomDocument doc; 00408 if (!doc.setContent(&f, &error_msg, &line, &col)) { 00409 qWarning("WidgetBox: failed to parse \"%s\": on line %d: %s", 00410 name.toUtf8().constData(), line, error_msg.toUtf8().constData()); 00411 return false; 00412 } 00413 00414 CategoryList cat_list = domToCateogryList(doc); 00415 if (cat_list.isEmpty()) 00416 return false; 00417 00418 // make sure the scratchpad is always at the end 00419 int scratch_idx = -1; 00420 for (int i = 0; i < cat_list.size(); ++i) { 00421 if (cat_list.at(i).type() == Category::Scratchpad) { 00422 scratch_idx = i; 00423 break; 00424 } 00425 } 00426 00427 foreach(Category cat, cat_list) { 00428 if (cat.type() != Category::Scratchpad) 00429 addCategory(cat); 00430 } 00431 00432 CategoryList custom_cat_list = loadCustomCategoryList(); 00433 foreach (Category cat, custom_cat_list) 00434 addCategory(cat); 00435 00436 if (scratch_idx != -1) 00437 addCategory(cat_list.at(scratch_idx)); 00438 00439 // Restore which items are expanded 00440 00441 QSettings settings; 00442 settings.beginGroup(QLatin1String("WidgetBox")); 00443 00444 QStringList closed_cat; 00445 for (int i = 0; i < topLevelItemCount(); ++i) { 00446 QTreeWidgetItem *item = topLevelItem(i); 00447 if (!isItemExpanded(item)) 00448 closed_cat.append(item->text(0)); 00449 } 00450 00451 closed_cat = settings.value(QLatin1String("Closed categories"), closed_cat).toStringList(); 00452 for (int i = 0; i < closed_cat.size(); ++i) { 00453 int cat_idx = indexOfCategory(closed_cat[i]); 00454 if (cat_idx == -1) 00455 continue; 00456 QTreeWidgetItem *item = topLevelItem(cat_idx); 00457 if (item == 0) 00458 continue; 00459 setItemExpanded(item, false); 00460 } 00461 00462 settings.endGroup(); 00463 00464 return true; 00465 }
Here is the call graph for this function:

| bool WidgetBoxTreeView::save | ( | ) |
Definition at line 336 of file widgetbox.cpp.
References category(), categoryCount(), categoryListToDom(), fileName(), i, isEmpty(), QFile::open(), QDomNode::save(), QTest::stream, and QIODevice::WriteOnly.
Referenced by dropWidgets(), removeCurrentItem(), qdesigner_internal::WidgetBox::save(), and updateItemData().
00337 { 00338 if (fileName().isEmpty()) 00339 return false; 00340 00341 QFile file(fileName()); 00342 if (!file.open(QIODevice::WriteOnly)) 00343 return false; 00344 00345 CategoryList cat_list; 00346 for (int i = 0; i < categoryCount(); ++i) 00347 cat_list.append(category(i)); 00348 00349 QDomDocument doc = categoryListToDom(cat_list); 00350 QTextStream stream(&file); 00351 doc.save(stream, 4); 00352 00353 return true; 00354 }
Here is the call graph for this function:

| void qdesigner_internal::WidgetBoxTreeView::pressed | ( | const QString | dom_xml, | |
| const QPoint & | global_mouse_pos | |||
| ) | [signal] |
Referenced by handleMousePress().
| void WidgetBoxTreeView::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive context menu events for the viewport() widget. The event is passed in e.
Reimplemented from QAbstractScrollArea.
Definition at line 821 of file widgetbox.cpp.
References QEvent::accept(), QMenu::addAction(), QTreeWidgetItem::data(), editCurrentItem(), QMenu::exec(), QEvent::ignore(), QTreeWidget::itemAt(), QWidget::mapToGlobal(), QTreeWidgetItem::parent(), QContextMenuEvent::pos(), removeCurrentItem(), SCRATCHPAD_ITEM, QTreeWidget::setCurrentItem(), SLOT, QVariant::toInt(), and Qt::UserRole.
00822 { 00823 QPoint global_pos = mapToGlobal(e->pos()); 00824 QTreeWidgetItem *item = itemAt(e->pos()); 00825 00826 bool scratchpad_menu = item != 0 00827 && item->parent() != 0 00828 && item->parent()->data(0, Qt::UserRole).toInt() 00829 == SCRATCHPAD_ITEM; 00830 00831 if (scratchpad_menu) { 00832 e->accept(); 00833 setCurrentItem(item); 00834 QMenu *menu = new QMenu(this); 00835 menu->addAction(tr("Remove"), this, SLOT(removeCurrentItem())); 00836 menu->addAction(tr("Edit name"), this, SLOT(editCurrentItem())); 00837 menu->exec(global_pos); 00838 } else { 00839 e->ignore(); 00840 } 00841 }
Here is the call graph for this function:

| void WidgetBoxTreeView::handleMousePress | ( | QTreeWidgetItem * | item | ) | [private, slot] |
Definition at line 356 of file widgetbox.cpp.
References QTreeWidgetItem::data(), emit, QTreeWidget::isItemExpanded(), QDesignerWidgetBoxInterface::Widget::isNull(), QTreeWidgetItem::parent(), QCursor::pos(), pressed(), QTreeWidget::setItemExpanded(), Qt::UserRole, and widgetDomXml().
Referenced by WidgetBoxTreeView().
00357 { 00358 if (item == 0) 00359 return; 00360 00361 if (item->parent() == 0) { 00362 setItemExpanded(item, !isItemExpanded(item)); 00363 return; 00364 } 00365 00366 QDesignerWidgetBoxInterface::Widget wgt = qvariant_cast<QDesignerWidgetBoxInterface::Widget>(item->data(0, Qt::UserRole)); 00367 if (wgt.isNull()) 00368 return; 00369 00370 emit pressed(widgetDomXml(wgt), QCursor::pos()); 00371 }
| void WidgetBoxTreeView::removeCurrentItem | ( | ) | [private, slot] |
Definition at line 752 of file widgetbox.cpp.
References QTreeWidget::currentItem(), QTreeWidget::indexOfTopLevelItem(), QMetaObject::invokeMethod(), QTreeWidgetItem::parent(), QObject::parent(), Qt::QueuedConnection, save(), SCRATCHPAD_ITEM, QTreeWidget::setItemExpanded(), QTreeWidget::takeTopLevelItem(), and Qt::UserRole.
Referenced by contextMenuEvent().
00753 { 00754 QTreeWidgetItem *item = currentItem(); 00755 if (item == 0) 00756 return; 00757 00758 QTreeWidgetItem *parent = item->parent(); 00759 if (parent == 0) { 00760 takeTopLevelItem(indexOfTopLevelItem(item)); 00761 } else { 00762 parent->takeChild(parent->indexOfChild(item)); 00763 setItemExpanded(parent, true); 00764 if (parent->data(0, Qt::UserRole).toInt() == SCRATCHPAD_ITEM 00765 && parent->childCount() == 0) { 00766 QMetaObject::invokeMethod(this, "deleteScratchpad", 00767 Qt::QueuedConnection); 00768 } 00769 } 00770 delete item; 00771 00772 save(); 00773 }
| void WidgetBoxTreeView::editCurrentItem | ( | ) | [private, slot] |
Definition at line 812 of file widgetbox.cpp.
References QAbstractItemView::currentIndex(), QAbstractItemView::edit(), and index.
Referenced by contextMenuEvent().
00813 { 00814 QModelIndex index = currentIndex(); 00815 if (!index.isValid()) 00816 return; 00817 00818 edit(index); 00819 }
| void WidgetBoxTreeView::updateItemData | ( | QTreeWidgetItem * | item | ) | [private, slot] |
Definition at line 783 of file widgetbox.cpp.
References QObject::blockSignals(), QTreeWidgetItem::data(), domToString(), QDomNode::firstChildElement(), QString::isEmpty(), QDomNode::isNull(), QDesignerWidgetBoxInterface::Widget::name(), QTreeWidgetItem::parent(), qVariantFromValue(), save(), QDomElement::setAttribute(), QTreeWidgetItem::setData(), QDesignerWidgetBoxInterface::Widget::setDomXml(), QDesignerWidgetBoxInterface::Widget::setName(), QTreeWidgetItem::setText(), stringToDom(), QTreeWidgetItem::text(), Qt::UserRole, widget(), and widgetDomXml().
Referenced by WidgetBoxTreeView().
00784 { 00785 if (item->parent() == 0) 00786 return; 00787 00788 Widget widget = qvariant_cast<Widget>(item->data(0, Qt::UserRole)); 00789 00790 if (item->text(0).isEmpty()) { 00791 QString widgetName = widget.name(); 00792 if (!widgetName.isEmpty()) 00793 item->setText(0, widgetName); 00794 return; 00795 } 00796 00797 widget.setName(item->text(0)); 00798 QDomDocument doc = stringToDom(widgetDomXml(widget)); 00799 QDomElement widget_elt = doc.firstChildElement(QLatin1String("widget")); 00800 if (!widget_elt.isNull()) { 00801 widget_elt.setAttribute(QLatin1String("name"), item->text(0)); 00802 widget.setDomXml(domToString(widget_elt)); 00803 } 00804 00805 bool block = blockSignals(true); 00806 item->setData(0, Qt::UserRole, qVariantFromValue(widget)); 00807 blockSignals(block); 00808 00809 save(); 00810 }
| void WidgetBoxTreeView::deleteScratchpad | ( | ) | [private, slot] |
Definition at line 775 of file widgetbox.cpp.
References indexOfScratchpad(), and QTreeWidget::takeTopLevelItem().
00776 { 00777 int idx = indexOfScratchpad(); 00778 if (idx == -1) 00779 return; 00780 delete takeTopLevelItem(idx); 00781 }
| WidgetBoxTreeView::CategoryList WidgetBoxTreeView::domToCateogryList | ( | const QDomDocument & | doc | ) | const [private] |
Definition at line 499 of file widgetbox.cpp.
References QByteArray::constData(), domToCategory(), QDomNode::firstChildElement(), QDesignerWidgetBoxInterface::Category::isNull(), QDomNode::isNull(), QDomNode::nextSiblingElement(), QDomNode::nodeName(), qWarning(), and QString::toUtf8().
Referenced by load().
00500 { 00501 CategoryList result; 00502 00503 QDomElement root = doc.firstChildElement(); 00504 if (root.nodeName() != QLatin1String("widgetbox")) { 00505 qWarning("WidgetCollectionModel::xmlToModel(): not a widgetbox file"); 00506 return result; 00507 } 00508 00509 QDomElement cat_elt = root.firstChildElement(); 00510 for (; !cat_elt.isNull(); cat_elt = cat_elt.nextSiblingElement()) { 00511 if (cat_elt.nodeName() != QLatin1String("category")) { 00512 qWarning("WidgetCollectionModel::xmlToModel(): bad child of widgetbox: \"%s\"", cat_elt.nodeName().toUtf8().constData()); 00513 return result; 00514 } 00515 00516 Category cat = domToCategory(cat_elt); 00517 if (!cat.isNull()) 00518 result.append(cat); 00519 } 00520 00521 return result; 00522 }
Here is the call graph for this function:

| WidgetBoxTreeView::Category WidgetBoxTreeView::domToCategory | ( | const QDomElement & | cat_elt | ) | const [private] |
Definition at line 524 of file widgetbox.cpp.
References QDesignerWidgetBoxInterface::Category::addWidget(), QDomElement::attribute(), QDesignerWidgetBoxInterface::Widget::Custom, QDesignerWidgetBoxInterface::Widget::Default, domToString(), QDomNode::firstChildElement(), QDomNode::isNull(), name, QDomNode::nextSiblingElement(), QDesignerWidgetBoxInterface::Category::Scratchpad, QDesignerWidgetBoxInterface::Category::setType(), type, and w.
Referenced by domToCateogryList().
00525 { 00526 QString name = cat_elt.attribute(QLatin1String("name")); 00527 00528 if (name == QLatin1String("[invisible]")) 00529 return Category(); 00530 00531 Category result(name); 00532 00533 if (cat_elt.attribute(QLatin1String("type")) == QLatin1String("scratchpad")) 00534 result.setType(Category::Scratchpad); 00535 00536 QDomElement widget_elt = cat_elt.firstChildElement(); 00537 for (; !widget_elt.isNull(); widget_elt = widget_elt.nextSiblingElement()) { 00538 QString type_attr = widget_elt.attribute("type"); 00539 Widget::Type type = type_attr == QLatin1String("custom") 00540 ? Widget::Custom 00541 : Widget::Default; 00542 00543 Widget w(widget_elt.attribute(QLatin1String("name")), 00544 domToString(widget_elt), 00545 widget_elt.attribute(QLatin1String("icon")), 00546 type); 00547 result.addWidget(w); 00548 } 00549 00550 return result; 00551 }
Here is the call graph for this function:

| WidgetBoxTreeView::CategoryList WidgetBoxTreeView::loadCustomCategoryList | ( | ) | const [private] |
Definition at line 564 of file widgetbox.cpp.
References QDesignerWidgetBoxInterface::Category::addWidget(), c, QDesignerWidgetBoxInterface::Widget::Custom, findCategory(), QHash< Key, T >::insert(), QString::isEmpty(), QIcon::isNull(), m_core, m_pluginIcons, QDesignerFormEditorInterface::pluginManager(), and QDesignerPluginManager::registeredCustomWidgets().
Referenced by load().
00565 { 00566 CategoryList result; 00567 00568 QDesignerPluginManager *pm = m_core->pluginManager(); 00569 00570 QList<QDesignerCustomWidgetInterface*> customWidgets = pm->registeredCustomWidgets(); 00571 00572 foreach (QDesignerCustomWidgetInterface *c, customWidgets) { 00573 QString dom_xml = c->domXml(); 00574 if (dom_xml.isEmpty()) 00575 continue; 00576 00577 QString cat_name = c->group(); 00578 if (cat_name.isEmpty()) 00579 cat_name = tr("Custom Widgets"); 00580 else if (cat_name == QLatin1String("[invisible]")) 00581 continue; 00582 00583 int idx = findCategory(cat_name, result); 00584 if (idx == -1) { 00585 result.append(Category(cat_name)); 00586 idx = result.size() - 1; 00587 } 00588 Category &cat = result[idx]; 00589 00590 QIcon icon = c->icon(); 00591 00592 QString icon_name; 00593 if (icon.isNull()) 00594 icon_name = QLatin1String("qtlogo.png"); 00595 else { 00596 icon_name = QLatin1String("__qt_icon__") + c->name(); 00597 m_pluginIcons.insert(icon_name, icon); 00598 } 00599 00600 cat.addWidget(Widget(c->name(), dom_xml, icon_name, Widget::Custom)); 00601 } 00602 00603 return result; 00604 }
Here is the call graph for this function:

| QDomDocument WidgetBoxTreeView::categoryListToDom | ( | const CategoryList & | cat_list | ) | const [private] |
Definition at line 467 of file widgetbox.cpp.
References QDomNode::appendChild(), QDomDocument::createElement(), QDesignerWidgetBoxInterface::Widget::Custom, i, QDesignerWidgetBoxInterface::Category::name(), QDesignerWidgetBoxInterface::Category::Scratchpad, QDomElement::setAttribute(), QString::startsWith(), QDesignerWidgetBoxInterface::Category::type(), QDesignerWidgetBoxInterface::Category::widget(), QDesignerWidgetBoxInterface::Category::widgetCount(), widgetDomXml(), DomWidget::write(), and xmlToUi().
Referenced by save().
00468 { 00469 QDomDocument doc; 00470 QDomElement root = doc.createElement(QLatin1String("widgetbox")); 00471 doc.appendChild(root); 00472 00473 foreach (Category cat, cat_list) { 00474 QDomElement cat_elt = doc.createElement(QLatin1String("category")); 00475 root.appendChild(cat_elt); 00476 cat_elt.setAttribute(QLatin1String("name"), cat.name()); 00477 if (cat.type() == Category::Scratchpad) 00478 cat_elt.setAttribute(QLatin1String("type"), QLatin1String("scratchpad")); 00479 for (int i = 0; i < cat.widgetCount(); ++i) { 00480 Widget wgt = cat.widget(i); 00481 if (wgt.type() == Widget::Custom) 00482 continue; 00483 00484 DomWidget *dom_wgt = xmlToUi(widgetDomXml(wgt)); 00485 QDomElement wgt_elt = dom_wgt->write(doc); 00486 wgt_elt.setAttribute(QLatin1String("name"), wgt.name()); 00487 QString iconName = wgt.iconName(); 00488 if (!iconName.startsWith("__qt_icon__")) 00489 wgt_elt.setAttribute(QLatin1String("icon"), wgt.iconName()); 00490 wgt_elt.setAttribute(QLatin1String("type"), QLatin1String("default")); 00491 cat_elt.appendChild(wgt_elt); 00492 } 00493 } 00494 00495 return doc; 00496 }
Here is the call graph for this function:

| QTreeWidgetItem * WidgetBoxTreeView::widgetToItem | ( | const Widget & | wgt, | |
| QTreeWidgetItem * | parent, | |||
| bool | editable = false | |||
| ) | [private] |
Definition at line 606 of file widgetbox.cpp.
References QList< T >::append(), QObject::blockSignals(), QStringList::contains(), qdesigner_internal::createIconSet(), QTreeWidgetItem::flags(), QDesignerWidgetBoxInterface::Widget::iconName(), QString::isEmpty(), QIcon::isNull(), Qt::ItemIsEditable, Qt::ItemIsEnabled, Qt::ItemIsSelectable, m_pluginIcons, m_widgetNames, QDesignerWidgetBoxInterface::Widget::name(), QObject::parent(), qVariantFromValue(), QTreeWidgetItem::setData(), QTreeWidgetItem::setFlags(), QTreeWidgetItem::setIcon(), QTreeWidgetItem::setText(), QString::startsWith(), Qt::UserRole, and QHash< Key, T >::value().
Referenced by addCategory(), addWidget(), and dropWidgets().
00609 { 00610 if (!editable && m_widgetNames.contains(wgt.name())) 00611 return 0; 00612 00613 QTreeWidgetItem *item = new QTreeWidgetItem(parent); 00614 item->setFlags(item->flags() & ~Qt::ItemIsSelectable); 00615 00616 QString icon_name = wgt.iconName(); 00617 if (icon_name.isEmpty()) 00618 icon_name = QLatin1String("qtlogo.png"); 00619 00620 bool block = blockSignals(true); 00621 item->setText(0, wgt.name()); 00622 00623 if (!editable) 00624 m_widgetNames.append(wgt.name()); 00625 00626 QIcon icon; 00627 if (icon_name.startsWith("__qt_icon__")) 00628 icon = m_pluginIcons.value(icon_name); 00629 if (icon.isNull()) 00630 icon = createIconSet(icon_name); 00631 item->setIcon(0, icon); 00632 item->setData(0, Qt::UserRole, qVariantFromValue(wgt)); 00633 blockSignals(block); 00634 00635 if (editable) { 00636 item->setFlags(Qt::ItemIsSelectable 00637 | Qt::ItemIsEditable 00638 | Qt::ItemIsEnabled); 00639 } 00640 00641 return item; 00642 }
Here is the call graph for this function:

| WidgetBoxTreeView::Widget WidgetBoxTreeView::itemToWidget | ( | const QTreeWidgetItem * | item | ) | const [private] |
Definition at line 644 of file widgetbox.cpp.
References QTreeWidgetItem::data(), and Qt::UserRole.
Referenced by category(), and widget().
00645 { 00646 return qvariant_cast<Widget>(item->data(0, Qt::UserRole)); 00647 }
Here is the call graph for this function:

| int WidgetBoxTreeView::indexOfCategory | ( | const QString & | name | ) | const [private] |
Definition at line 387 of file widgetbox.cpp.
References i, name, QTreeWidget::topLevelItem(), and QTreeWidget::topLevelItemCount().
Referenced by addCategory(), and load().
00388 { 00389 for (int i = 0; i < topLevelItemCount(); ++i) { 00390 if (topLevelItem(i)->text(0) == name) 00391 return i; 00392 } 00393 return -1; 00394 }
Here is the call graph for this function:

| int WidgetBoxTreeView::indexOfScratchpad | ( | ) | [private] |
Definition at line 373 of file widgetbox.cpp.
References categoryCount(), data, i, SCRATCHPAD_ITEM, QTreeWidgetItem::setData(), QTreeWidgetItem::setText(), QTreeWidget::topLevelItem(), QTreeWidget::topLevelItemCount(), and Qt::UserRole.
Referenced by deleteScratchpad(), and dropWidgets().
00374 { 00375 for (int i = 0; i < topLevelItemCount(); ++i) { 00376 if (topLevelItem(i)->data(0, Qt::UserRole).toInt() == SCRATCHPAD_ITEM) 00377 return i; 00378 } 00379 00380 QTreeWidgetItem *scratch_item = new QTreeWidgetItem(this); 00381 scratch_item->setText(0, tr("Scratchpad")); 00382 scratch_item->setData(0, Qt::UserRole, SCRATCHPAD_ITEM); 00383 00384 return categoryCount() - 1; 00385 }
Here is the call graph for this function:

Definition at line 307 of file widgetbox.cpp.
References QString::arg(), QDesignerWidgetBoxInterface::Widget::Default, QDesignerWidgetBoxInterface::Widget::domXml(), QString::fromUtf8(), QString::isEmpty(), QDesignerWidgetBoxInterface::Widget::name(), qtify(), QDesignerWidgetBoxInterface::Widget::type(), and widget().
Referenced by categoryListToDom(), handleMousePress(), and updateItemData().
00308 { 00309 QString domXml = widget.domXml(); 00310 00311 if (domXml.isEmpty()) { 00312 QString defaultVarName = qtify(widget.name()); 00313 QString typeStr = widget.type() == Widget::Default 00314 ? QLatin1String("default") 00315 : QLatin1String("custom"); 00316 00317 domXml = QString::fromUtf8("<widget class=\"%1\" name=\"%2\" type=\"%3\"/>") 00318 .arg(widget.name()) 00319 .arg(defaultVarName) 00320 .arg(typeStr); 00321 } 00322 00323 return domXml; 00324 }
Here is the call graph for this function:

Definition at line 285 of file widgetbox.cpp.
References QString::at(), QString::count(), i, QString::length(), QString::mid(), name, QChar::toLower(), and QChar::toUpper().
Referenced by widgetDomXml().
00286 { 00287 QString qname = name; 00288 00289 Q_ASSERT(name.isEmpty() == false); 00290 00291 if (qname.count() > 1 && qname.at(1).toUpper() == qname.at(1) && (qname.at(0) == QLatin1Char('Q') || qname.at(0) == QLatin1Char('K'))) 00292 qname = qname.mid(1); 00293 00294 int i=0; 00295 while (i < qname.length()) { 00296 if (qname.at(i).toLower() != qname.at(i)) 00297 qname[i] = qname.at(i).toLower(); 00298 else 00299 break; 00300 00301 ++i; 00302 } 00303 00304 return qname; 00305 }
Here is the call graph for this function:

Definition at line 210 of file widgetbox.cpp.
Referenced by loadCustomCategoryList(), and WidgetBoxTreeView().
QHash<QString, QIcon> qdesigner_internal::WidgetBoxTreeView::m_pluginIcons [mutable, private] |
Definition at line 212 of file widgetbox.cpp.
Referenced by loadCustomCategoryList(), and widgetToItem().
1.5.1