MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / MacroIndexToModelIndex

Function MacroIndexToModelIndex

lib/macro/macro-tree.cpp:360–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360static inline int
361MacroIndexToModelIndex(int realIdx,
362 const std::deque<std::shared_ptr<Macro>> &macros)
363{
364 if (realIdx == -1) {
365 return -1;
366 }
367
368 int modelIdx = 0;
369 bool inCollapsedGroup = false;
370 uint32_t groupSize = 0;
371 for (int i = 0; i < realIdx; i++) {
372 if (inCollapsedGroup) {
373 i += groupSize - 1;
374 groupSize = 0;
375 inCollapsedGroup = false;
376 continue;
377 }
378 const auto &m = macros.at(i);
379 inCollapsedGroup = m->IsGroup() && m->IsCollapsed();
380 groupSize = m->GroupSize();
381 modelIdx++;
382 }
383 return modelIdx;
384}
385
386void MacroTreeModel::MoveItemBefore(const std::shared_ptr<Macro> &item,
387 const std::shared_ptr<Macro> &before)

Callers 2

GetItemModelIndexMethod · 0.85
dropEventMethod · 0.85

Calls 3

IsGroupMethod · 0.80
IsCollapsedMethod · 0.80
GroupSizeMethod · 0.80

Tested by

no test coverage detected