MCPcopy Create free account
hub / github.com/XRay3D/GERBER_X3 / contextMenuEvent

Method contextMenuEvent

static_libs/filetree/ft_view.cpp:180–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178void View::showExcellonDialog() { }
179
180void 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
213void View::mousePressEvent(QMouseEvent* event)
214{

Callers

nothing calls this directly

Calls 11

isEmptyMethod · 0.80
posMethod · 0.45
isValidMethod · 0.45
childCountMethod · 0.45
toIntMethod · 0.45
dataMethod · 0.45
createMainMenuMethod · 0.45
menuMethod · 0.45
countMethod · 0.45
rowMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected