tools/designer/src/components/widgetbox/widgetbox.cpp File Reference

#include "widgetbox.h"
#include <QtDesigner/QtDesigner>
#include <pluginmanager_p.h>
#include <sheet_delegate_p.h>
#include <iconloader_p.h>
#include <ui4_p.h>
#include <QtGui/QtGui>
#include <QtCore/qdebug.h>
#include "widgetbox_dnditem.h"
#include "widgetbox.moc"

Include dependency graph for widgetbox.cpp:

Go to the source code of this file.

Namespaces

namespace  qdesigner_internal

Classes

class  qdesigner_internal::WidgetBoxItemDelegate
class  qdesigner_internal::WidgetBoxTreeView

Defines

#define SCRATCHPAD_ITEM   1
#define CUSTOM_ITEM   2

Typedefs

typedef QList< QDomElementElementList

Functions

static QDomElement childElement (QDomNode node, const QString &tag, const QString &attr_name, const QString &attr_value)
static void _childElementList (QDomNode node, const QString &tag, const QString &attr_name, const QString &attr_value, ElementList *result)
static QString domToString (const QDomElement &elt)
static QDomDocument stringToDom (const QString &xml)
static DomWidgetxmlToUi (QString xml)
static int findCategory (const QString &name, const WidgetBoxTreeView::CategoryList &list)


Define Documentation

#define CUSTOM_ITEM   2

Definition at line 45 of file widgetbox.cpp.

#define SCRATCHPAD_ITEM   1

Definition at line 44 of file widgetbox.cpp.

Referenced by qdesigner_internal::WidgetBoxTreeView::addCategory(), qdesigner_internal::WidgetBoxTreeView::addWidget(), qdesigner_internal::WidgetBoxTreeView::category(), qdesigner_internal::WidgetBoxTreeView::contextMenuEvent(), qdesigner_internal::WidgetBoxTreeView::indexOfScratchpad(), and qdesigner_internal::WidgetBoxTreeView::removeCurrentItem().


Typedef Documentation

typedef QList<QDomElement> ElementList

Definition at line 82 of file widgetbox.cpp.


Function Documentation

static void _childElementList ( QDomNode  node,
const QString tag,
const QString attr_name,
const QString attr_value,
ElementList result 
) [static]

Definition at line 83 of file widgetbox.cpp.

References QList< T >::append(), QDomNode::firstChild(), QDomNode::isElement(), QString::isEmpty(), QDomNode::isNull(), QDomNode::nextSibling(), and QDomNode::toElement().

00087 {
00088     if (node.isElement()) {
00089         QDomElement elt = node.toElement();
00090         if (elt.tagName() == tag) {
00091             if (attr_name.isEmpty()) {
00092                 result->append(elt);
00093             } else if (elt.hasAttribute(attr_name)) {
00094                 if (attr_value.isEmpty())
00095                     result->append(elt);
00096                 else if (elt.attribute(attr_name) == attr_value)
00097                     result->append(elt);
00098             }
00099         }
00100     }
00101 
00102     QDomNode child = node.firstChild();
00103     for (; !child.isNull(); child = child.nextSibling())
00104         _childElementList(child, tag, attr_name, attr_value, result);
00105 }

Here is the call graph for this function:

static QDomElement childElement ( QDomNode  node,
const QString tag,
const QString attr_name,
const QString attr_value 
) [static]

Definition at line 54 of file widgetbox.cpp.

References QDomNode::firstChild(), QDomNode::isElement(), QString::isEmpty(), QDomNode::isNull(), QDomNode::nextSibling(), and QDomNode::toElement().

00057 {
00058     if (node.isElement()) {
00059         QDomElement elt = node.toElement();
00060         if (elt.tagName() == tag) {
00061             if (attr_name.isEmpty())
00062                 return elt;
00063             if (elt.hasAttribute(attr_name)) {
00064                 if (attr_value.isEmpty())
00065                     return elt;
00066                 if (elt.attribute(attr_name) == attr_value)
00067                     return elt;
00068             }
00069         }
00070     }
00071 
00072     QDomNode child = node.firstChild();
00073     for (; !child.isNull(); child = child.nextSibling()) {
00074         QDomElement elt = childElement(child, tag, attr_name, attr_value);
00075         if (!elt.isNull())
00076             return elt;
00077     }
00078 
00079     return QDomElement();
00080 }

Here is the call graph for this function:

static QString domToString ( const QDomElement elt  )  [static]

Definition at line 107 of file widgetbox.cpp.

References QDomNode::save(), QTest::stream, and QIODevice::WriteOnly.

Referenced by qdesigner_internal::WidgetBoxTreeView::domToCategory(), qdesigner_internal::WidgetBoxTreeView::dropWidgets(), and qdesigner_internal::WidgetBoxTreeView::updateItemData().

00108 {
00109     QString result;
00110     QTextStream stream(&result, QIODevice::WriteOnly);
00111     elt.save(stream, 2);
00112     stream.flush();
00113     return result;
00114 }

Here is the call graph for this function:

static int findCategory ( const QString name,
const WidgetBoxTreeView::CategoryList &  list 
) [static]

Definition at line 553 of file widgetbox.cpp.

References name, and QDesignerWidgetBoxInterface::Category::name().

Referenced by qdesigner_internal::WidgetBoxTreeView::loadCustomCategoryList().

00554 {
00555     int idx = 0;
00556     foreach (const WidgetBoxTreeView::Category &cat, list) {
00557         if (cat.name() == name)
00558             return idx;
00559         ++idx;
00560     }
00561     return -1;
00562 }

Here is the call graph for this function:

static QDomDocument stringToDom ( const QString xml  )  [static]

Definition at line 116 of file widgetbox.cpp.

References QDomDocument::setContent().

Referenced by qdesigner_internal::WidgetBoxTreeView::updateItemData().

00117 {
00118     QDomDocument result;
00119     result.setContent(xml);
00120     return result;
00121 }

Here is the call graph for this function:

static DomWidget* xmlToUi ( QString  xml  )  [static]

Definition at line 123 of file widgetbox.cpp.

References QByteArray::constData(), QDomNode::firstChildElement(), QDomNode::nodeName(), qWarning(), DomWidget::read(), QDomDocument::setContent(), and QString::toUtf8().

Referenced by qdesigner_internal::WidgetBoxTreeView::categoryListToDom(), and qdesigner_internal::WidgetBox::handleMousePress().

00124 {
00125     QDomDocument doc;
00126     QString err_msg;
00127     int err_line, err_col;
00128     if (!doc.setContent(xml, &err_msg, &err_line, &err_col)) {
00129         qWarning("xmlToUi: parse failed:\n%s\n:%d:%d: %s",
00130                     xml.toUtf8().constData(),
00131                     err_line, err_col,
00132                     err_msg.toUtf8().constData());
00133         return 0;
00134     }
00135 
00136     QDomElement dom_elt = doc.firstChildElement();
00137     if (dom_elt.nodeName() != QLatin1String("widget")) {
00138         qWarning("xmlToUi: invalid root element:\n%s", xml.toUtf8().constData());
00139         return 0;
00140     }
00141 
00142     DomWidget *widget = new DomWidget;
00143     widget->read(dom_elt);
00144     return widget;
00145 }

Here is the call graph for this function:


Generated on Thu Mar 15 14:21:46 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1