Changeset View
Changeset View
Standalone View
Standalone View
plugins/documentview/kdevdocumentview.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 97 | { | |||
---|---|---|---|---|---|
98 | return m_plugin; | 98 | return m_plugin; | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | void KDevDocumentView::mousePressEvent( QMouseEvent * event ) | 101 | void KDevDocumentView::mousePressEvent( QMouseEvent * event ) | ||
102 | { | 102 | { | ||
103 | QModelIndex proxyIndex = indexAt( event->pos() ); | 103 | QModelIndex proxyIndex = indexAt( event->pos() ); | ||
104 | QModelIndex index = m_proxy->mapToSource( proxyIndex ); | 104 | QModelIndex index = m_proxy->mapToSource( proxyIndex ); | ||
105 | 105 | | |||
106 | if (event->button() == Qt::LeftButton && event->modifiers() == Qt::NoModifier) { | 106 | if (event->modifiers() == Qt::NoModifier) { | ||
107 | const bool actionOpen = event->button() == Qt::LeftButton; | ||||
108 | const bool actionClose = event->button() == Qt::MidButton; | ||||
109 | const bool action = actionClose || actionOpen; | ||||
anthonyfieroni: Looks incorrect `actionClose || actionOpen` | |||||
110 | | ||||
111 | if (action) { | ||||
107 | if (proxyIndex.parent().isValid()) { | 112 | if (proxyIndex.parent().isValid()) { | ||
108 | // this is a document item | 113 | // this is a document item | ||
109 | KDevelop::IDocumentController* dc = m_plugin->core()->documentController(); | 114 | KDevelop::IDocumentController* dc = m_plugin->core()->documentController(); | ||
110 | QUrl documentUrl = static_cast<KDevDocumentItem*>(m_documentModel->itemFromIndex(index))->fileItem()->url(); | 115 | QUrl documentUrl = static_cast<KDevDocumentItem*>(m_documentModel->itemFromIndex(index))->fileItem()->url(); | ||
111 | if (dc->documentForUrl(documentUrl) != dc->activeDocument()) { | 116 | KDevelop::IDocument *doc = dc->documentForUrl(documentUrl); | ||
117 | | ||||
118 | // Try to open a document by url. | ||||
119 | if (actionOpen) { | ||||
120 | if (doc != dc->activeDocument()) { | ||||
112 | dc->openDocument(documentUrl); | 121 | dc->openDocument(documentUrl); | ||
113 | return; | 122 | return; | ||
114 | } | 123 | } | ||
115 | } else { | 124 | } | ||
125 | // Try to close a document. | ||||
126 | else if (actionClose) { | ||||
127 | if (doc) { | ||||
128 | doc->close(); | ||||
129 | return; | ||||
130 | } | ||||
131 | } | ||||
132 | } else if (actionOpen) { | ||||
116 | // this is a folder item | 133 | // this is a folder item | ||
117 | setExpanded(proxyIndex, !isExpanded(proxyIndex)); | 134 | setExpanded(proxyIndex, !isExpanded(proxyIndex)); | ||
118 | return; | 135 | return; | ||
119 | } | 136 | } | ||
120 | } | 137 | } | ||
138 | } | ||||
121 | 139 | | |||
122 | QTreeView::mousePressEvent( event ); | 140 | QTreeView::mousePressEvent( event ); | ||
123 | } | 141 | } | ||
124 | 142 | | |||
125 | template<typename F> void KDevDocumentView::visitItems(F f, bool selectedItems) | 143 | template<typename F> void KDevDocumentView::visitItems(F f, bool selectedItems) | ||
126 | { | 144 | { | ||
127 | KDevelop::IDocumentController* dc = m_plugin->core()->documentController(); | 145 | KDevelop::IDocumentController* dc = m_plugin->core()->documentController(); | ||
128 | const QList<QUrl> docs = selectedItems ? m_selectedDocs : m_unselectedDocs; | 146 | const QList<QUrl> docs = selectedItems ? m_selectedDocs : m_unselectedDocs; | ||
▲ Show 20 Lines • Show All 233 Lines • Show Last 20 Lines |
Looks incorrect actionClose || actionOpen