bool CTuopList::triggerSlot(WObject *sender, const WSlot_ *slot, void **args) { if (slot == slots_ + 0) { sender_ = sender; EditUserName(*((const std::string *)args[0])); return true; } if (slot == slots_ + 1) { sender_ = sender; OpenTuop(*((const std::string *)args[0])); return true; } if (slot == slots_ + 2) { sender_ = sender; SelAll(); return true; } if (slot == slots_ + 3) { sender_ = sender; SelNone(); return true; } if (slot == slots_ + 4) { sender_ = sender; SelInvert(); return true; } if (slot == slots_ + 5) { sender_ = sender; BeforeDelUser(); return true; } if (slot == slots_ + 6) { sender_ = sender; DelUser(); return true; } if (slot == slots_ + 7) { sender_ = sender; EditReturn(*((int *)args[0])); return true; } if (slot == slots_ + 8) { sender_ = sender; Translate(); return true; } if (slot == slots_ + 9) { sender_ = sender; ExChange(); return true; } if (slot == slots_ + 10) { sender_ = sender; Sort(); return true; } if (slot == slots_ + 11) { sender_ = sender; SortOk(); return true; } return WContainerWidget::triggerSlot(sender, slot, args); }
void CTuopList::ShowMainTable() { //strNullList = "空的列表"; m_pMainTable = new WSVMainTable(this,strMainTitle,false); //if(m_pMainTable->pHelpImg) //{ // connect(m_pMainTable->pHelpImg,SIGNAL(click()),this,SLOT(ShowHelp())); //} //拓扑列表界面 m_pTopologyListTable = new WSVFlexTable(m_pMainTable->GetContentTable()->elementAt(0,0),List, strTitle); if (m_pTopologyListTable->GetContentTable() != NULL) { m_pTopologyListTable->AppendColumn("",WLength(40,WLength::Pixel)); m_pTopologyListTable->SetDataRowStyle("table_data_grid_item_text"); m_pTopologyListTable->AppendColumn(strLoginLabel,WLength(70,WLength::Percentage)); m_pTopologyListTable->SetDataRowStyle("table_data_grid_item_text"); m_pTopologyListTable->AppendColumn(strNameUse,WLength(10,WLength::Percentage)); m_pTopologyListTable->SetDataRowStyle("table_data_grid_item_text"); m_pTopologyListTable->AppendColumn(strNameEdit,WLength(10,WLength::Percentage)); m_pTopologyListTable->SetDataRowStyle("table_data_grid_item_text"); } if (m_pTopologyListTable->GetActionTable() != NULL) { m_pTopologyListTable->AddStandardSelLink(strAllSel ,strAllNotSel,strFanSel); connect(m_pTopologyListTable->pSelAll, SIGNAL(clicked()), this, SLOT(SelAll())); connect(m_pTopologyListTable->pSelNone, SIGNAL(clicked()), this, SLOT(SelNone())); connect(m_pTopologyListTable->pSelReverse, SIGNAL(clicked()), this, SLOT(SelInvert())); WTable *pTbl; m_pTopologyListTable->GetActionTable()->elementAt(0,1)->setContentAlignment(AlignCenter); m_pTopologyListTable->GetActionTable()->elementAt(0,1)->setStyleClass("textbold"); pTbl = new WTable(m_pTopologyListTable->GetActionTable()->elementAt(0,1)); pTbl->setStyleClass("widthauto"); WSVButton * pDel = new WSVButton(pTbl->elementAt(0,1),strDelete, "button_bg_del.png", "", false); if (pDel) { connect(pDel, SIGNAL(clicked()), this, SLOT(BeforeDelUser())); } //新增 //WSVButton * pSort = new WSVButton(pTbl->elementAt(0,2), "排序", "button_bg_taxis.png", "", false); WSVButton * pSort = new WSVButton(pTbl->elementAt(0,2), strSort, "button_bg_taxis.png", "", false); if (pSort) { connect(pSort, SIGNAL(clicked()), this, SLOT(Sort())); } //WTable *pTbl2; m_pTopologyListTable->GetActionTable()->elementAt(0, 2)->setContentAlignment(AlignRight); strcpy(m_pTopologyListTable->GetActionTable()->elementAt(0, 2)->contextmenu_, "nowrap"); //Tuopu 发布插件下载 string strTuopPluginJs = "window.open('../TuopoClient.exe','newwindow')"; string szLink = "<a href='#'>" + szTuopDown + "</a> "; WText * pTuopPlugin = new WText(szLink, (WContainerWidget *)m_pTopologyListTable->GetActionTable()->elementAt(0, 2)); connect(pTuopPlugin, SIGNAL(clicked()),strTuopPluginJs.c_str() ,WObject::JAVASCRIPT); } m_pTopologyListTable->SetNullTipInfo(strNullList); //拓扑排序列表界面 //pSortTable = new WSVFlexTable(m_pMainTable->GetContentTable()->elementAt(1,0), List, "拓扑排序列表"); pSortTable = new WSVFlexTable(m_pMainTable->GetContentTable()->elementAt(1,0), List, strTuoPuSortList); if (pSortTable->GetContentTable() != NULL) { pSortTable->AppendColumn("",WLength(40,WLength::Pixel)); pSortTable->SetDataRowStyle("table_data_grid_item_text"); //pSortTable->AppendColumn("名称",WLength(50,WLength::Percentage)); pSortTable->AppendColumn(strName,WLength(50,WLength::Percentage)); pSortTable->SetDataRowStyle("table_data_grid_item_text"); //pSortTable->AppendColumn("序号",WLength(50,WLength::Percentage)); pSortTable->AppendColumn(strSequenceNo,WLength(50,WLength::Percentage)); pSortTable->SetDataRowStyle("table_data_grid_item_text"); } if (pSortTable->GetActionTable() != NULL) { WTable *pTbl1; pSortTable->GetActionTable()->elementAt(0,1)->setContentAlignment(AlignCenter); pSortTable->GetActionTable()->elementAt(0,1)->setStyleClass("textbold"); pTbl1 = new WTable(pSortTable->GetActionTable()->elementAt(0,1)); pTbl1->setStyleClass("widthauto"); //WSVButton * pSortOkBtn = new WSVButton(pTbl1->elementAt(0, 1), "确 定", "button_bg_m.png", "", false); WSVButton * pSortOkBtn = new WSVButton(pTbl1->elementAt(0, 1), strAffirm, "button_bg_m.png", "", false); if(pSortOkBtn) { connect(pSortOkBtn,SIGNAL(clicked()),this,SLOT(SortOk())); } } //编辑事件 std::string strIndex; std::list<string> m_pList; std::list<string>::iterator m_pItem; #ifdef Tuopu m_pList = ReadFileName(GetSiteViewRootPath() + "\\htdocs\\tuoplist"); #else m_pList = ReadFileName(GetSiteViewRootPath() + "\\htdocs\\maintainlist"); #endif std::list<string> m_pVList; std::list<string>::iterator m_pVItem; #ifdef Tuopu m_pVList = ReadVSDName(GetSiteViewRootPath() + "\\htdocs\\tuoplist"); #else m_pVList = ReadVSDName(GetSiteViewRootPath() + "\\htdocs\\maintainlist"); #endif m_pVItem = m_pVList.begin(); for(m_pItem = m_pList.begin(); m_pItem != m_pList.end(); m_pItem++) { std::string strUserName = *m_pItem; std::string strVSD = *m_pVItem; OneRecord list; list.strUserName = strUserName; //vsd文件始终不会更改, 所以用它来制造key list.strBackName = ReplaceStdString(strVSD, ".vsd", ".htm"); list.strTuop = strVSD; //读取tuopfile.ini的sort信息并赋值给OneRecord变量。: //如果没有预先设置的sort信息则按什么规则自动赋值? ---》先是读预先设置的序号, 为默认值 则不存在 意味着是新发布的 //---》规则(读一遍ini, 找到序号最大值, 加1 并写到tuopfile.ini文件中) int nSort = GetIniFileInt("sort", strVSD, -1, "tuopfile.ini"); if(nSort != -1) { list.nSort = nSort; } else { //获取序号最大值, 加1 list.nSort = GetMaxSortId() + 1; //写序号值到ini #ifdef Tuopu WriteIniFileInt("sort", strVSD, list.nSort, "tuopfile.ini"); #else WriteIniFileInt("sort", strVSD, list.nSort, "maintainfile.ini"); #endif } RecordList.push_back(list); m_pVItem++; } //绑定编辑事件 connect(&m_userMapper, SIGNAL(mapped(const std::string)), this, SLOT(EditUserName(const std::string))); //显示列表 int i = 1; std::string strOpen; for(m_pRecordList=RecordList.begin(); m_pRecordList != RecordList.end(); m_pRecordList ++) { m_pTopologyListTable->InitRow(i); pSortTable->InitRow(i); i++; } i = 1; for(m_pRecordList=RecordList.begin(); m_pRecordList != RecordList.end(); m_pRecordList ++) { //列表数据界面初始化 m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 0)->setContentAlignment(AlignCenter); m_pRecordList->pCheckBox = new WCheckBox("", (WContainerWidget*)m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 0)); strOpen = "<a href=./showtuopu.exe?pageid="; strOpen += ReplaceStdString(m_pRecordList->strBackName, ".htm", ""); #ifdef Tuopu strOpen += "&version=0"; #else strOpen += "&version=0&usrleader=0&maintain=1"; #endif strOpen += " target=_blank>"; strOpen += m_pRecordList->strUserName; strOpen += "</a>"; m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 2)->setContentAlignment(AlignCenter); m_pRecordList->pstrUserName = new WText(strOpen, (WContainerWidget*)m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 2)); m_pRecordList->pLineEdit = new WLineEdit(m_pRecordList->strUserName,m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 2)); m_pRecordList->pLineEdit->hide(); m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 4)->setContentAlignment(AlignCenter); m_pRecordList->pTuop = new WImage("../Images/resource.gif",m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 4)); m_pRecordList->pTuop->setToolTip(strTuopTip); m_pRecordList->pTuop->setStyleClass("hand"); //绑定visio事件 std::string strJavascript; #ifdef Tuopu strJavascript = "window.open('../tuoplist/" + m_pRecordList->strTuop + "','newwindow')"; #else strJavascript = "window.open('../maintainlist/" + m_pRecordList->strTuop + "','newwindow')"; #endif connect(m_pRecordList->pTuop, SIGNAL(clicked()),strJavascript.c_str() ,WObject::JAVASCRIPT ); m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 6)->setContentAlignment(AlignCenter); m_pRecordList->pEdit = new WImage("/Images/edit.gif",m_pTopologyListTable->GeDataTable()->elementAt(m_pRecordList->nSort, 6)); m_pRecordList->pEdit->setToolTip(strEditTip); m_pRecordList->pEdit->setStyleClass("hand"); strIndex=m_pRecordList->strUserName.c_str(); m_userMapper.setMapping(m_pRecordList->pEdit, strIndex); connect(m_pRecordList->pEdit, SIGNAL(clicked()), &m_userMapper, SLOT(map())); connect(m_pRecordList->pLineEdit, SIGNAL(keyWentDown(int)), this, SLOT(EditReturn(int))); i++; //排序数据界面初始化 pSortTable->GeDataTable()->elementAt(m_pRecordList->nSort, 2)->setContentAlignment(AlignCenter); WText * pTmpText = new WText(m_pRecordList->strUserName, pSortTable->GeDataTable()->elementAt(m_pRecordList->nSort, 2)); char chItem[32] = {0}; sprintf(chItem, "%d", m_pRecordList->nSort); string strSort = chItem; pSortTable->GeDataTable()->elementAt(m_pRecordList->nSort, 4)->setContentAlignment(AlignCenter); WLineEdit * pTmpEdit = new WLineEdit(strSort, pSortTable->GeDataTable()->elementAt(m_pRecordList->nSort, 4)); //放到sv_table里去 SVTableCell ce; ce.setType(adText); ce.setValue(pTmpText); m_svSortList.WriteCell(m_pRecordList->strTuop, 0, ce); ce.setType(adLineEdit); ce.setValue(pTmpEdit); m_svSortList.WriteCell(m_pRecordList->strTuop, 1, ce); } m_pList.clear(); m_pVList.clear(); //列表为空 if(RecordList.size() <= 0) { m_pTopologyListTable->ShowNullTip(); } else { m_pTopologyListTable->HideNullTip(); } pSortTable->hide(); //隐藏按钮 pHideBtn = new WPushButton("hide button",this); if(pHideBtn) { pHideBtn->setToolTip("Hide Button"); connect(pHideBtn,SIGNAL(clicked()),this,SLOT(DelUser())); pHideBtn->hide(); } pTranslateBtn = new WPushButton("Translate",this); pExChangeBtn = new WPushButton("Refresh",this); //翻译 int bTrans = GetIniFileInt("translate", "translate", 0, "general.ini"); if(bTrans == 1) { this->pTranslateBtn->show(); connect(this->pTranslateBtn, SIGNAL(clicked()), this, SLOT(Translate())); this->pExChangeBtn->show(); connect(this->pExChangeBtn, SIGNAL(clicked()), this, SLOT(ExChange())); } else { this->pTranslateBtn->hide(); this->pExChangeBtn->hide(); } }