Exemplo n.º 1
0
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));
  }
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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));
    }
  }
}
Exemplo n.º 4
0
  /*! \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);
    }
  }
Exemplo n.º 5
0
int WSortFilterProxyModel::compare(const WModelIndex& lhs,
				   const WModelIndex& rhs) const
{
  return Wt::Impl::compare(lhs.data(sortRole_), rhs.data(sortRole_));
}