Пример #1
0
    ExplorerServerItem* ExplorerTreeModel::findServerItem(IServer* server) const
    {
        fasto::qt::gui::TreeItem *parent = dynamic_cast<fasto::qt::gui::TreeItem*>(root_);
        DCHECK(parent);
        if(!parent){
            return NULL;
        }

        for(int i = 0; i < parent->childrenCount(); ++i){
            ExplorerServerItem *item = dynamic_cast<ExplorerServerItem*>(parent->child(i));
            if(item){
                if(item->server().get() == server){
                    return item;
                }
            }
            else{
                ExplorerClusterItem* citem = dynamic_cast<ExplorerClusterItem*>(parent->child(i));
                if(citem){
                    for(int j = 0; j < citem->childrenCount(); ++j){
                        ExplorerServerItem *item = dynamic_cast<ExplorerServerItem*>(citem->child(i));
                        if(item){
                            if(item->server().get() == server){
                                return item;
                            }
                        }
                    }
                }
            }
        }
        return NULL;
    }
Пример #2
0
    void ExplorerTreeView::closeServerConnection()
    {
        QModelIndex sel = selectedIndex();
        if(!sel.isValid()){
            return;
        }

        ExplorerServerItem* snode = common::utils_qt::item<ExplorerServerItem*>(sel);
        if(snode){
            IServerSPtr server = snode->server();
            if(server){
                removeServer(server);
            }
            return;
        }

        ExplorerClusterItem* cnode = common::utils_qt::item<ExplorerClusterItem*>(sel);
        if(cnode && cnode->type() == IExplorerTreeItem::eCluster){
            IClusterSPtr server = cnode->cluster();
            if(server){
                removeCluster(server);
            }
            return;
        }
    }
Пример #3
0
    ExplorerClusterItem* ExplorerTreeModel::findClusterItem(IClusterSPtr cl)
    {
        fasto::qt::gui::TreeItem *parent = dynamic_cast<fasto::qt::gui::TreeItem*>(root_);
        DCHECK(parent);
        if(!parent){
            return NULL;
        }

        for(int i = 0; i < parent->childrenCount() ; ++i){
            ExplorerClusterItem *item = dynamic_cast<ExplorerClusterItem*>(parent->child(i));
            if(item && item->cluster() == cl){
                return item;
            }
        }
        return NULL;
    }