本文整理汇总了C++中WModelIndex::data方法的典型用法代码示例。如果您正苦于以下问题:C++ WModelIndex::data方法的具体用法?C++ WModelIndex::data怎么用?C++ WModelIndex::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WModelIndex
的用法示例。
在下文中一共展示了WModelIndex::data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modelDataChanged
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));
}
}
示例2: partialResults
bool WSuggestionPopup::partialResults() const
{
if (filterLength_ < 0)
return true;
else if (model_->rowCount() > 0) {
WModelIndex index = model_->index(model_->rowCount() - 1, modelColumn_);
boost::any styleclass = index.data(StyleClassRole);
return Wt::asString(styleclass) == "Wt-more-data";
} else
return false;
}
示例3: modelRowsInserted
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));
}
}
}
示例4: folderChanged
/*! \brief Change the filter on the file view when the selected folder
* changes.
*/
void folderChanged() {
if (folderView_->selectedIndexes().empty())
return;
WModelIndex selected = *folderView_->selectedIndexes().begin();
boost::any d = selected.data(UserRole);
if (!d.empty()) {
std::string folder = boost::any_cast<std::string>(d);
// For simplicity, we assume here that the folder-id does not
// contain special regexp characters, otherwise these need to be
// escaped -- or use the \Q \E qutoing escape regular expression
// syntax (and escape \E)
fileFilterModel_->setFilterRegExp(folder);
}
}
示例5: compare
int WSortFilterProxyModel::compare(const WModelIndex& lhs,
const WModelIndex& rhs) const
{
return Wt::Impl::compare(lhs.data(sortRole_), rhs.data(sortRole_));
}