コード例 #1
0
//------------------------------------------------------------------------------
void DbMySQLTableEditorIndexPage::switch_be(MySQLTableEditorBE *be) {
  if (!_editing_sig.empty())
    _editing_sig.disconnect();

  _index_node = bec::NodeId();

  _indexes_columns_model.clear();
  Gtk::TreeView *tv = 0;
  _xml->get_widget("index_columns", tv);
  tv->remove_all_columns();
  tv->unset_model();

  _be = be;

  _be->get_indexes()->select_index(_index_node);
  // refresh is done from TableEd

  _indexes_tv->remove_all_columns();

  _indexes_model = ListModelWrapper::create(_be->get_indexes(), _indexes_tv, "DbMySQLTableEditorIndexPage");

  _indexes_model->model().append_string_column(0, "Index Name", EDITABLE, NO_ICON);
  _indexes_model->model().append_combo_column(1, "Type", model_from_string_list(_be->get_index_types()), EDITABLE,
                                              true);

  _indexes_tv->set_model(_indexes_model);

  Gtk::CellRenderer *rend = _indexes_tv->get_column_cell_renderer(0);

  _editing_sig =
    rend->signal_editing_started().connect(sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::cell_editing_started));
}
コード例 #2
0
bool DbMySQLTableEditorIndexPage::real_refresh()
{
  if (!_editing_sig.empty())
    _editing_sig.disconnect();

  Gtk::TreeView *tv = 0;
  _xml->get_widget("index_columns", tv);

  tv->unset_model();
  tv->remove_all_columns();

  _index_node = bec::NodeId();
  _be->get_indexes()->select_index(_index_node);

  fill_combo_from_string_list(_index_storage_combo, _be->get_index_storage_types());

  _indexes_tv->remove_all_columns();

  _indexes_model = ListModelWrapper::create(_be->get_indexes(), _indexes_tv, "DbMySQLTableEditorIndexPage");


  _indexes_model->model().append_string_column(0, "Index Name", EDITABLE, NO_ICON);
  _indexes_model->model().append_combo_column(1, "Type", model_from_string_list(_be->get_index_types()), EDITABLE, true);


  _indexes_tv->set_model(_indexes_model);

  Gtk::CellRenderer* rend = _indexes_tv->get_column_cell_renderer(0);

  _editing_sig = rend->signal_editing_started().
    connect(sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::cell_editing_started));

  const bool has_columns = _be->get_columns()->count() > 1;
  tv->set_sensitive(has_columns);
  _indexes_tv->set_sensitive(has_columns);
  
  index_cursor_changed();
  return false;
}
コード例 #3
0
//------------------------------------------------------------------------------
void DbMySQLTableEditorIndexPage::update_index_details() {
  MySQLTableIndexListBE *indices_be = _be->get_indexes();
  if (indices_be) {
    std::string index_name;
    indices_be->refresh();

    Gtk::TreeView *tv = 0;
    _xml->get_widget("index_columns", tv);
    tv->remove_all_columns();
    tv->unset_model();

    const bool got_indices = indices_be->count() > 1;
    if (_index_node.is_valid() && got_indices && _index_node.back() < indices_be->real_count()) {
      indices_be->get_field(_index_node, 0, index_name);
      if (!index_name.empty()) {
        indices_be->select_index(_index_node);
        indices_be->refresh();
      }

      _indexes_columns_model = ListModelWrapper::create(indices_be->get_columns(), tv, "IndexesColumnsModel");

      // negative column means value getting/setting is delegated back to us
      _indexes_columns_model->model().append_check_column(-8, "", EDITABLE);
      _indexes_columns_model->model().append_string_column(::bec::IndexColumnsListBE::Name, "Column", RO, NO_ICON);
      _indexes_columns_model->model().append_combo_column(::bec::IndexColumnsListBE::OrderIndex, "#",
                                                          recreate_order_model(), EDITABLE);
      _indexes_columns_model->model().append_combo_column(-2, "Order", _sort_order_model, EDITABLE, true);
      _indexes_columns_model->model().append_int_column(::bec::IndexColumnsListBE::Length, "Length", EDITABLE);

      _indexes_columns_model->set_fake_column_value_getter(
        sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::get_value));
      _indexes_columns_model->set_fake_column_value_setter(
        sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::set_value));

      tv->set_model(_indexes_columns_model);

      std::string text;
      indices_be->get_field(_index_node, ::MySQLTableIndexListBE::StorageType, text);
      _index_storage_combo_conn.block();
      set_selected_combo_item(_index_storage_combo, text);
      _index_storage_combo_conn.unblock();
    } else {
      set_selected_combo_item(_index_storage_combo, "");
    }

    Gtk::Entry *entry(0);
    std::string text;

    // Update row block size
    _xml->get_widget("index_key_block_size", entry);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::RowBlockSize, text);
    entry->set_text(text);

    // Update index parser
    _xml->get_widget("index_parser", entry);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::Parser, text);
    entry->set_text(text);

    Gtk::TextView *textview(0);
    // update index comment
    _xml->get_widget("index_comment", textview);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::Comment, text);
    textview->get_buffer()->set_text(text);

    _xml->get_widget("index_key_block_size", entry);
    entry->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());
    _xml->get_widget("index_parser", entry);
    entry->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());
    _xml->get_widget("index_comment", textview);
    textview->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());

    this->update_gui_for_server();

    _index_storage_combo->set_sensitive(got_indices && _index_node.is_valid() &&
                                        _index_node.back() < indices_be->real_count());
  }
}