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

Method helpEvent

plugins/projectmanagerview/projectmodelitemdelegate.cpp:166–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166bool ProjectModelItemDelegate::helpEvent(QHelpEvent* event,
167 QAbstractItemView* view, const QStyleOptionViewItem& option,
168 const QModelIndex& index)
169{
170 if (!event || !view) {
171 return false;
172 }
173
174 if (event->type() == QEvent::ToolTip) {
175 // explicitly close current tooltip, as its autoclose margins overlap items
176 if ((m_tooltippedIndex != index) && m_tooltip) {
177 m_tooltip->close();
178 m_tooltip.clear();
179 }
180
181 const ProjectBaseItem* it = index.data(ProjectModel::ProjectItemRole).value<ProjectBaseItem*>();
182
183 // show navigation tooltip for files
184 if (it && it->file()) {
185 if (!m_tooltip) {
186 m_tooltippedIndex = index;
187 KDevelop::DUChainReadLocker lock(KDevelop::DUChain::lock());
188 const TopDUContext* top = DUChainUtils::standardContextForUrl(it->file()->path().toUrl());
189
190 if (top) {
191 if (auto* navigationWidget = top->createNavigationWidget()) {
192 // force possible existing normal tooltip for other list item to hide
193 // Seems that is still only done with a small delay though,
194 // but the API seems not to allow more control.
195 QToolTip::hideText();
196
197 m_tooltip = new KDevelop::NavigationToolTip(view, event->globalPos() + QPoint(40, 0), navigationWidget);
198 m_tooltip->resize(navigationWidget->sizeHint() + QSize(10, 10));
199 auto rect = view->visualRect(m_tooltippedIndex);
200 rect.moveTopLeft(view->mapToGlobal(rect.topLeft()));
201 m_tooltip->setHandleRect(rect);
202 ActiveToolTip::showToolTip(m_tooltip);
203 }
204 }
205 }
206
207 // tooltip successfully handled by us?
208 if (m_tooltip) {
209 return true;
210 }
211 }
212 }
213
214 return QItemDelegate::helpEvent(event, view, option, index);
215}
216
217#include "moc_projectmodelitemdelegate.cpp"

Callers

nothing calls this directly

Calls 11

setHandleRectMethod · 0.80
QPointClass · 0.50
typeMethod · 0.45
closeMethod · 0.45
clearMethod · 0.45
dataMethod · 0.45
fileMethod · 0.45
toUrlMethod · 0.45
pathMethod · 0.45
sizeHintMethod · 0.45

Tested by

no test coverage detected