WAbstractMedia::Source::Source(WAbstractMedia *parent, const WLink& link, const std::string &type, const std::string &media) : parent(parent), type(type), media(media), link(link) { if (link.type() == WLink::Resource) connection = link.resource()->dataChanged().connect (this, &Source::resourceChanged); }
void WPushButton::setLink(const WLink& link) { if (link == link_) return; link_ = link; flags_.set(BIT_LINK_CHANGED); if (link.type() == WLink::Resource) link.resource()->dataChanged().connect(this, &WPushButton::resourceChanged); repaint(RepaintPropertyIEMobile); }
void WImage::setImageLink(const WLink& link) { if (link.type() != WLink::Resource && canOptimizeUpdates() && (link == imageLink_)) return; imageLink_ = link; if (link.type() == WLink::Resource) link.resource()->dataChanged().connect(this, &WImage::resourceChanged); flags_.set(BIT_IMAGE_LINK_CHANGED); repaint(RepaintPropertyIEMobile); }
void WCssDecorationStyle::setBackgroundImage(const WLink& image, Repeat repeat, WFlags<Side> sides) { if (image.type() == WLink::Resource) image.resource()->dataChanged(). connect(this, &WCssDecorationStyle::backgroundImageResourceChanged); if (!WWebWidget::canOptimizeUpdates() || backgroundImage_ != image || backgroundImageRepeat_ != repeat || backgroundImageLocation_ != sides) { backgroundImage_ = image; backgroundImageRepeat_ = repeat; backgroundImageLocation_ = sides; backgroundImageChanged_ = true; changed(); } }
WLink WsMenu::makeLink(const std::string& path, bool bUseIcon) { WsUser* pUser = WsApp->wsUser(); std::string m_sDocumentRoot = pUser->getRootPath(); // /var/www/demo_site std::string m_httpDocumentRoot = gdWApp->getParameter("DOCUMENT_ROOT", "/var/www"); std::string m_sRelativeDocumentRoot = m_sDocumentRoot; boost::algorithm::replace_first(m_sRelativeDocumentRoot, m_httpDocumentRoot, ""); // /demo_site WLink lnk; std::string strExt(boost::filesystem::extension(path)); if ( strExt == ".url" ) { boost::filesystem::path urlFile(m_sDocumentRoot + path); std::string sUrl; std::ifstream f(urlFile.string().c_str()); std::getline(f, sUrl); // url without CR boost::algorithm::replace_all(sUrl, "link=", ""); lnk.setUrl(sUrl); } else lnk.setInternalPath(path); //lnk.setUrl(m_sRelativeDocumentRoot + path); return lnk; }
WAbstractMedia::Source::Source(WAbstractMedia *parent, const WLink& link, const std::string &type, const std::string &media) : parent(parent), type(type), media(media), link(link) { if (link.type() == LinkType::Resource) { /* connection = link.resource()->dataChanged().connect ([=]() { this->resourceChanged(); }); */ #ifdef WT_TARGET_JAVA connection = link.resource()->dataChanged().connect (this, std::bind(&Source::resourceChanged, this)); #else // !WT_TARGET_JAVA connection = link.resource()->dataChanged().connect (std::bind(&Source::resourceChanged, this)); #endif // WT_TARGET_JAVA } }
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; IndexText *t = new IndexText(index); 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; boost::any checkedData = index.data(CheckStateRole); if (!checkedData.empty()) { haveCheckBox = true; CheckState state = (checkedData.type() == typeid(bool) ? (boost::any_cast<bool>(checkedData) ? Checked : Unchecked) : (checkedData.type() == typeid(CheckState) ? boost::any_cast<CheckState>(checkedData) : Unchecked)); IndexCheckBox *icb = checkBox(widgetRef, index, true, index.flags() & ItemIsTristate); icb->setCheckState(state); icb->setEnabled(index.flags() & ItemIsUserCheckable); } else if (!isNew) delete checkBox(widgetRef, index, false); boost::any linkData = index.data(LinkRole); if (!linkData.empty()) { WLink link = boost::any_cast<WLink>(linkData); IndexAnchor *a = anchorWidget(widgetRef, index); a->setLink(link); if (link.type() == WLink::Resource) a->setTarget(TargetNewWindow); } IndexText *t = textWidget(widgetRef, index); 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, index, true)->setImageLink(WLink(iconUrl)); } else if (!isNew) delete iconWidget(widgetRef, index, false); } if (index.flags() & ItemHasDeferredTooltip){ widgetRef.w->setDeferredToolTip(true, (index.flags() & ItemIsXHTMLText) ? XHTMLText : PlainText); } else { WString tooltip = asString(index.data(ToolTipRole)); if (!tooltip.empty() || !isNew) widgetRef.w->setToolTip(tooltip, (index.flags() & ItemIsXHTMLText) ? XHTMLText : PlainText); } 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; }