本文整理汇总了C++中WText::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ WText::setObjectName方法的具体用法?C++ WText::setObjectName怎么用?C++ WText::setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WText
的用法示例。
在下文中一共展示了WText::setObjectName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: widgetRef
WWidget *WItemDelegate::update(WWidget *widget, const WModelIndex& index,
WFlags<ViewItemRenderFlag> flags)
{
bool editing = widget && widget->find("t") == 0;
if (flags & RenderEditing) {
if (!editing) {
widget = createEditor(index, flags);
WInteractWidget *iw = dynamic_cast<WInteractWidget *>(widget);
if (iw) {
// Disable drag & drop and selection behaviour
iw->mouseWentDown().preventPropagation();
iw->clicked().preventPropagation();
}
}
} else {
if (editing)
widget = 0;
}
WidgetRef widgetRef(widget);
bool isNew = false;
if (!(flags & RenderEditing)) {
if (!widgetRef.w) {
isNew = true;
WText *t = new WText();
t->setObjectName("t");
if (index.isValid() && !(index.flags() & ItemIsXHTMLText))
t->setTextFormat(PlainText);
t->setWordWrap(true);
widgetRef.w = t;
}
if (!index.isValid())
return widgetRef.w;
bool haveCheckBox = false;
if (index.flags() & ItemIsUserCheckable) {
boost::any checkedData = index.data(CheckStateRole);
CheckState state = checkedData.empty() ? Unchecked
: (checkedData.type() == typeid(bool) ?
(boost::any_cast<bool>(checkedData) ? Checked : Unchecked)
: (checkedData.type() == typeid(CheckState) ?
boost::any_cast<CheckState>(checkedData) : Unchecked));
checkBox(widgetRef, index, true, index.flags() & ItemIsTristate)
->setCheckState(state);
haveCheckBox = true;
} else if (!isNew)
delete checkBox(widgetRef, index, false);
boost::any linkData = index.data(LinkRole);
if (!linkData.empty()) {
WLink link = boost::any_cast<WLink>(linkData);
WAnchor *a = anchorWidget(widgetRef);
a->setLink(link);
if (link.type() == WLink::Resource)
a->setTarget(TargetNewWindow);
}
WText *t = textWidget(widgetRef);
WString label = asString(index.data(), textFormat_);
if (label.empty() && haveCheckBox)
label = WString::fromUTF8(" ");
t->setText(label);
std::string iconUrl = asString(index.data(DecorationRole)).toUTF8();
if (!iconUrl.empty()) {
iconWidget(widgetRef, true)->setImageLink(WLink(iconUrl));
} else if (!isNew)
delete iconWidget(widgetRef, false);
}
WString tooltip = asString(index.data(ToolTipRole));
if (!tooltip.empty() || !isNew)
widgetRef.w->setToolTip(tooltip);
WT_USTRING sc = asString(index.data(StyleClassRole));
if (flags & RenderSelected)
sc += WT_USTRING::fromUTF8
(" " + WApplication::instance()->theme()->activeClass());
if (flags & RenderEditing)
sc += WT_USTRING::fromUTF8(" Wt-delegate-edit");
widgetRef.w->setStyleClass(sc);
if (index.flags() & ItemIsDropEnabled)
widgetRef.w->setAttributeValue("drop", WString::fromUTF8("true"));
else
if (!widgetRef.w->attributeValue("drop").empty())
widgetRef.w->setAttributeValue("drop", WString::fromUTF8("f"));
return widgetRef.w;
}