21 lines
550 B
C++
21 lines
550 B
C++
//
|
|
// Created by grimmauld on 03.03.24.
|
|
//
|
|
|
|
#include "SwayTreeModel.h"
|
|
|
|
QModelIndex SwayTreeModel::findFocusedWindowIndex() const {
|
|
std::vector<int> indices;
|
|
for (const auto *head = getRoot()->findFocused(); head != nullptr; head = head->parentItem()) {
|
|
indices.insert(indices.cbegin(), head->row());
|
|
}
|
|
|
|
// weirdness, idk... ask QT
|
|
QModelIndex idx = this->index(indices.size() < 2 ? 0 : indices[1], 0);
|
|
for (int i = 2; i < indices.size(); ++i) {
|
|
idx = this->index(indices[i], 0, idx);
|
|
}
|
|
|
|
return idx;
|
|
}
|