| 114 | } |
| 115 | |
| 116 | QMenu* Column::createContextMenu() { |
| 117 | if (parentAspect()->type() == AspectType::StatisticsSpreadsheet) |
| 118 | return nullptr; |
| 119 | |
| 120 | // initialize the actions if not done yet |
| 121 | if (!m_copyDataAction) { |
| 122 | m_copyDataAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy Data"), this); |
| 123 | connect(m_copyDataAction, &QAction::triggered, this, &Column::copyData); |
| 124 | |
| 125 | m_pasteDataAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), i18n("Paste Data"), this); |
| 126 | connect(m_pasteDataAction, &QAction::triggered, this, &Column::pasteData); |
| 127 | |
| 128 | m_usedInActionGroup = new QActionGroup(this); |
| 129 | connect(m_usedInActionGroup, &QActionGroup::triggered, this, &Column::navigateTo); |
| 130 | connect(this, &AbstractColumn::maskingChanged, this, [=] { |
| 131 | d->invalidate(); |
| 132 | }); |
| 133 | } |
| 134 | |
| 135 | QMenu* menu = AbstractAspect::createContextMenu(); |
| 136 | QAction* firstAction{nullptr}; |
| 137 | |
| 138 | // insert after "rename" and "delete" actions, if available. |
| 139 | // MQTTTopic columns don't have these actions |
| 140 | if (menu->actions().size() > 1) |
| 141 | firstAction = menu->actions().at(1); |
| 142 | |
| 143 | // add actions available in SpreadsheetView |
| 144 | // TODO: we don't need to add anything from the view for MQTTTopic columns. |
| 145 | // at the moment it's ok to check to the null pointer for firstAction here. |
| 146 | // later, once we have some actions in the menu also for MQTT topics we'll |
| 147 | // need to explicitly to dynamic_cast for MQTTTopic |
| 148 | if (firstAction) { |
| 149 | if (parentAspect()->inherits(AspectType::Spreadsheet)) { |
| 150 | auto* spreadsheet = static_cast<Spreadsheet*>(parentAspect()); |
| 151 | spreadsheet->fillColumnContextMenu(menu, this); |
| 152 | } else if (parentAspect()->type() == AspectType::Notebook) { |
| 153 | #if defined(HAVE_CANTOR_LIBS) && !defined(SDK) |
| 154 | auto* notebook = static_cast<Notebook*>(parentAspect()); |
| 155 | notebook->fillColumnContextMenu(menu, this); |
| 156 | #endif |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | //"Used in" menu containing all plots where the column is used |
| 161 | QMenu* usedInMenu = new QMenu(i18n("Used in")); |
| 162 | usedInMenu->setIcon(QIcon::fromTheme(QStringLiteral("go-next-view"))); |
| 163 | |
| 164 | // remove previously added actions |
| 165 | for (auto* action : m_usedInActionGroup->actions()) |
| 166 | m_usedInActionGroup->removeAction(action); |
| 167 | |
| 168 | auto* project = this->project(); |
| 169 | bool showIsUsed = false; |
| 170 | |
| 171 | // add curves where the column is currently in use |
| 172 | bool sectionAdded = false; |
| 173 | const auto& plots = project->children<Plot>(AbstractAspect::ChildIndexFlag::Recursive); |
nothing calls this directly
no test coverage detected