void WSuggestionPopup::modelDataChanged(const WModelIndex& topLeft, const WModelIndex& bottomRight) { if (topLeft.parent().isValid()) return; if (modelColumn_ < topLeft.column() || modelColumn_ > bottomRight.column()) return; for (int i = topLeft.row(); i <= bottomRight.row(); ++i) { WContainerWidget *w = dynamic_cast<WContainerWidget *>(impl_->widget(i)); WAnchor *anchor = dynamic_cast<WAnchor *>(w->widget(0)); WText *value = dynamic_cast<WText *>(anchor->widget(0)); WModelIndex index = model_->index(i, modelColumn_); boost::any d = index.data(); value->setText(asString(d)); TextFormat format = index.flags() & ItemIsXHTMLText ? XHTMLText : PlainText; value->setTextFormat(format); boost::any d2 = model_->data(i, modelColumn_, UserRole); if (d2.empty()) d2 = d; value->setAttributeValue("sug", asString(d2)); } }
void WItemDelegate::updateModelIndex(WWidget *widget, const WModelIndex& index) { WidgetRef w(widget); if (index.flags() & ItemIsUserCheckable) { IndexCheckBox *cb = checkBox(w, index, false, false); if (cb) cb->setIndex(index); } }
void WItemDelegate::updateModelIndex(WWidget *widget, const WModelIndex& index) { WidgetRef w(widget); if (index.flags() & ItemIsUserCheckable) { IndexCheckBox *cb = checkBox(w, index, false, false); if (cb) cb->setIndex(index); } if (index.flags() & ItemHasDeferredTooltip) { IndexText *text = dynamic_cast<IndexText *>(widget); if (text) text->setIndex(index); IndexAnchor *anchor = dynamic_cast<IndexAnchor *>(widget); if (anchor) anchor->setIndex(index); IndexContainerWidget *c = dynamic_cast<IndexContainerWidget *>(widget); if (c) c->setIndex(index); } }
void WSuggestionPopup::modelRowsInserted(const WModelIndex& parent, int start, int end) { if (filterLength_ != 0 && !filtering_) return; if (modelColumn_ >= model_->columnCount()) return; if (parent.isValid()) return; for (int i = start; i <= end; ++i) { WContainerWidget *line = new WContainerWidget(); impl_->insertWidget(i, line); WModelIndex index = model_->index(i, modelColumn_); boost::any d = index.data(); TextFormat format = index.flags() & ItemIsXHTMLText ? XHTMLText : PlainText; WAnchor *anchor = new WAnchor(line); WText *value = new WText(asString(d), format, anchor); boost::any d2 = index.data(UserRole); if (d2.empty()) d2 = d; value->setAttributeValue("sug", asString(d2)); boost::any styleclass = index.data(StyleClassRole); if (!styleclass.empty()) { value->setAttributeValue("class", asString(styleclass)); } } }