void CQPlotSubwidget::copyPlot() { leaveProtected(); CDataModel *pDataModel = mpObject->getObjectDataModel(); if (pDataModel == NULL) return; CPlotSpecification *pPl = new CPlotSpecification(*dynamic_cast<CPlotSpecification *>(mpObject), NO_PARENT); std::string baseName = pPl->getObjectName() + "_copy"; std::string name = baseName; int i = 1; while (pDataModel->getPlotDefinitionList()->getIndex(name) != C_INVALID_INDEX) { i++; name = baseName + TO_UTF8(QString::number(i)); } pPl->setObjectName(name); pDataModel->getPlotDefinitionList()->add(pPl, true); std::string cn = pPl->CCopasiParameter::getCN(); protectedNotify(ListViews::ObjectType::PLOT, ListViews::ADD, cn); enter(cn); mpListView->switchToOtherWidget(ListViews::WidgetType::PlotDetail, cn); }