📄 evasearchwindow.cpp
字号:
i18n("Eva - Search/Add")); return; } emit requestUserInfo(m_SelectedBasicUser.getQQ()); }void EvaSearchWindow::slotBasicResultTableDBClicked(int row){ slotBasicUserSelected(row); slotTbBSDetailsClicked();}void EvaSearchWindow::processAdvancedSearch(const bool online, const bool cam, const int province, const int city, const int age, const int gender){ pbSearch->setText(i18n("Add Buddy")); pbLastStep->setHidden(false); wsAdvancedSearch->raiseWidget(1); tbASPrev->setEnabled(false); tbASNext->setEnabled(false); tbASDetails->setEnabled(false); tbASAll->setEnabled(false); lblASResultTip->setText(i18n("Eva is searching users for you...")); m_ACurrentPage = 0; m_ShowAllAdvancedUsers = false; m_AdvancedUserPages.clear();//empty it, because there is always re-search m_SelectedAdvancedUser.setQQ(0); tbASResult->setNumRows(0); //clear the result table for(int row=0; row<tbASResult->numRows(); row++){ for(int col=0; col<tbASResult->numCols(); col++){ tbASResult->clearCell(row, col); } } printf("AdvancedSearch sig send\n"); emit requestAdvancedSearch(0, online, cam, province, city, age, gender);//always send page 1 request, so the page num is 0}void EvaSearchWindow::slotAdvancedSearchReady(const int page, const bool finished, const std::list<AdvancedUser> list){ lblASResultTip->setText(i18n("the following users are found for you by Eva.")); std::map<int, std::list<AdvancedUser> >::iterator iter = m_AdvancedUserPages.find(m_ACurrentPage); if( iter != m_AdvancedUserPages.end()) return ; m_ASearchFinished = finished; if(!m_ASearchFinished){ m_ACurrentPage = page; m_AdvancedUserPages[m_ACurrentPage] = list; } else m_ACurrentPage--; displayAdvancedUsers();}void EvaSearchWindow::displayAdvancedUsers(){ //clear the advanced search result table for(int row=0; row<tbASResult->numRows(); row++){ for(int col=0; col<tbBSResult->numCols(); col++){ tbASResult->clearCell(row, col); } } tbASResult->setNumRows(0); int start=0, end=1; if(m_ShowAllAdvancedUsers){ end = m_AdvancedUserPages.size(); }else{ start = m_ACurrentPage; end = start+1; } std::list<AdvancedUser>::iterator iter; std::list< CityListElement> city; std::list< CityListElement >::iterator cityIter; QTextCodec *codec = QTextCodec::codecForName("GB18030"); for(int i=start; i<end; i++){ for(iter = m_AdvancedUserPages[i].begin(); iter!=m_AdvancedUserPages[i].end(); ++iter){ tbASResult->setNumRows(tbASResult->numRows()+1); QImage img = images->getFace(images->getFaceFileIndex(iter->getFace()), iter->isOnline())->convertToImage(); tbASResult->setPixmap(tbASResult->numRows()-1, 0, QPixmap(img.smoothScale(16,16))); tbASResult->setText(tbASResult->numRows()-1, 0, QString::number(iter->getQQ())); tbASResult->setText(tbASResult->numRows()-1, 1,codec->toUnicode(iter->getNick().c_str())); tbASResult->setText(tbASResult->numRows()-1, 2,cbASSex->text(iter->getGenderIndex())); tbASResult->setText(tbASResult->numRows()-1, 3,QString::number(iter->getAge())); tbASResult->setText(tbASResult->numRows()-1, 4,cbASProvince->text(iter->getProvinceIndex())); //if use selected unlimited item, then the city name can not selected in the combox, because //the combox has no items yet, so I decided that all the city name is search in cityData if(cityData != NULL){ city = cityData->getCityList(iter->getProvinceIndex()); for(cityIter=city.begin(); cityIter!=city.end(); cityIter++){ if(iter->getCityIndex() == cityIter->city){ tbASResult->setText(tbASResult->numRows()-1,5,cityIter->name); break; } } } tbASResult->setText(tbASResult->numRows()-1, 6,iter->isOnline()?i18n("on"):i18n("off")); } } tbASPrev->setEnabled(m_ACurrentPage==1?false:true); tbASNext->setEnabled(m_ACurrentPage==10?false:true);//advanced search can only search 10 pages tbASDetails->setEnabled(true); tbASAll->setEnabled(true); lblASResultPage->setText(QString(i18n("Current page %1 ")).arg(m_ACurrentPage)); }void EvaSearchWindow::slotAdvancedUserSelected(int row){ int start = 0, end = 1 ,count = 0; if(m_ShowAllAdvancedUsers){ end = m_AdvancedUserPages.size(); }else{ start = m_ACurrentPage; end = start+1; } std::list<AdvancedUser>::iterator iter; for(int i=start; i<end; i++){ for(iter = m_AdvancedUserPages[i].begin(); iter!=m_AdvancedUserPages[i].end(); ++iter){ if(count == row){ m_SelectedAdvancedUser = *iter; return; }else count++; } } }void EvaSearchWindow::slotTbASDetailsClicked(){ //if user click the "details" button without any selected item, then show the message box if(tbASResult->numRows()!=0 && m_SelectedAdvancedUser.getQQ() == 0){ KMessageBox::messageBox((QWidget *) 0,KMessageBox::Information, i18n("Please select a user."), i18n("Eva - Search/Add")); return; } //if(m_SelectedAdvancedUser.getQQ()==-1) return; emit requestUserInfo(m_SelectedAdvancedUser.getQQ()); }void EvaSearchWindow::slotAdvancedResultTableDBClicked(int row){ slotAdvancedUserSelected(row); slotTbASDetailsClicked();}void EvaSearchWindow::slotCbASProvinceActive(int index){ loadCityList(index); cbASCity->setCurrentItem(0);}void EvaSearchWindow::slotTbASNextClicked(){ m_ACurrentPage++; m_ShowAllAdvancedUsers = false; int pageNo = m_ACurrentPage-1;//the request page num of advanced search is start by 0, but the response page num is start by 1 if(m_ACurrentPage>m_AdvancedUserPages.size()){ tbASNext->setEnabled(false); tbASPrev->setEnabled(false); tbASDetails->setEnabled(false); tbASAll->setEnabled(false); lblASResultTip->setText(i18n("Eva is searching users for you...")); emit requestAdvancedSearch(pageNo, m_OnlineUser, m_HasCam, m_ProvinceIndex, m_CityIndex, m_AgeIndex, m_GenderIndex); }else{ displayAdvancedUsers(); }}void EvaSearchWindow::slotTbASPrevClicked(){ m_ACurrentPage--; m_ShowAllAdvancedUsers = false; displayAdvancedUsers();}void EvaSearchWindow::slotTbASAllClicked(){ m_ShowAllAdvancedUsers = true; displayAdvancedUsers();}void EvaSearchWindow::processQunSearch(const QString &qunNum){ printf("qun search clicked\n"); if(qunNum.isEmpty()){ KMessageBox::messageBox((QWidget *) 0,KMessageBox::Information, i18n("Qun Num can not be empty."), i18n("Eva - Search/Add")); leQunNum->setFocus(); return; } bool ok; int extQunNum = qunNum.toInt(&ok); if(!ok){ KMessageBox::messageBox((QWidget *) 0,KMessageBox::Information, i18n("Qun Num is incorrect."), i18n("Eva - Search/Add")); leQunNum->setFocus(); return; } m_SelectedQun.setQunID(0); pbSearch->setText(i18n("Join Qun")); pbLastStep->setHidden(false); wsQunSearch->raiseWidget(1); tbQSPrev->setEnabled(false); tbQSNext->setEnabled(false); tbQSDetails->setEnabled(false); tbQSAll->setEnabled(false); lblQSResultTip->setText(i18n("Eva is searching Qun for you...")); emit requestQunSearch(extQunNum);}void EvaSearchWindow::slotQunSearchReady(const std::list<QunInfo> list, QString /*error*/){ //clear qun search result table for(int row=0; row<tbQSResult->numRows(); row++){ for(int col=0; col<tbQSResult->numCols(); col++){ tbQSResult->clearCell(row, col); } } tbQSResult->setNumRows(0); std::list<QunInfo>::iterator iter; QTextCodec *codec = QTextCodec::codecForName("GB18030"); qunList = list; if(list.size()){ for(iter = qunList.begin(); iter!=qunList.end(); ++iter){ tbQSResult->setNumRows(tbQSResult->numRows()+1); QImage img = images->getIcon("QUN")->convertToImage(); tbQSResult->setPixmap(tbQSResult->numRows()-1, 0, QPixmap(img.smoothScale(16,16))); tbQSResult->setText(tbQSResult->numRows()-1, 0, QString::number(iter->getExtID())); tbQSResult->setText(tbQSResult->numRows()-1, 1,codec->toUnicode(iter->getName().c_str())); tbQSResult->setText(tbQSResult->numRows()-1, 2,QString::number(iter->getCreator())); } } tbQSDetails->setEnabled(true); lblQSResultPage->setText(QString(i18n("Current page 1 "))); lblQSResultTip->setText(i18n("the following Qun are found for you by Eva."));}void EvaSearchWindow::slotTopListChanged(int index){ std::list< QunCategoryElement > second = categoryData->getSubList(topIndexCodeMap[index]); cbCategory2->clear(); if(!second.size()){ cbCategory2->setEnabled(false); return; }else cbCategory2->setEnabled(true); std::list< QunCategoryElement >::iterator iter; int sIndex = 0; cbCategory2->insertItem(""); secondIndexCodeMap.clear(); for(iter=second.begin(); iter!=second.end(); ++iter){ cbCategory2->insertItem(iter->name); secondIndexCodeMap[++sIndex] = iter->code; }}void EvaSearchWindow::slotSecondListChanged(int index){ std::list< QunCategoryElement > third = categoryData->getSubList(secondIndexCodeMap[index]); cbCategory3->clear(); if(!third.size()){ cbCategory3->setEnabled(false); return; }else cbCategory3->setEnabled(true); std::list< QunCategoryElement >::iterator iter; int tIndex = 0; cbCategory3->insertItem(""); thirdIndexCodeMap.clear(); for(iter=third.begin(); iter!=third.end(); ++iter){ cbCategory3->insertItem(iter->name); thirdIndexCodeMap[++tIndex] = iter->code; } }const unsigned short EvaSearchWindow::getCategoryCode(){ unsigned short code = 12; // 12 is "tech union", we set it as default if(cbCategory3->isEnabled() && cbCategory3->currentItem()) code = thirdIndexCodeMap[cbCategory3->currentItem()]; else if(cbCategory2->isEnabled() && cbCategory2->currentItem()) code = secondIndexCodeMap[cbCategory2->currentItem()]; else if(cbCategory1->currentItem()) code = topIndexCodeMap[cbCategory1->currentItem()]; return code;}void EvaSearchWindow::slotQunSelected(int row){ int count = 0; std::list<QunInfo>::iterator iter; for(iter = qunList.begin(); iter!=qunList.end(); ++iter){ if(count == row){ m_SelectedQun = *iter; return; }else count++; } }void EvaSearchWindow::slotQunResultTableDBClicked(int row){ slotQunSelected(row); slotTbQSDetailsClicked();}void EvaSearchWindow::slotTbQSDetailsClicked(){ //if user click the "details" button without any selected item, then show the message box if(tbBSResult->numRows()!=0 && m_SelectedQun.getQunID() == 0){ KMessageBox::messageBox((QWidget *) 0,KMessageBox::Information, i18n("Please select a Qun."), i18n("Eva - Search/Add")); return; } Qun *qun = new Qun(m_SelectedQun.getQunID()); qun->setDetails( m_SelectedQun ); QunDetailsWindow *win = new QunDetailsWindow(qun, false); delete qun; QRect scr = KApplication::desktop()->screenGeometry(); win->move(scr.center() - win->rect().center()); win->show();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -