コード例 #1
0
void LayerTree::add_figure_node(mforms::TreeNodeRef parent, model_FigureRef figure, int insertion_point) {
  bec::IconManager *im = bec::IconManager::get_instance();
  mforms::TreeNodeRef fnode;
  FigureNode *fchild = new FigureNode();
  fchild->object = figure;
  fchild->is_layer = false;

  if (insertion_point < 0)
    fnode = parent ? parent->add_child() : add_node();
  else
    fnode = parent ? parent->insert_child(insertion_point) : root_node()->insert_child(insertion_point);

  fnode->set_data(fchild);
  fnode->set_string(0, figure->name());
  fnode->set_tag(figure->id());
  fnode->set_icon_path(0, im->get_icon_path(im->get_icon_id(figure, bec::Icon16)));

  fchild->conn = figure->signal_changed()->connect(
    std::bind(&LayerTree::object_changed, this, std::placeholders::_1, std::placeholders::_2, fnode));

  std::string conn_icon = im->get_icon_path("db.Column.fknn.16x16.png");
  std::string id = figure->id();
  std::multimap<std::string, workbench_physical_ConnectionRef>::iterator iter;
  for (iter = _figure_connections.find(id); iter != _figure_connections.end() && iter->first == id; ++iter) {
    mforms::TreeNodeRef cnode = fnode->add_child();
    FigureNode *cchild = new FigureNode();
    cchild->object = iter->second->endFigure();
    cchild->is_layer = false;
    cnode->set_data(cchild);
    cnode->set_string(0, iter->second->caption());
    cnode->set_tag(iter->second.id());
    cnode->set_icon_path(0, conn_icon);
  }
}
コード例 #2
0
void DBSearchPanel::load_model(mforms::TreeNodeRef tnode)
{
  _key_columns.clear();
  for (size_t c = _searcher->search_results().size(), i = tnode->count(); i < c; i++)
  {
    const DBSearch::column_data_t& rows = _searcher->search_results()[i].data;
    mforms::TreeNodeRef table_node = tnode->add_child();
    table_node->set_string(0, _searcher->search_results()[i].schema);
    table_node->set_string(1, _searcher->search_results()[i].table);
    table_node->set_string(4, base::strfmt("%i rows matched", (int)rows.size()).c_str());
    table_node->set_tag(_searcher->search_results()[i].query);
    _key_columns.insert(std::make_pair(table_node->get_tag(), _searcher->search_results()[i].keys));

    for(DBSearch::column_data_t::const_iterator It_rows = rows.begin(); It_rows != rows.end(); ++It_rows)
    {
      std::string cols;
      std::string data;
      mforms::TreeNodeRef data_node = table_node->add_child();
      std::vector<std::pair<std::string, std::string> >::const_iterator It_cols = It_rows->begin();
      data_node->set_string(2, (It_cols++)->second);
      for (; It_cols != It_rows->end(); ++It_cols)
      {
        if (It_cols->second.empty())
          continue;
        if (!cols.empty())
          cols.append(", ");
        cols.append(It_cols->first);
        if (!data.empty())
          data.append(", ");
        data.append(It_cols->second);
      }
      data_node->set_string(3, cols);
      data_node->set_string(4, data);
      }
  }
};