| 178 | void View::showExcellonDialog() { } |
| 179 | |
| 180 | void View::contextMenuEvent(QContextMenuEvent* event) |
| 181 | { |
| 182 | m_menuIndex = indexAt(event->pos()); |
| 183 | qDebug() << m_menuIndex; |
| 184 | if (!m_menuIndex.isValid()) |
| 185 | return; |
| 186 | QMenu menu(this); |
| 187 | m_childCount = static_cast<Node*>(m_menuIndex.internalPointer())->childCount(); |
| 188 | if (m_menuIndex.data(Role::NodeType).toInt() == Type::Folder) { |
| 189 | const int type = m_menuIndex.data(Role::Id).toInt(); |
| 190 | const int cType = m_menuIndex.data(Role::ContentType).toInt(); |
| 191 | if (cType == Type::File) { |
| 192 | App::filePlugin(type)->createMainMenu(menu, this); |
| 193 | } else if (cType == Type::Shape) { |
| 194 | std::get<0>(App::shapePlugins().begin()->second)->createMainMenu(menu, this); |
| 195 | } |
| 196 | } else { |
| 197 | reinterpret_cast<Node*>(m_menuIndex.internalId())->menu(menu, this); |
| 198 | if (auto selectedRows { selectionModel()->selectedRows().toVector() }; selectedRows.count() > 1) { |
| 199 | menu.addSeparator(); |
| 200 | // FIXME rename Action in future. |
| 201 | menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete Selected"), [selectedRows, this]() mutable { |
| 202 | std::ranges::sort(selectedRows, std::greater {}, &QModelIndex::row); |
| 203 | for (auto&& index : selectedRows) |
| 204 | m_model->removeRow(index.row(), index.parent()); |
| 205 | }); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | if (!menu.isEmpty()) |
| 210 | menu.exec(viewport()->mapToGlobal(event->pos())); |
| 211 | } |
| 212 | |
| 213 | void View::mousePressEvent(QMouseEvent* event) |
| 214 | { |