void ReactionsWidget1::slotNewFunction() { // FunctionWidget1 * fw = new FunctionWidget1(NULL); // fw->show(); // TODO: we could think about calling the function widget as a dialogue here... std::string name = std::string("Rate Law for ") + mpObject->getObjectName(); std::string nname = name; size_t i = 0; CCopasiVectorN<CFunction>& FunctionList = CCopasiRootContainer::getFunctionList()->loadedFunctions(); CFunction* pFunc; while (FunctionList.getIndex(nname) != C_INVALID_INDEX) { i++; nname = name + "_"; nname += TO_UTF8(QString::number(i)); } CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(nname), true); protectedNotify(ListViews::FUNCTION, ListViews::ADD, pFunc->getKey()); mpListView->switchToOtherWidget(C_INVALID_INDEX, pFunc->getKey()); }
//! Slot for being activated wehenver New button is clicked void FunctionWidget1::slotBtnNew() { std::string name = "function_1"; int i = 1; CFunction* pFunc; CCopasiVectorN<CFunction>& FunctionList = CCopasiRootContainer::getFunctionList()->loadedFunctions(); while (FunctionList.getIndex(name) != C_INVALID_INDEX) { i++; name = "function_"; name += TO_UTF8(QString::number(i)); } CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(name), true); std::string key = pFunc->getKey(); protectedNotify(ListViews::FUNCTION, ListViews::ADD, key); // enter(key); mpListView->switchToOtherWidget(C_INVALID_INDEX, key); }