void WTreeNode::update() { bool isLast = isLastChildNode(); if (!visible_) { layout_->bindString("selected", "Wt-root"); childContainer()->addStyleClass("Wt-root"); } else { if (tree()) { const WTree::WTreeNodeSet &s = tree()->selectedNodes(); if (s.find(this) != s.end()) layout_->bindString("selected", WApplication::instance()->theme()->activeClass()); else layout_->bindEmpty("selected"); } else layout_->bindEmpty("selected"); childContainer()->removeStyleClass("Wt-root"); } WTreeNode *parent = parentNode(); if (parent && !parent->childrenDecorated_) { // FIXME } if (expandIcon_->state() != (isExpanded() ? 1 : 0)) expandIcon_->setState(isExpanded() ? 1 : 0); if (childContainer()->isHidden() != !isExpanded()) childContainer()->setHidden(!isExpanded()); if (labelIcon_ && (labelIcon_->state() != (isExpanded() ? 1 : 0))) labelIcon_->setState(isExpanded() ? 1 : 0); toggleStyleClass("Wt-trunk", !isLast); layout_->bindString("trunk-class", isLast ? "Wt-end" : "Wt-trunk"); if (!parentNode() || parentNode()->isExpanded()) { if (childCountPolicy_ == Enabled && !populated_) doPopulate(); if (!expandable()) { if (noExpandIcon_->parent() == 0) { layout_->takeWidget("expand"); layout_->bindWidget("expand", noExpandIcon_); } } else { if (expandIcon_->parent() == 0) { layout_->takeWidget("expand"); layout_->bindWidget("expand", expandIcon_); } } } if (childCountPolicy_ != Disabled && populated_ && childCountLabel_) { int n = displayedChildCount(); if (n) childCountLabel_->setText (WString::fromUTF8("(" + boost::lexical_cast<std::string>(n) + ")")); else childCountLabel_->setText(WString()); } }
void WTreeNode::update() { bool isLast = isLastChildNode(); if (!visible_) { layout_->rowAt(0)->hide(); expandIcon_->hide(); layout_->elementAt(0, 0)->resize(0, WLength::Auto); layout_->elementAt(1, 0)->resize(0, WLength::Auto); } else { layout_->rowAt(0)->show(); expandIcon_->show(); layout_->elementAt(0, 0)->resize(WLength::Auto, WLength::Auto); layout_->elementAt(1, 0)->resize(WLength::Auto, WLength::Auto); } WTreeNode *parent = parentNode(); if (parent && !parent->childrenDecorated_) { layout_->elementAt(0, 0)->hide(); layout_->elementAt(1, 0)->hide(); } if (expandIcon_->state() != (isExpanded() ? 1 : 0)) expandIcon_->setState(isExpanded() ? 1 : 0); if (layout_->rowAt(1)->isHidden() != !isExpanded()) layout_->rowAt(1)->setHidden(!isExpanded()); if (labelIcon_ && (labelIcon_->state() != (isExpanded() ? 1 : 0))) labelIcon_->setState(isExpanded() ? 1 : 0); if (isLast) { layout_->elementAt(0, 0)->setStyleClass("Wt-end"); layout_->elementAt(1, 0)->setStyleClass(""); } else { layout_->elementAt(0, 0)->setStyleClass("Wt-trunk"); layout_->elementAt(1, 0)->setStyleClass("Wt-trunk"); } if (!parentNode() || parentNode()->isExpanded()) { if (childCountPolicy_ == Enabled && !populated_) doPopulate(); if (!expandable()) { if (noExpandIcon_->parent() == 0) { layout_->elementAt(0, 0)->addWidget(noExpandIcon_); layout_->elementAt(0, 0)->removeWidget(expandIcon_); } } else { if (expandIcon_->parent() == 0) { layout_->elementAt(0, 0)->addWidget(expandIcon_); layout_->elementAt(0, 0)->removeWidget(noExpandIcon_); } } } if (childCountPolicy_ != Disabled && populated_ && childCountLabel_) { int n = displayedChildCount(); if (n) childCountLabel_->setText (WString::fromUTF8("(" + boost::lexical_cast<std::string>(n) + ")")); else childCountLabel_->setText(WString()); } }