Ejemplo n.º 1
0
void BinaryDataEditor::import_value()
{
  mforms::FileChooser chooser(mforms::OpenFile);
  
  chooser.set_title("Import Field Data");
  if (chooser.run_modal())
  {
    std::string path = chooser.get_path();
    GError *error = 0;
    char *data;
    gsize length;
    
    if (!g_file_get_contents(path.c_str(), &data, &length, &error))
    {
      mforms::Utilities::show_error(base::strfmt("Could not import data from %s", path.c_str()),
                                    error->message, "OK");
      g_error_free(error);
    }
    else
    {
      assign_data(data, length, true);
      tab_changed();
    }
  }
}
Ejemplo n.º 2
0
BinaryDataEditor::BinaryDataEditor(bec::GRTManager *grtm, const char *data, size_t length, bool read_only)
: mforms::Form(0), _grtm(grtm), _box(false), _hbox(true), _read_only(read_only)
{

  set_name("blob_editor");
  _data = 0;
  _length = 0;

  grt::IntegerRef tab = grt::IntegerRef::cast_from(_grtm->get_app_option("BlobViewer:DefaultTab"));

  setup();
  assign_data(data, length);

  add_viewer(new HexDataViewer(this, read_only), "Binary");
  add_viewer(new TextDataViewer(this, "LATIN1", read_only), "Text");
  if (ImageDataViewer::can_display(data, length))
    add_viewer(new ImageDataViewer(this, read_only), "Image");

  int activeTab = 0;
  if (tab.is_valid())
    activeTab = (int)*tab;
  if (tab.is_valid() && *tab >= _tab_view.page_count())
  {
    grt::DictRef dict(grt::DictRef::cast_from(_grtm->get_app_option("")));
    if (dict.is_valid())
      dict.gset("BlobViewer:DefaultTab", 0);
    activeTab = 0;
  }
  _tab_view.set_active_tab(activeTab);

  tab_changed();
}
Ejemplo n.º 3
0
BinaryDataEditor::BinaryDataEditor(bec::GRTManager *grtm, const char *data, size_t length, const std::string &text_encoding, const std::string &datatype, bool read_only)
: mforms::Form(mforms::Form::main_form()), _grtm(grtm), _type(datatype), _box(false), _hbox(true), _read_only(read_only)
{
  set_name("blob_editor");
  _data = 0;
  _length = 0;
  _updating = false;

  grt::IntegerRef tab = grt::IntegerRef::cast_from(_grtm->get_app_option("BlobViewer:DefaultTab"));

  setup();
  add_viewer(new HexDataViewer(this, read_only), "Binary");
  if (datatype == "GEOMETRY")
  {
    add_viewer(new GeomTextDataViewer(this, read_only), "Text");
    add_viewer(new GeomDataViewer(this, read_only), "Image");
  }
  else
    add_viewer(new TextDataViewer(this, text_encoding, read_only), "Text");
  if (ImageDataViewer::can_display(data, length))
    add_viewer(new ImageDataViewer(this, read_only), "Image");

  assign_data(data, length);
  add_json_viewer(read_only, text_encoding, "JSON");

  int activeTab = 0;
  if (tab.is_valid())
    activeTab = (int)*tab;
  if (tab.is_valid() && *tab >= _tab_view.page_count())
  {
    grt::DictRef dict(grt::DictRef::cast_from(_grtm->get_app_option("")));
    if (dict.is_valid())
      dict.gset("BlobViewer:DefaultTab", 0);
    activeTab = 0;
  }

  _tab_view.set_active_tab(activeTab);  
  tab_changed();
}
Ejemplo n.º 4
0
void MainWindow::mode_maintables()
{
    emit ui->stackedWidget->setCurrentIndex(0);
    emit tab_changed(ui->tabs->currentIndex());
}