コード例 #1
0
void CCheckBoxTreeView::AddDeviceTreeNode(std::string szDeviceID,  WTreeNode* parentNode)
{

    WTreeNode* pNode;
    OBJECT objDevice = GetEntity(szDeviceID);
    if(objDevice != INVALID_VALUE)
    {
        MAPNODE node = GetEntityMainAttribNode(objDevice);
        if(node != INVALID_VALUE)
        {
            string szName = "";

            FindNodeValue(node, "sv_name", szName);

            pNode=makeTreeFile(szName, szDeviceID, Tree_DEVICE, parentNode, false, true, 
               "/Images/cbb-4server.gif", "/Images/cbb-4server.gif");   

            if(bDevice ==true) //树的最后一层是设备
            {
                pNode->expandIcon_->hide();
            }
            else
            {
                if(pNode!=NULL)
                    connect(pNode,SIGNAL(addmonitor()),this, SLOT(ListMonitorInDevice()));			
            }

            //			if(szDeviceID=="1.11")  pTestNode= pNode;
        }
        CloseEntity(objDevice);
    }
}
コード例 #2
0
void TreeListExample::addMap()
{
  TreeNode *node
    = makeTreeMap(mapNameEdit_->text() + L" "
		  + boost::lexical_cast<std::wstring>(++testCount_),
		  testMap_);
  makeTreeFile(L"File " + boost::lexical_cast<std::wstring>(testCount_),
	       node);

  removeMapButton_->enable();
}
コード例 #3
0
WTreeNode * CCheckBoxTreeView::AddGroupTreeNode(std::string szSubGroupID,   WTreeNode* parentNode,bool bhaveCheck)
{
    WTreeNode * tmpNode=NULL;
    OBJECT  groupnode = GetGroup(szSubGroupID);
    if(groupnode != INVALID_VALUE)
    {
        MAPNODE node = GetGroupMainAttribNode(groupnode);
        if(node != INVALID_VALUE)
        {
            string szName = "";

            FindNodeValue(node, "sv_name", szName);
            tmpNode = makeTreeFile(szName, szSubGroupID, Tree_GROUP, parentNode,false, bhaveCheck,  
                "/Images/cbb-3group.gif", "/Images/cbb-3group.gif"); 

        }
        CloseGroup(groupnode);
    }
    return tmpNode;

}
コード例 #4
0
bool CCheckBoxTreeView::InitTree(std::string strFirstNode_, bool bDevice_ ,bool bCheck_ ,bool bMain_ ,std::string strUser_, 
                                 std::string szSEID)
{
    vector<string >::iterator iSelItor;
	m_pOldSelNode =NULL;

    if(treeroot)
        delete treeroot;

    if (m_menutable)
    {
        while ( m_menutable->numRows() > 1)
        {
            m_menutable->deleteRow(m_menutable->numRows() - 1);
        }
    }
    strFirstNode=strFirstNode_;
    bDevice=bDevice_;
    bCheck=bCheck_;
    bMain=bMain_;
    strUser=strUser_;
    pTreeSelNode =NULL;
    if (bDevice_)  //增加权限table cell
    {
        if(pRightTbl==NULL)
        {
            InitRightCell();
        }
        Scrolltable->resize(WLength(100,WLength::Percentage), 450);
        this->setStyleClass("margin_top");
    }else {
        this->setStyleClass("margin_top");
        Scrolltable->setStyleClass("widthauto");
    }

    int nAdmin = GetIniFileInt(strUser, "nAdmin", -1, "user.ini");
    if(nAdmin==-1)
        bAdmin = false;
    else 
		bAdmin= true;

    if(!bAdmin)
    {
        std::string groupright= GetIniFileString(strUser, "groupright", "", "user.ini");
        ParserToken(pUserSelGroupList,groupright.c_str(),",");
        vector<string>::iterator  result1; 
        for( result1=pUserSelGroupList.begin();result1!=pUserSelGroupList.end();result1++)
            PushGroup(result1->c_str(),pUserTreeGroupList);
    }

    WTreeNode *FistNode;

    {
        OBJECT root = GetSVSE(szSEID);
        list<string> lsGroupID;
        list<string>::iterator lstItem;
        WTreeNode *tmpNode = NULL;

        if(treeroot!=NULL)
        {
            FistNode= makeTreeFile(GetSVSELabel(root), szSEID, Tree_SE, treeroot, false, false,
                 "/Images/cbb-2main.gif", "/Images/cbb-2main.gif");  
        }else{
            FistNode= makeTreeMap(GetSVSELabel(root), szSEID, Tree_SE, m_menutable, false, false,
                "/Images/cbb-2main.gif", "/Images/cbb-2main.gif");  
            treeroot= FistNode;
        }

        if (root != INVALID_VALUE)
        {
            //第一层组
            if(GetSubGroupsIDBySE(root, lsGroupID))
            {
                map<int, base_param, less<int> > sortList;
                map<int, base_param, less<int> >::iterator lsItem;
                base_param group;
                for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++)
                {
                    string szSubGroupID = (*lstItem).c_str();
                    bool bSelTree = true;// 是否增加组或者设备到树上
                    if(!bAdmin)
                    {
                        iSelItor = find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szSubGroupID);
                        if(iSelItor == pUserTreeGroupList.end())
                            bSelTree= false;
					}
                    if(bSelTree)
                    {
                        OBJECT objGroup = GetGroup(szSubGroupID);
                        if(objGroup != INVALID_VALUE)
                        {
                            MAPNODE node = GetGroupMainAttribNode(objGroup);
                            if(node != INVALID_VALUE)
                            {
                                string szName = "", szIndex = "";
                                FindNodeValue(node, "sv_index", szIndex);
                                if(szIndex.empty())
                                    szIndex = findIndexByRealID(szSubGroupID);
                                group.szIndex = szSubGroupID;
                                group.szName = szName;
                                int nIndex = atoi(szIndex.c_str());
                                lsItem = sortList.find(nIndex);
                                while(lsItem != sortList.end())
                                {
                                    nIndex ++;
                                    lsItem = sortList.find(nIndex);
                                }
                                sortList[nIndex] = group;
                            }
                            CloseGroup(objGroup);
                        }
                    }
                }
                for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
                {
                    bool bTreehaveCheck=true;
                    if(bCheck_)
                        bTreehaveCheck =true;
                    else
                    {
                        iSelItor =find(pUserSelGroupList.begin(),pUserSelGroupList.end(), lsItem->second.szIndex);
                        if(iSelItor ==pUserSelGroupList.end())
                            bTreehaveCheck= false;
                    }
                    tmpNode=AddGroupTreeNode(lsItem->second.szIndex, FistNode, bTreehaveCheck);
                    if(tmpNode!=NULL)
                        EnumGroup(lsItem->second.szIndex, tmpNode, bTreehaveCheck);
                }
            }

            if(GetSubEntitysIDBySE(root, lsGroupID))
            {
                map<int, base_param, less<int> > sortList;
                map<int, base_param, less<int> >::iterator lsItem;
                base_param device;
                for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++)
                {
                    string szEntityID = (*lstItem).c_str();
                    bool bSelTree =true;// 是否增加组或者设备到树上
                    if(!bAdmin)
                    {
                        iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szEntityID);
                        if(iSelItor ==pUserTreeGroupList.end())
                            bSelTree= false;
                    }
                    if(bSelTree)
                    {
                        OBJECT objDevice = GetEntity(szEntityID);
                        if(objDevice != INVALID_VALUE)
                        {
                            MAPNODE node = GetEntityMainAttribNode(objDevice);
                            if(node != INVALID_VALUE)
                            {
                                string szName = "", szIndex = "";
                                //FindNodeValue(node, "sv_name", szName);
                                FindNodeValue(node, "sv_index", szIndex);
                                if(szIndex.empty())
                                    szIndex = findIndexByRealID(szEntityID);
                                device.szIndex = szEntityID;
                                device.szName = szName;
                                int nIndex = atoi(szIndex.c_str());
                                lsItem = sortList.find(nIndex);
                                while(lsItem != sortList.end())
                                {
                                    //nMax ++;
                                    nIndex ++;
                                    lsItem = sortList.find(nIndex);
                                }
                                sortList[nIndex] = device;
                            }
                            CloseEntity(objDevice);
                        }
                        //AddDeviceTreeNode(szEntityID, parentNode );      
                    }
                } 
                for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
                    AddDeviceTreeNode(lsItem->second.szIndex, FistNode); 
            }
            CloseSVSE(root);
        }
    }
	
	makeTreeFile("无依靠", "-2", Tree_MONITOR, FistNode, false,	 false, "/Images/cbb-6application.gif","/Images/cbb-6application.gif");

    return true;
}
コード例 #5
0
void CCheckBoxTreeView::AddMontiorInDevice(WTreeNode* pDeviceNode,bool bExpand)
{	
	OutputDebugString("AddMonitorInDevice()\n");
    if(pDeviceNode!=NULL)
    {
        //OutputDebugString("AddMontiorInDevice\n");
        map<int, base_param, less<int> > sortList;
        map<int, base_param, less<int> >::iterator lsItem;
        pDeviceNode->bMExpand=true;
        OBJECT objDevice = GetEntity(pDeviceNode->strId);
        if(objDevice != INVALID_VALUE)
        {
            list<string> lsMonitorID;
            list<string>::iterator lstItem;
            if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID))
            {
                base_param monitor;
                //nMax = lsMonitorID.size();
                for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++)
                {
                    string szMonitorId = (*lstItem).c_str();
                    OBJECT objMonitor = GetMonitor(szMonitorId);
                    if(objMonitor != INVALID_VALUE)
                    {
                        MAPNODE node = GetMonitorMainAttribNode(objMonitor);
                        if(node != INVALID_VALUE)
                        {
                            string szName = "", szIndex = "";
                            FindNodeValue(node, "sv_name", szName);
                            FindNodeValue(node, "sv_index", szIndex);
                            if(szIndex.empty())
                                szIndex = findIndexByRealID(szMonitorId);
                            monitor.szIndex = szMonitorId;
                            monitor.szName = szName;

                            int nIndex = atoi(szIndex.c_str());
                            lsItem = sortList.find(nIndex);
                            while(lsItem != sortList.end())
                            {
                                //PrintDebugString("be found");
                                //nMax ++;
                                nIndex ++;//= nMax;
                                lsItem = sortList.find(nIndex);
                            }
                            sortList[nIndex] = monitor;
                        }
                        CloseMonitor(objMonitor);
                    }
                }
            }
            CloseEntity(objDevice);			
        }
        for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
        {
            WTreeNode *pNode=makeTreeFile(lsItem->second.szName,lsItem->second.szIndex, Tree_MONITOR, pDeviceNode, false,	
                    true,"/Images/cbb-6application.gif","/Images/cbb-6application.gif");
            if(bExpand)
            {
                if(pDeviceNode->treeCheckBox_->isChecked())
                pNode->treeCheckBox_->setChecked(true);
            }
        }
    }
}
コード例 #6
0
TreeListExample::TreeListExample(WContainerWidget *parent)
  : WContainerWidget(parent),
    testCount_(0)
{
  tree_ = makeTreeMap(L"TreeListExample", 0);
  addWidget(tree_);
  tree_->expand();

  TreeNode *treelist = makeTreeMap(L"Tree List", tree_);
  TreeNode *wstateicon = makeTreeMap(L"class IconPair", treelist);
  makeTreeFile(L"IconPair.h", wstateicon);
  makeTreeFile(L"IconPair.C", wstateicon);
  TreeNode *wtreenode = makeTreeMap(L"class TreeNode", treelist);
  makeTreeFile(L"TreeNode.h", wtreenode);
  makeTreeFile(L"TreeNode.C", wtreenode);
  TreeNode *wtreeexample = makeTreeMap(L"class TreeListExample", treelist);
  makeTreeFile(L"TreeListExample.h", wtreeexample);
  makeTreeFile(L"TreeListExample.C", wtreeexample);

  testMap_ = makeTreeMap(L"Test map", tree_);

  /*
   * Buttons to demonstrate dynamically changing the tree contents
   * implies no magic at all.
   */
  addWidget
    (new WText(L"<p>Use the following buttons to change the "
	       "contents of the Test map:</p>"));

  WGroupBox *addBox = new WGroupBox(L"Add map", this);

  WLabel *mapNameLabel = new WLabel(L"Map name:", addBox);
  mapNameLabel->setMargin(WLength(1, WLength::FontEx), Right);
  mapNameEdit_ = new WLineEdit(L"Map", addBox);
  mapNameLabel->setBuddy(mapNameEdit_);

  /*
   * Example of validation: make the map name mandatory, and give
   * feedback when invalid.
   */
  mapNameEdit_->setValidator(new WValidator(true));
  WImage *invalid = new WImage("icons/invalid.png");
  WImage *invalidEmpty = new WImage("icons/invalid.png");

  WValidationStatus *statusIcon
    = new WValidationStatus(mapNameEdit_, 0, invalid, invalidEmpty, addBox);
  statusIcon->setMargin(WLength(5), Left | Right);

  addMapButton_ = new WPushButton(L"Add map", addBox);
  addMapButton_->clicked.connect(SLOT(this, TreeListExample::addMap));

  statusIcon->validated.connect(SLOT(addMapButton_, WFormWidget::setEnabled));

  new WBreak(this);

  WGroupBox *removeBox = new WGroupBox(L"Remove map", this);

  removeMapButton_
    = new WPushButton(L"Remove map", removeBox);
  removeMapButton_->clicked.connect(SLOT(this, TreeListExample::removeMap));
  removeMapButton_->disable();
}