Support deleting types

master
Marko Semet 2019-07-08 15:20:50 +02:00
parent af5165fbcd
commit bcfd625390
3 changed files with 11 additions and 5 deletions

View File

@ -78,7 +78,8 @@ namespace sirEdit::data {
this->addBaseTool(tool);
}
void removeTool(Tool* tool) {
throw;// TODO
this->__tools.erase(std::find(this->__tools.begin(), this->__tools.end(), tool));
this->removeBaseTool(tool);
}
virtual void prepareSave() = 0;
virtual void save() = 0;
@ -155,6 +156,10 @@ namespace sirEdit::data {
updateCall(this->__change_callback);
return tmp;
}
void removeTool(const Tool& tool) {
this->__serializer.removeTool(const_cast<Tool*>(&tool));
updateCall(this->__change_callback);
}
void setFieldStatus(const Tool& tool, const Type& type, const Field& field, FIELD_STATE state, const std::function<void(const Type&, const Field&, FIELD_STATE, FIELD_STATE)>& callback_field, const std::function<void(const Type&, TYPE_STATE, TYPE_STATE)>& callback_type) {
// Set state
FIELD_STATE old = tool.getFieldSetState(field, type);

View File

@ -451,12 +451,10 @@ namespace {
}
void addBaseTool(Tool* tool) {
this->toAdd.push_back(tool);
//auto tmp = this->sf->Tool->add();
this->tools[tool] = nullptr;
}
void removeBaseTool(Tool* tool) {
this->toRemove.push_back(tools[tool]);
//this->sf->free(this->tools[tool]);
this->tools.erase(tool);
delete tool;
}

View File

@ -200,8 +200,8 @@ class MainWindow {
button->signal_clicked().connect([i]() -> void {
std::string path; // TODO; path
std::string cmd = i->parseCMD(path);
std::thread([cmd]() -> void {
runCommand({"xterm", cmd}, getSavePath());
new std::thread([cmd]() -> void {
runCommand({"xterm", "sh -c " + cmd}, getSavePath());
});
});
top->pack_start(*button, false, true);
@ -221,6 +221,9 @@ class MainWindow {
Gtk::Button* button = Gtk::manage(new Gtk::Button());
button->set_relief(Gtk::RELIEF_NONE);
button->set_image(*(Gtk::manage(new Gtk::Image(Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON))));
button->signal_clicked().connect([i, this]() -> void {
this->__transitions.removeTool(*i);
});
top->pack_start(*button, false, true);
}
main->pack_start(*top, true, true);