| 29 | } |
| 30 | |
| 31 | void NotebookDock::setNotebooks(QList<Notebook*> list) { |
| 32 | CONDITIONAL_LOCK_RETURN; |
| 33 | m_notebooks = list; |
| 34 | m_notebook = list.first(); |
| 35 | setAspects(list); |
| 36 | |
| 37 | // remove the available panel plugins first |
| 38 | int k = 0; |
| 39 | int prev_index = ui.tabWidget->currentIndex(); |
| 40 | for (int i : index) { |
| 41 | ui.tabWidget->removeTab(i - k); |
| 42 | ++k; |
| 43 | } |
| 44 | |
| 45 | ui.leName->setStyleSheet(QString()); |
| 46 | ui.leName->setToolTip(QString()); |
| 47 | |
| 48 | if (m_notebooks.size() == 1) { |
| 49 | // show name/comment |
| 50 | ui.leName->setText(m_notebook->name()); |
| 51 | ui.teComment->setText(m_notebook->comment()); |
| 52 | |
| 53 | // add available panel plugins |
| 54 | const auto& plugins = m_notebooks.first()->getPlugins(); |
| 55 | index.clear(); |
| 56 | for (auto* plugin : plugins) { |
| 57 | // skip the "File Browser" plugin |
| 58 | // in the new code of Cantor the plugin id is set as the object name and we can use it. |
| 59 | // for the older version we need to rely on the translated name... |
| 60 | // TODO: remove the dependency on the plugin name later. |
| 61 | if (plugin->objectName() == QLatin1String("FileBrowserPanel") || plugin->name() == i18n("File Browser")) |
| 62 | continue; |
| 63 | |
| 64 | connect(plugin, &Cantor::PanelPlugin::visibilityRequested, this, &NotebookDock::visibilityRequested); |
| 65 | int i = ui.tabWidget->addTab(plugin->widget(), plugin->name()); |
| 66 | index.append(i); |
| 67 | |
| 68 | if (plugin->objectName() == QLatin1String("HelpPanel")) |
| 69 | m_helpPanelIndex = i; |
| 70 | else if (plugin->objectName() == QLatin1String("DocumentationPanel")) |
| 71 | m_documentationPanelIndex = i; |
| 72 | } |
| 73 | } else { |
| 74 | // don't show any name/comment when multiple notebooks were selected |
| 75 | ui.leName->setText(QString()); |
| 76 | ui.teComment->setText(QString()); |
| 77 | } |
| 78 | |
| 79 | ui.tabWidget->setCurrentIndex(prev_index); |
| 80 | |
| 81 | if (m_notebook->part()) { |
| 82 | ui.bEvaluate->show(); |
| 83 | ui.bRestart->show(); |
| 84 | } else { |
| 85 | ui.bEvaluate->hide(); |
| 86 | ui.bRestart->hide(); |
| 87 | } |
| 88 | } |
no test coverage detected