MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / copySelection

Method copySelection

src/copyeventfilter.cpp:18–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16{}
17
18void CopyEventFilter::copySelection() const
19{
20 if (!m_view->selectionModel()->hasSelection()) {
21 return;
22 }
23
24 // sort to reflect the visual order
25 QModelIndexList selectedRows = m_view->selectionModel()->selectedRows();
26 std::sort(selectedRows.begin(), selectedRows.end(),
27 [=](const auto& lidx, const auto& ridx) {
28 return m_view->visualRect(lidx).top() < m_view->visualRect(ridx).top();
29 });
30
31 QStringList rows;
32 for (auto& idx : selectedRows) {
33 rows.append(m_format(idx));
34 }
35
36 QGuiApplication::clipboard()->setText(rows.join("\n"));
37}
38
39bool CopyEventFilter::eventFilter(QObject* sender, QEvent* event)
40{

Callers 1

createMenuMethod · 0.80

Calls 4

visualRectMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected