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

Function selectUse

plugins/contextbrowser/contextbrowserview.cpp:49–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49void selectUse(ContextBrowserView* view, Direction direction)
50{
51 auto abstractNaviWidget = qobject_cast<AbstractNavigationWidget*>(view->navigationWidget());
52
53 if (!abstractNaviWidget) {
54 return;
55 }
56
57 auto usesWidget = qobject_cast<UsesWidget*>(abstractNaviWidget->context()->widget());
58 if (!usesWidget) {
59 return;
60 }
61
62 OneUseWidget* first = nullptr, * previous = nullptr, * current = nullptr;
63 const auto& usesWidgetItems = usesWidget->items();
64 for (auto item : usesWidgetItems) {
65 auto topContext = qobject_cast<TopContextUsesWidget*>(item);
66 if (!topContext) {
67 continue;
68 }
69 const auto& topContextItems = topContext->items();
70 for (auto item : topContextItems) {
71 auto navigationList = qobject_cast<NavigatableWidgetList*>(item);
72 if (!navigationList) {
73 continue;
74 }
75 const auto& navigationListItems = navigationList->items();
76 for (auto item : navigationListItems) {
77 auto use = qobject_cast<OneUseWidget*>(item);
78 if (!use) {
79 continue;
80 }
81 if (!first) {
82 first = use;
83 }
84 current = use;
85 if (direction == PreviousUse && current->isHighlighted() && previous) {
86 previous->setHighlighted(true);
87 previous->activateLink();
88 current->setHighlighted(false);
89 return;
90 }
91 if (direction == NextUse && previous && previous->isHighlighted()) {
92 current->setHighlighted(true);
93 current->activateLink();
94 previous->setHighlighted(false);
95 return;
96 }
97 previous = current;
98 }
99 }
100 }
101
102 if (direction == NextUse && first) {
103 first->setHighlighted(true);
104 first->activateLink();
105 if (current && current->isHighlighted())
106 current->setHighlighted(false);

Callers 2

selectNextItemMethod · 0.85
selectPreviousItemMethod · 0.85

Calls 7

navigationWidgetMethod · 0.80
isHighlightedMethod · 0.80
setHighlightedMethod · 0.80
activateLinkMethod · 0.80
widgetMethod · 0.45
contextMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected