| 291 | } |
| 292 | |
| 293 | void TreeControl::validate() |
| 294 | { |
| 295 | using PairNodeEnumeration = std::pair<VectorNodePtr::iterator, VectorNodePtr::iterator>; |
| 296 | using ListNodeEnumeration = std::list<PairNodeEnumeration>; |
| 297 | ListNodeEnumeration EnumerationStack; |
| 298 | PairNodeEnumeration Enumeration; |
| 299 | VectorNodePtr vectorNodePtr; |
| 300 | if (mbRootVisible) |
| 301 | { |
| 302 | vectorNodePtr.push_back(mpRoot); |
| 303 | Enumeration = PairNodeEnumeration(vectorNodePtr.begin(), vectorNodePtr.end()); |
| 304 | } |
| 305 | else |
| 306 | Enumeration = PairNodeEnumeration(mpRoot->getChildren().begin(), mpRoot->getChildren().end()); |
| 307 | |
| 308 | size_t nLevel = 0; |
| 309 | size_t nIndex = 0; |
| 310 | size_t nItem = 0; |
| 311 | int nOffset = 0 - mnTopOffset; |
| 312 | |
| 313 | while (true) |
| 314 | { |
| 315 | if (Enumeration.first == Enumeration.second) |
| 316 | { |
| 317 | if (EnumerationStack.empty()) |
| 318 | break; |
| 319 | |
| 320 | Enumeration = EnumerationStack.back(); |
| 321 | EnumerationStack.pop_back(); |
| 322 | nLevel--; |
| 323 | continue; |
| 324 | } |
| 325 | |
| 326 | Node* pNode = *Enumeration.first; |
| 327 | Enumeration.first++; |
| 328 | |
| 329 | if (nIndex >= (size_t)mnTopIndex) |
| 330 | { |
| 331 | // FIXME проверка вставлена так как падает индекс айтема больше чем всего айтемов |
| 332 | if (nItem >= mItemWidgets.size()) |
| 333 | break; |
| 334 | |
| 335 | if (nIndex >= mnExpandedNodes || mItemWidgets[nItem]->getTop() > getClientWidget()->getHeight()) |
| 336 | break; |
| 337 | |
| 338 | TreeControlItem* pItem = mItemWidgets[nItem]; |
| 339 | pItem->setVisible(true); |
| 340 | pItem->setCaption(pNode->getText()); |
| 341 | pItem->setPosition(IntPoint(nLevel * mnLevelOffset, nOffset)); |
| 342 | pItem->setStateSelected(pNode == mpSelection); |
| 343 | pItem->setUserData(pNode); |
| 344 | |
| 345 | Button* pButtonExpandCollapse = pItem->getButtonExpandCollapse(); |
| 346 | pButtonExpandCollapse->setVisible(pNode->hasChildren()); |
| 347 | pButtonExpandCollapse->setStateSelected(!pNode->isExpanded()); |
| 348 | |
| 349 | ImageBox* pIcon = pItem->getIcon(); |
| 350 | if (pIcon) |
nothing calls this directly
no test coverage detected