MCPcopy Create free account
hub / github.com/KDE/kdevelop / mousePressEvent

Method mousePressEvent

plugins/documentview/kdevdocumentview.cpp:88–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void KDevDocumentView::mousePressEvent( QMouseEvent * event )
89{
90 QModelIndex proxyIndex = indexAt( event->pos() );
91 QModelIndex index = m_proxy->mapToSource( proxyIndex );
92
93 if (event->modifiers() == Qt::NoModifier) {
94 const bool actionOpen = event->button() == Qt::LeftButton;
95 const bool actionClose = event->button() == Qt::MiddleButton;
96 const bool action = actionOpen || actionClose;
97
98 if (action) {
99 if (proxyIndex.parent().isValid()) {
100 // this is a document item
101 KDevelop::IDocumentController* dc = m_plugin->core()->documentController();
102 QUrl documentUrl = static_cast<KDevDocumentItem*>(m_documentModel->itemFromIndex(index))->fileItem()->url();
103 KDevelop::IDocument *doc = dc->documentForUrl(documentUrl);
104
105 // Try to open a document by url.
106 if (actionOpen) {
107 if (doc != dc->activeDocument()) {
108 dc->openDocument(documentUrl);
109 return;
110 }
111 }
112 // Try to close a document.
113 else if (actionClose) {
114 if (doc) {
115 doc->close();
116 return;
117 }
118 }
119 } else if (actionOpen) {
120 // this is a folder item
121 setExpanded(proxyIndex, !isExpanded(proxyIndex));
122 return;
123 }
124 }
125 }
126
127 QTreeView::mousePressEvent( event );
128}
129
130template<typename F> void KDevDocumentView::visitItems(F f, bool selectedItems)
131{

Callers

nothing calls this directly

Calls 15

isExpandedFunction · 0.85
posMethod · 0.80
modifiersMethod · 0.80
buttonMethod · 0.80
documentControllerMethod · 0.80
documentForUrlMethod · 0.80
activeDocumentMethod · 0.80
mousePressEventFunction · 0.50
mapToSourceMethod · 0.45
isValidMethod · 0.45
parentMethod · 0.45
coreMethod · 0.45

Tested by

no test coverage detected