Skip to content

Commit

Permalink
ticket:4547 Fill the path if model belongs to a package
Browse files Browse the repository at this point in the history
Don't allow duplicating in system libraries
  • Loading branch information
adeas31 committed Oct 9, 2017
1 parent bc6e188 commit 5422a27
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -742,7 +742,7 @@ DuplicateClassDialog::DuplicateClassDialog(bool saveAs, LibraryTreeItem *pLibrar
mpNameTextBox = new QLineEdit(mpLibraryTreeItem->getName());
mpNameTextBox->selectAll();
mpPathLabel = new Label(Helper::path);
mpPathTextBox = new QLineEdit;
mpPathTextBox = new QLineEdit(mpLibraryTreeItem->isTopLevel() ? "" : mpLibraryTreeItem->parent()->getNameStructure());
mpPathBrowseButton = new QPushButton(Helper::browse);
mpPathBrowseButton->setAutoDefault(false);
connect(mpPathBrowseButton, SIGNAL(clicked()), SLOT(browsePath()));
Expand Down Expand Up @@ -805,6 +805,16 @@ void DuplicateClassDialog::duplicateClass()
.arg((mpPathTextBox->text().isEmpty() ? "Top Level" : mpPathTextBox->text())), Helper::ok);
return;
}
// check if path is not a system library
if (!mpPathTextBox->text().isEmpty()) {
LibraryTreeItem *pLibraryTreeItem;
pLibraryTreeItem = MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->findLibraryTreeItem(mpPathTextBox->text());
if (pLibraryTreeItem && pLibraryTreeItem->isSystemLibrary()) {
QMessageBox::critical(this, QString("%1 - %2").arg(Helper::applicationName, Helper::error),
tr("Cannot duplicate inside system library."), Helper::ok);
return;
}
}
// if everything is fine then duplicate the class.
if (MainWindow::instance()->getOMCProxy()->copyClass(mpLibraryTreeItem->getNameStructure(), mpNameTextBox->text(), mpPathTextBox->text())) {
/* Ticket #3793
Expand Down

0 comments on commit 5422a27

Please sign in to comment.