| 86 | } |
| 87 | |
| 88 | void 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 | |
| 130 | template<typename F> void KDevDocumentView::visitItems(F f, bool selectedItems) |
| 131 | { |
nothing calls this directly
no test coverage detected