Пример #1
0
void NetworkCatalogTree::updateVisibility() {
	//adding to remove list and clearing all existed nodes
	List toRemove;
	NetworkItem::List itemsWithNodes; //used in loop for creating new nodes (for these items new nodes won't be created)
	for (std::size_t i = 0; i < children().size(); ++i) {
		ZLTreeNode* tree = children().at(i);
		if (!tree->isInstanceOf(NetworkCatalogTree::TYPE_ID)) {
			continue;
		}
		NetworkCatalogTree *child = (NetworkCatalogTree*)tree;
		itemsWithNodes.push_back(child->myItem);
		switch (child->item().getVisibility()) {
			case B3_TRUE:
				child->updateVisibility();
				break;
			case B3_FALSE:
				toRemove.push_back(child);
				break;
			case B3_UNDEFINED:
				child->clearCatalog();
				break;
		}
	}

	//creating new nodes (if necessary)
	for (std::size_t i = 0; i < myChildrenItems.size(); ++i) {
		shared_ptr<NetworkItem> item = myChildrenItems.at(i);
		if (!item->isInstanceOf(NetworkCatalogItem::TYPE_ID)) {
			continue;
		}
		if (std::find(itemsWithNodes.begin(), itemsWithNodes.end(), item) != itemsWithNodes.end()) {
			continue;
		}
		NetworkCatalogItem *catalogItem = (NetworkCatalogItem*)(&*item);
		if (catalogItem->getVisibility() != B3_FALSE) {
			NetworkTreeFactory::createNetworkTree(this, item, i);
		}
	}

	for (std::size_t i = 0; i < toRemove.size(); ++i) {
		ZLTreeNode* tree = toRemove.at(i);
		remove(tree);
	}

}
Пример #2
0
void TreeViewForm::OnItemStateChanged (const Tizen::Ui::Control &source, int index, int itemId, Tizen::Ui::ItemStatus status)
{
	Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
	String strName;
	AppLog("index %d",index);
	//ZLTreeNode* node = myModel->myCurrentNode->children().at(index);
	ZLTreeNode* node = myTreeDialog->myCurrentNode->children().at(index);
    int actionsCount = node->actions().size();
	AppLog("node->actions().size %d", actionsCount);


	switch (actionsCount){
	case  0: if (ZLTreeTitledNode *TitledNode = zlobject_cast<ZLTreeTitledNode*>(node))
				{
			 	 AppLog("Node is ZLTreeTitledNode %s ",TitledNode->title().c_str());
			 	 //myTreeDialog->enter(node);
			 	 AppLog("exit enter");
				};
			 break;
	//case  1:
			// pFrame->SetCurrentForm(*pPreviousForm);
		//TODO испраивть на приличную проверку что действие в содежаннии

		// break;
	default:
		/*
		if (exitFlag){
				AppLog("exitFlag == true");
				//pFrame->SetCurrentForm(*pPreviousForm);

			}
		*/
		      std::string actionName = node->actions()[0]->key().Name;
		      AppLog("action name %s",actionName.c_str());
		      if (actionName == "gotoParagraph") pPreviousForm->SendUserEvent(0, null);



			  myTreeDialog->treadTerminator();
			  //node->actions()[0]->run();
			  break;
	}

}
Пример #3
0
void FBFileHandler::changeFolder(const ZLTreeNode &node) {
    shared_ptr<ZLDir> dir = ZLFile(myDir->itemPath(node.id())).directory();
    if (!dir.isNull()) {
        const std::string selectedId = myDir->name();
        myDir = dir;
        myIsUpToDate = false;
        mySubnodes.clear();
        mySelectedIndex = 0;
        if (node.id() == "..") {
            int index = 0;
            const std::vector<ZLTreeNodePtr> &subnodes = this->subnodes();
            for (std::vector<ZLTreeNodePtr>::const_iterator it = subnodes.begin(); it != subnodes.end(); ++it) {
                if ((*it)->id() == selectedId) {
                    mySelectedIndex = index;
                    break;
                }
                ++index;
            }
        }
        addUpdateInfo(UPDATE_ALL);
    }
}
Пример #4
0
bool FBFileHandler::accept(const ZLTreeNode &node) {
    FBReader::createDescription(myDir->itemPath(node.id()), myDescription);
    return !myDescription.isNull();
}
void ShowNetworkLibraryTreeAction::run() {
	shared_ptr<ZLTreeDialog>  myDialog = ZLDialogManager::Instance().createTreeDialog(ZLResourceKey("NetworkTreeDialog"));
	ZLTreeListener::RootNode &rootNode = myDialog->rootNode();
	NetworkLinkCollection &collection = NetworkLinkCollection::Instance();
	AppLog(" NetworkLinkCollection::Instance()");
	std::set<ZLTreeNode*> nodesToDelete;
	ZLTreeNode::List rootChildren = rootNode.children();

	ZLTreeNode::List::iterator nodeIt = rootChildren.begin();
	size_t nodeCount = 0;
	AppLog("collection.size() = %d",collection.size());
	for (size_t i = 0; i < collection.size(); ++i) {
		AppLog("i = %d",i);
		NetworkLink &link = collection.link(i);
//		if (!link.isEnabled()) {
//			continue;
//		}
		bool processed = false;
		AppLog("processed");
		while (nodeIt != rootChildren.end() &&
					 (*nodeIt)->isInstanceOf(NetworkCatalogNode::TYPE_ID)) {
			AppLog("while");
			const NetworkLink &nodeLink = ((NetworkCatalogRootNode*)*nodeIt)->link();
			if (&nodeLink == &link && nodeLink.SiteName == link.SiteName) {
				AppLog("reloadLink() 1");
				((NetworkCatalogRootNode*)*nodeIt)->reloadLink();
				++nodeIt;
				++nodeCount;
				processed = true;
				break;
			} else {
				bool found = false;
				for (size_t j = i + 1; j < collection.size(); ++j) {
					if (&nodeLink == &collection.link(j) && nodeLink.SiteName == collection.link(j).SiteName) {
						found = true;
						AppLog("reloadLink() 2");
						((NetworkCatalogRootNode*)*nodeIt)->reloadLink();
						break;
					}
				}
				if (!found) {
					nodesToDelete.insert(*nodeIt++);
					++nodeCount;
				} else {
					break;
				}
			}
		}

		if (!processed) {
			NetworkCatalogNode *ptr = new NetworkCatalogRootNode(&rootNode, link, nodeCount++);
			//ptr->item().onDisplayItem();
		}
	}

	SearchResultNode *srNode = 0;

	while (nodeIt != rootChildren.end()) {
		ZLTreeNode *node = *nodeIt++;
		++nodeCount;
		if (node->isInstanceOf(SearchResultNode::TYPE_ID)) {
			srNode = (SearchResultNode*)node;
		} else {
			nodesToDelete.insert(node);
		}
	}

	const SearchResult &searchResult = SearchResult::lastSearchResult();
	shared_ptr<NetworkBookCollection> result = searchResult.collection();
	if (result.isNull()) {
		if (srNode != 0) {
			nodesToDelete.insert(srNode);
		}
	} else if (srNode == 0 || srNode->searchResult() != result) {
		if (srNode != 0) {
			nodesToDelete.insert(srNode);
		}
		//srNode = new SearchResultNode(&rootNode, result, searchResult.summary()); // at nodeCount ??? or not???
		NetworkNodesFactory::createSubnodes(srNode, *result);
	}

	for (std::set<ZLTreeNode*>::iterator it = nodesToDelete.begin(); it != nodesToDelete.end(); ++it) {
		ZLTreeNode *node = *it;
		node->parent()->remove(node);
		delete node;
	}

//	if (srNode != 0) {
//		srNode->open(false);
//		srNode->expandOrCollapseSubtree();
//	}

	myDialog->run();
}