本文整理汇总了C++中DomProperty类的典型用法代码示例。如果您正苦于以下问题:C++ DomProperty类的具体用法?C++ DomProperty怎么用?C++ DomProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomProperty类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
bool Q3ListBoxExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget)
{
Q3ListBox *listBox = qobject_cast<Q3ListBox*>(widget());
Q_ASSERT(listBox != 0);
QList<DomItem *> items;
const int childCount = listBox->count();
for (int i = 0; i < childCount; ++i) {
DomItem *item = new DomItem();
QList<DomProperty*> properties;
DomString *str = new DomString();
str->setText(listBox->text(i));
DomProperty *ptext = new DomProperty();
ptext->setAttributeName(QLatin1String("text"));
ptext->setElementString(str);
properties.append(ptext);
item->setElementProperty(properties);
items.append(item);
}
ui_widget->setElementItem(items);
return true;
}
示例2: propertyMap
void DatabaseInfo::acceptWidget(DomWidget *node)
{
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0);
if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
return;
DomProperty *db = properties.value(QLatin1String("database"), 0);
if (db && db->elementStringList()) {
QStringList info = db->elementStringList()->elementString();
QString connection = info.size() > 0 ? info.at(0) : QString();
if (connection.isEmpty())
return;
m_connections.append(connection);
QString table = info.size() > 1 ? info.at(1) : QString();
if (table.isEmpty())
return;
m_cursors[connection].append(table);
QString field = info.size() > 2 ? info.at(2) : QString();
if (field.isEmpty())
return;
m_fields[connection].append(field);
}
TreeWalker::acceptWidget(node);
}
示例3: DomItem
DomItem *Q3ListViewExtraInfo::saveQ3ListViewItem(Q3ListViewItem *item) const
{
DomItem *pitem = new DomItem();
QList<DomProperty *> properties;
const int columnCount = static_cast<Q3ListView*>(widget())->columns();
for (int i = 0; i < columnCount; ++i) {
DomString *str = new DomString();
str->setText(item->text(i));
DomProperty *ptext = new DomProperty();
ptext->setAttributeName(QLatin1String("text"));
ptext->setElementString(str);
properties.append(ptext);
}
pitem->setElementProperty(properties);
QList<DomItem *> items;
Q3ListViewItem *child = item->firstChild();
while (child) {
items.append(saveQ3ListViewItem(child));
child = child->nextSibling();
}
pitem->setElementItem(items);
return pitem;
}
示例4: Q3ListViewItem
void Q3ListViewExtraInfo::initializeQ3ListViewItems(const QList<DomItem *> &items, Q3ListViewItem *parentItem)
{
for (int i=0; i<items.size(); ++i) {
DomItem *item = items.at(i);
Q3ListViewItem *__item = 0;
if (parentItem != 0)
__item = new Q3ListViewItem(parentItem);
else
__item = new Q3ListViewItem(static_cast<Q3ListView*>(widget()));
int textCount = 0, pixCount = 0;
QList<DomProperty*> properties = item->elementProperty();
for (int i=0; i<properties.size(); ++i) {
DomProperty *p = properties.at(i);
if (p->attributeName() == QLatin1String("text"))
__item->setText(textCount++, p->elementString()->text());
if (p->attributeName() == QLatin1String("pixmap")) {
DomResourcePixmap *pix = p->elementPixmap();
QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory()));
__item->setPixmap(pixCount++, pixmap);
}
}
if (item->elementItem().size()) {
__item->setOpen(true);
initializeQ3ListViewItems(item->elementItem(), __item);
}
}
}
示例5: QStringLiteral
void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
{
typedef QList<DomProperty*> DomPropertyList;
if (properties.empty())
return;
const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o);
const QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core()->extensionManager(), o);
const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == QStringLiteral("QAxWidget");
const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(o);
const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed();
QDesignerPropertySheet *designerPropertySheet = qobject_cast<QDesignerPropertySheet *>(
core()->extensionManager()->extension(o, Q_TYPEID(QDesignerPropertySheetExtension)));
if (designerPropertySheet) {
if (designerPropertySheet->pixmapCache())
designerPropertySheet->setPixmapCache(m_pixmapCache);
if (designerPropertySheet->iconCache())
designerPropertySheet->setIconCache(m_iconCache);
}
const DomPropertyList::const_iterator cend = properties.constEnd();
for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) {
DomProperty *p = *it;
QVariant v;
if (!readDomEnumerationValue(p, sheet, v))
v = toVariant(o->metaObject(), p);
if (v.isNull())
continue;
const QString attributeName = p->attributeName();
if (d->applyPropertyInternally(o, attributeName, v))
continue;
// refuse fake properties like current tab name (weak test)
if (!dynamicPropertiesAllowed) {
if (changingMetaObject) // Changes after setting control of QAxWidget
meta = core()->introspection()->metaObject(o);
if (meta->indexOfProperty(attributeName) == -1)
continue;
}
QObject *obj = o;
QAbstractScrollArea *scroll = qobject_cast<QAbstractScrollArea *>(o);
if (scroll && attributeName == QStringLiteral("cursor") && scroll->viewport())
obj = scroll->viewport();
// a real property
obj->setProperty(attributeName.toUtf8(), v);
}
}
示例6: propertyMap
QT_BEGIN_NAMESPACE
inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me
{
QHash<QString, DomProperty *> map;
for (int i=0; i<properties.size(); ++i) {
DomProperty *p = properties.at(i);
map.insert(p->attributeName(), p);
}
return map;
}
示例7: xmlFromWidgetBox
// Get XML for a new form from the widget box. Change objectName/geometry
// properties to be suitable for new forms
static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const QString &className, const QString &objectName)
{
typedef QList<DomProperty*> PropertyList;
QDesignerWidgetBoxInterface::Widget widget;
const bool found = QDesignerWidgetBox::findWidget(core->widgetBox(), className, QString(), &widget);
if (!found)
return QString();
QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false));
if (domUI.isNull())
return QString();
domUI->setAttributeVersion(QLatin1String("4.0"));
DomWidget *domWidget = domUI->elementWidget();
if (!domWidget)
return QString();
// Properties: Remove the "objectName" property in favour of the name attribute and check geometry.
domWidget->setAttributeName(objectName);
const QString geometryProperty = QLatin1String("geometry");
const QString objectNameProperty = QLatin1String("objectName");
PropertyList properties = domWidget->elementProperty();
for (PropertyList::iterator it = properties.begin(); it != properties.end(); ) {
DomProperty *property = *it;
if (property->attributeName() == objectNameProperty) { // remove "objectName"
it = properties.erase(it);
delete property;
} else {
if (property->attributeName() == geometryProperty) { // Make sure form is at least 400, 300
if (DomRect *geom = property->elementRect()) {
if (geom->elementWidth() < NewFormWidth)
geom->setElementWidth(NewFormWidth);
if (geom->elementHeight() < NewFormHeight)
geom->setElementHeight(NewFormHeight);
}
}
++it;
}
}
// Add a window title property
DomString *windowTitleString = new DomString;
windowTitleString->setText(objectName);
DomProperty *windowTitleProperty = new DomProperty;
windowTitleProperty->setAttributeName(QLatin1String("windowTitle"));
windowTitleProperty->setElementString(windowTitleString);
properties.push_back(windowTitleProperty);
// ------
domWidget->setElementProperty(properties);
// Embed in in DomUI and get string. Omit the version number.
domUI->setElementClass(objectName);
QString rc;
{ // Serialize domUI
QXmlStreamWriter writer(&rc);
writer.setAutoFormatting(true);
writer.setAutoFormattingIndent(1);
writer.writeStartDocument();
domUI->write(writer);
writer.writeEndDocument();
}
return rc;
}
示例8: Q_ASSERT
bool Q3ListViewExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget)
{
// ### finish me
Q3ListView *listView = qobject_cast<Q3ListView*>(widget());
Q_ASSERT(listView != 0);
QList<DomColumn*> columns;
Q3Header *header = listView->header();
for (int i=0; i<header->count(); ++i) {
DomColumn *c = new DomColumn();
QList<DomProperty*> properties;
DomString *str = new DomString();
str->setText(header->label(i));
DomProperty *ptext = new DomProperty();
ptext->setAttributeName(QLatin1String("text"));
ptext->setElementString(str);
DomProperty *pclickable = new DomProperty();
pclickable->setAttributeName(QLatin1String("clickable"));
pclickable->setElementBool(header->isClickEnabled(i) ? QLatin1String("true") : QLatin1String("false"));
DomProperty *presizable = new DomProperty();
presizable->setAttributeName(QLatin1String("resizable"));
presizable->setElementBool(header->isResizeEnabled(i) ? QLatin1String("true") : QLatin1String("false"));
properties.append(ptext);
properties.append(pclickable);
properties.append(presizable);
c->setElementProperty(properties);
columns.append(c);
}
ui_widget->setElementColumn(columns);
QList<DomItem *> items;
Q3ListViewItem *child = listView->firstChild();
while (child) {
items.append(saveQ3ListViewItem(child));
child = child->nextSibling();
}
ui_widget->setElementItem(items);
return true;
}
示例9: Q_ASSERT
void Q3IconViewExtraInfo::initializeQ3IconViewItems(const QList<DomItem *> &items)
{
Q3IconView *iconView = qobject_cast<Q3IconView*>(widget());
Q_ASSERT(iconView != 0);
for (int i=0; i<items.size(); ++i) {
DomItem *item = items.at(i);
Q3IconViewItem *__item = new Q3IconViewItem(iconView);
QList<DomProperty*> properties = item->elementProperty();
for (int i=0; i<properties.size(); ++i) {
DomProperty *p = properties.at(i);
if (p->attributeName() == QLatin1String("text"))
__item->setText(p->elementString()->text());
if (p->attributeName() == QLatin1String("pixmap")) {
DomResourcePixmap *pix = p->elementPixmap();
QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory()));
__item->setPixmap(pixmap);
}
}
}
}
示例10: QString
// Set a fixed size on a XML template
QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, bool fixed)
{
typedef QList<DomProperty*> PropertyList;
DomUI *domUI = QDesignerWidgetBox::xmlToUi(QLatin1String("Form"), xml, false);
if (!domUI)
return QString();
DomWidget *domWidget = domUI->elementWidget();
if (!domWidget)
return QString();
// Properties: Find/Ensure the geometry, minimum and maximum sizes properties
const QString geometryPropertyName = QLatin1String("geometry");
const QString minimumSizePropertyName = QLatin1String("minimumSize");
const QString maximumSizePropertyName = QLatin1String("maximumSize");
DomProperty *geomProperty = 0;
DomProperty *minimumSizeProperty = 0;
DomProperty *maximumSizeProperty = 0;
PropertyList properties = domWidget->elementProperty();
const PropertyList::const_iterator cend = properties.constEnd();
for (PropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) {
const QString name = (*it)->attributeName();
if (name == geometryPropertyName) {
geomProperty = *it;
} else {
if (name == minimumSizePropertyName) {
minimumSizeProperty = *it;
} else {
if (name == maximumSizePropertyName)
maximumSizeProperty = *it;
}
}
}
if (!geomProperty) {
geomProperty = new DomProperty;
geomProperty->setAttributeName(geometryPropertyName);
geomProperty->setElementRect(new DomRect);
properties.push_front(geomProperty);
}
if (fixed) {
if (!minimumSizeProperty) {
minimumSizeProperty = new DomProperty;
minimumSizeProperty->setAttributeName(minimumSizePropertyName);
minimumSizeProperty->setElementSize(new DomSize);
properties.push_back(minimumSizeProperty);
}
if (!maximumSizeProperty) {
maximumSizeProperty = new DomProperty;
maximumSizeProperty->setAttributeName(maximumSizePropertyName);
maximumSizeProperty->setElementSize(new DomSize);
properties.push_back(maximumSizeProperty);
}
}
// Set values of geometry, minimum and maximum sizes properties
const int width = size.width();
const int height = size.height();
if (DomRect *geom = geomProperty->elementRect()) {
geom->setElementWidth(width);
geom->setElementHeight(height);
}
if (fixed) {
if (DomSize *s = minimumSizeProperty->elementSize()) {
s->setElementWidth(width);
s->setElementHeight(height);
}
if (DomSize *s = maximumSizeProperty->elementSize()) {
s->setElementWidth(width);
s->setElementHeight(height);
}
}
// write back
domWidget->setElementProperty(properties);
QString rc;
{ // serialize domUI
QXmlStreamWriter writer(&rc);
writer.setAutoFormatting(true);
writer.setAutoFormattingIndent(1);
writer.writeStartDocument();
domUI->write(writer);
writer.writeEndDocument();
}
delete domUI;
return rc;
}