⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evasearchwindow.cpp

📁 linux下的eva源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************** *   Copyright (C) 2005 by yunfan,casper                                  * *   yunfan_zg@163.com                                                     * *   tlmcasper@163.com                                                     * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#include "evasearchwindow.h"#include "evaresource.h"#include <stdlib.h>#include <qlabel.h>#include <qwidgetstack.h>#include <qpushbutton.h>#include <qradiobutton.h>#include <qlineedit.h>#include <qtable.h>#include <qcheckbox.h>#include <qtoolbutton.h>#include <qgroupbox.h>#include <qbuttongroup.h>#include <qimage.h>#include <qtextcodec.h>#include <qtabwidget.h>#include <qcombobox.h>#include <qstringlist.h>#include <qrect.h>#include <kmessagebox.h>#include <krun.h>#include <klocale.h>#include <kglobal.h>#include <kstandarddirs.h>#include <kapp.h>#include "../evamain.h"#include "../evaaddingmanager.h"#include "evaqunlist.h"#include "qundetailswindow.h"CityList::CityList( ){	isOK = loadList();}std::list< CityListElement > CityList::getCityList( unsigned short province ){	std::list< CityListElement > results;	std::map<unsigned short, std::list< CityListElement> >::iterator iter;	for(iter=list.begin(); iter!=list.end(); ++iter)		if(province == iter->first){			results = iter->second;			break;		}		return results;}const bool CityList::loadList( ){	list.clear();	QString filePath = KGlobal::dirs()->findResource("data", QString::fromLatin1("eva/citylist"));	QFile file(filePath);    	if(!file.open(IO_ReadOnly)){		return false;	}		QTextStream stream(&file);	stream.setCodec(QTextCodec::codecForName("GB18030"));	QString line;	QStringList lineList;		std::list<CityListElement> tmpList;	unsigned int tmpProv;	unsigned int province = 1;	while(!stream.atEnd()){		line = stream.readLine().stripWhiteSpace();					lineList = QStringList::split(",", line);						if(lineList.size() != 3)			continue;				bool ok;		CityListElement element;		tmpProv = (unsigned short)(lineList[0].stripWhiteSpace().toInt(&ok));		if(!ok) continue;				if( tmpProv != province){				list[province++] = tmpList;			tmpList.clear();		}				element.city = (unsigned short)(lineList[1].stripWhiteSpace().toInt(&ok));		if(!ok) continue;		element.name = lineList[2].stripWhiteSpace();		tmpList.push_back(element);	//store the city informations to list	}	list[province] = tmpList;	file.close();	return true; }/*----------------------------------------------------------*/EvaSearchWindow::EvaSearchWindow(EvaImageResource *res, const int onlineUsers, QWidget* parent, 		const char* name, WFlags fl)	: EvaSearchUIBase(parent,name, fl),	m_BSearchType(B_CUSTOM),	m_BCurrentPage(0),	m_ShowAllBasicUsers(false),	m_ACurrentPage(0),	m_ShowAllAdvancedUsers(false),	m_OnlineUser(true), m_HasCam(false), m_ProvinceIndex(0), m_CityIndex(0), m_AgeIndex(0), m_GenderIndex(0),	m_QSearchType(Q_CATEGORY){	if(onlineUsers>0)		lblOnlineNum->setText(QString::number(onlineUsers));	else		lblOnlineNum->setText(i18n("Unknown"));		images = res;	lblLogo->setPixmap(*images->getIcon("SEARCH_LOGO"));	adjustInterface();	//initialise city info	cityData = new CityList();	if(!cityData->isLoaded()){		delete cityData;		cityData = NULL;	}	//initialise qun category list	loadCategoryList();	QObject::connect(rbSearchOnline, SIGNAL(clicked()), this, SLOT(slotRbSearchOnlineClicked()));	QObject::connect(rbCustomSearch, SIGNAL(clicked()), this, SLOT(slotRbCustomSearchClicked()));	QObject::connect(rbAccuratelySearch, SIGNAL(clicked()), this, SLOT(slotRbAccuratelySearchClicked()));		QObject::connect(rbSearchByCategory, SIGNAL(clicked()), this, SLOT(slotRbSearchByCategoryClicked()));	QObject::connect(rbSearchAlumni, SIGNAL(clicked()), this, SLOT(slotRbSearchAlumniClicked()));	QObject::connect(rbSearchFrdCenter, SIGNAL(clicked()), this, SLOT(slotRbSearchFrdCenterClicked()));		QObject::connect(pbSearch, SIGNAL(clicked()), this, SLOT(slotPbSearchClicked()));	QObject::connect(pbClose, SIGNAL(clicked()), this, SLOT(close()));	QObject::connect(pbLastStep, SIGNAL(clicked()), this, SLOT(slotPbLastStepClicked()));	QObject::connect(twSearchMain, SIGNAL(currentChanged(QWidget*)), this, SLOT( slotCurrentChanged(QWidget*)));		QObject::connect(tbBSNext, SIGNAL( clicked() ), this, SLOT( slotTbBSNextClicked()));	QObject::connect(tbBSPrev, SIGNAL( clicked() ), this, SLOT( slotTbBSPrevClicked()));	QObject::connect(tbBSDetails, SIGNAL( clicked() ), this, SLOT( slotTbBSDetailsClicked()));	QObject::connect(tbBSAll, SIGNAL( clicked() ), this, SLOT( slotTbBSAllClicked()));		QObject::connect(tbBSResult, SIGNAL(clicked(int,int,int,const QPoint&)), this, SLOT(slotBasicUserSelected(int)));	QObject::connect(tbBSResult, SIGNAL(doubleClicked(int,int,int,const QPoint&)), this, SLOT(slotBasicResultTableDBClicked(int)));		QObject::connect(tbASResult, SIGNAL(clicked(int,int,int,const QPoint&)), this,SLOT(slotAdvancedUserSelected(int)));	QObject::connect(tbASResult, SIGNAL(doubleClicked(int,int,int,const QPoint&)), this, SLOT(slotAdvancedResultTableDBClicked(int)));		QObject::connect(cbASProvince, SIGNAL(activated(int)), this, SLOT(slotCbASProvinceActive(int)));		QObject::connect(tbASNext, SIGNAL( clicked() ), this, SLOT( slotTbASNextClicked()));	QObject::connect(tbASPrev, SIGNAL( clicked() ), this, SLOT( slotTbASPrevClicked()));	QObject::connect(tbASAll, SIGNAL( clicked() ), this, SLOT( slotTbASAllClicked()));	QObject::connect(tbASDetails, SIGNAL( clicked() ), this, SLOT( slotTbASDetailsClicked()));		QObject::connect(cbCategory1,SIGNAL(activated(int)), SLOT(slotTopListChanged(int)));	QObject::connect(cbCategory2,SIGNAL(activated(int)), SLOT(slotSecondListChanged(int)));		QObject::connect(tbQSResult, SIGNAL(clicked(int,int,int,const QPoint&)), this, SLOT(slotQunSelected(int)));	QObject::connect(tbQSResult, SIGNAL(doubleClicked(int,int,int,const QPoint&)), this, SLOT(slotQunResultTableDBClicked(int)));	QObject::connect(tbQSDetails, SIGNAL( clicked() ), this, SLOT( slotTbQSDetailsClicked()));}EvaSearchWindow::~EvaSearchWindow(){	if(cityData)		delete cityData;	if(categoryData)		delete categoryData;	}void EvaSearchWindow::adjustInterface(){	pbLastStep->setHidden(true);	rbCustomSearch->setChecked(true);	rbSearchByCategory->setChecked(true);	chbOnlineUsers->setChecked(true);		tbBSResult->setLeftMargin(0);	tbBSResult->setColumnWidth(0,100);//width of qq num column	tbBSResult->setColumnWidth(1,100);//Nick Name	tbBSResult->setColumnWidth(2,120);//From 		tbASResult->setLeftMargin(0);	tbASResult->setColumnWidth(0,90);//qq num	tbASResult->setColumnWidth(1,75);	tbASResult->setColumnWidth(2,50);	tbASResult->setColumnWidth(3,30);	tbASResult->setColumnWidth(4,60);	tbASResult->setColumnWidth(5,50);	tbASResult->setColumnWidth(6,40);	tbQSResult->setLeftMargin(0);			//把省份填充进省份的下拉框中	cbASProvince->insertItem(i18n("any"));	cbASProvince->insertItem(i18n("oversea"));	cbASProvince->insertItem( i18n( "BeiJing" ) );	cbASProvince->insertItem( i18n( "ShangHai" ) );	cbASProvince->insertItem( i18n("TianJing" ) );	cbASProvince->insertItem( i18n("ChongQing" ) );	cbASProvince->insertItem( i18n("HeBei" ) );	cbASProvince->insertItem( i18n("ShanXi" ) );	cbASProvince->insertItem( i18n("NeiMengGu" ) );	cbASProvince->insertItem( i18n("LiaoNing" ) );	cbASProvince->insertItem( i18n("JiLin" ) );	cbASProvince->insertItem( i18n("HeiLongJiang" ) );	cbASProvince->insertItem( i18n("JiangSu" ) );	cbASProvince->insertItem( i18n("ZheJiang" ) );	cbASProvince->insertItem( i18n("AnHui" ) );	cbASProvince->insertItem( i18n("FuJian" ) );	cbASProvince->insertItem( i18n("JiangXi" ) );	cbASProvince->insertItem( i18n("ShanDong" ) );	cbASProvince->insertItem( i18n("HeNan" ) );	cbASProvince->insertItem( i18n("HuBei" ) );	cbASProvince->insertItem( i18n("HuNan" ) );	cbASProvince->insertItem( i18n("GuangDong" ) );	cbASProvince->insertItem( i18n("GuangXi" ) );	cbASProvince->insertItem( i18n("HaiNan" ) );	cbASProvince->insertItem( i18n("SiChuan" ) );	cbASProvince->insertItem( i18n("GuiZhou" ) );	cbASProvince->insertItem( i18n("YunNan" ) );	cbASProvince->insertItem( i18n("XiZang" ) );	cbASProvince->insertItem( i18n("ShaanXi" ) );	cbASProvince->insertItem( i18n("GanSu" ) );	cbASProvince->insertItem( i18n("NingXia" ) );	cbASProvince->insertItem( i18n("QingHai" ) );	cbASProvince->insertItem( i18n("XinJiang" ) );	cbASProvince->insertItem( i18n("Hong Kong" ) );	cbASProvince->insertItem( i18n("Macao" ) );	cbASProvince->insertItem( i18n("TaiWan" ) );		cbASCity->insertItem(i18n("any"));	}void EvaSearchWindow::loadCityList(unsigned int province){	if(cityData != NULL){		std::list< CityListElement > city = cityData->getCityList(province);		cbASCity->clear();		std::list< CityListElement >::iterator iter;		cbASCity->insertItem(i18n("any"));		for(iter=city.begin(); iter!=city.end(); ++iter){			cbASCity->insertItem(iter->name);		}	}}void EvaSearchWindow::loadCategoryList(){	categoryData = new QunCategory();	if(!categoryData->isLoaded()){		delete categoryData;		categoryData = NULL;	}	std::list< QunCategoryElement > top = categoryData->getSubList(0);	cbCategory1->clear();	std::list< QunCategoryElement >::iterator iter;	int index = 0;	cbCategory1->insertItem("");	for(iter=top.begin(); iter!=top.end(); ++iter){		cbCategory1->insertItem(iter->name);		topIndexCodeMap[++index] = iter->code;	}	cbCategory2->setEnabled(false);	cbCategory3->setEnabled(false);	}void EvaSearchWindow::slotRbSearchOnlineClicked(){	wsBasicCondtion->raiseWidget(0);	m_BSearchType = B_ONLINE;		lblQQNum->setEnabled(false);	lblNickName->setEnabled(false);	//lblEmail->setEnabled(false);		leQQNum->setEnabled(false);	leNickName->setEnabled(false);	//leEmail->setEnabled(false);}void EvaSearchWindow::slotRbCustomSearchClicked(){	wsBasicCondtion->raiseWidget(0);	m_BSearchType = B_CUSTOM;		lblQQNum->setEnabled(true);	lblNickName->setEnabled(true);	//lblEmail->setEnabled(true);		leQQNum->setEnabled(true);	leNickName->setEnabled(true);	//leEmail->setEnabled(true);}void EvaSearchWindow::slotRbSearchFrdCenterClicked(){	wsBasicCondtion->raiseWidget(1);	m_BSearchType = B_FRDCENTER;}void EvaSearchWindow::slotRbSearchByCategoryClicked(){	wsQunCondition->raiseWidget(0);	m_QSearchType = Q_CATEGORY;}void EvaSearchWindow::slotRbSearchAlumniClicked(){	wsQunCondition->raiseWidget(1);	m_QSearchType = Q_ALUMNI;}void EvaSearchWindow::slotRbAccuratelySearchClicked(){	wsQunCondition->raiseWidget(2);	m_QSearchType = Q_ACCURATE;}void EvaSearchWindow::slotPbSearchClicked(){	QTextCodec *codec = QTextCodec::codecForName("GB18030");	//Index of TabWidget: 0-basic search, 1-advanced search, 2-qun search	switch(twSearchMain->currentPageIndex()){	case 0:		if(!strcmp(wsBasicSearch->visibleWidget()->name(),"wsBSPage")){ 			//we are now on the search parma page: click the button means search user.			switch(m_BSearchType){			case B_ONLINE:{					processBasicSearch(true,"", "", "");				}				break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -