void LibraryView::showBook(shared_ptr<Book> book) { makeUpToDate(); ZLBlockTreeNode::List bookNodes; std::queue<ZLBlockTreeNode*> nodesQueue; nodesQueue.push(&rootNode()); while (!nodesQueue.empty()) { const ZLBlockTreeNode::List &children = nodesQueue.front()->children(); nodesQueue.pop(); for (ZLBlockTreeNode::List::const_iterator it = children.begin(); it != children.end(); ++it) { if ((*it)->isInstanceOf(BookNode::TYPE_ID)) { // TODO: replace with == for shared_ptr<Book> //if (((BookNode*)*it)->book() == book) { if (((BookNode*)*it)->book()->file() == book->file()) { bookNodes.push_back(*it); } } else { nodesQueue.push(*it); } } } if (bookNodes.empty()) { return; } ZLBlockTreeNode *nodeToShow = bookNodes[0]; VisibilityMode mode = INVISIBLE; for (ZLBlockTreeNode::List::iterator it = bookNodes.begin(); it != bookNodes.end(); ++it) { VisibilityMode nodeMode = visibilityMode(*it); if ((nodeMode == VISIBLE && mode != VISIBLE) || (nodeMode != INVISIBLE && mode == INVISIBLE)) { nodeToShow = *it; mode = nodeMode; } } ensureVisible(nodeToShow); }