📄 qundetailswindow.cpp
字号:
/*************************************************************************** * Copyright (C) 2005 by yunfan * * yunfan_zg@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 "qundetailswindow.h"#include <qlineedit.h>#include <qtextedit.h>#include <qcombobox.h>#include <qpushbutton.h>#include <qradiobutton.h>//#include <qiconset.h>#include <qpixmap.h>#include <qlabel.h>#include <qtabwidget.h>#include <qbuttongroup.h>#include <qtable.h>#include <qimage.h>#include <kmessagebox.h>#include <qtextcodec.h>#include <qevent.h>#include <qpoint.h>#include <qtoolbutton.h>#include <qmessagebox.h>#include "evaqunlist.h"#include "../evamain.h"#include "evaresource.h"#include "evauser.h"#include "evaqtutil.h"#include "evaqunmemberpicker.h"#include "quncategorypicker.h"#include <klocale.h>// QunDetailsWindow::QunDetailsWindow(QWidget* parent, const char* name, WFlags fl)// : QunDetailsUI(parent,name,fl), m_CardId(0)// {// codec = QTextCodec::codecForName("GB18030");// initTable( );// slotLoadMembers();// }QunDetailsWindow::~QunDetailsWindow(){ delete mQun;}QunDetailsWindow::QunDetailsWindow( Qun * qun, const bool isInList, QWidget * parent, const char * name, WFlags fl ) : QunDetailsUI(parent,name,fl), mQun(qun), m_IsInList(isInList), m_CardId(0){ mQun = new Qun(*qun); codec = QTextCodec::codecForName("GB18030"); initInformation(); if(isInList){ initTable( ); slotLoadMembers(); picker = new EvaQunMemberPicker(0, "qunpicker", WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop | WStyle_Tool| WX11BypassWM, mQun); picker->resize(QSize(240,frameGeometry().height())); QObject::connect(picker, SIGNAL(memberClicked(const unsigned int, const bool)), SLOT(slotPickerMemberClicked(const unsigned int, const bool))); QObject::connect(this, SIGNAL(removeMember(const int)), picker, SLOT(slotSetMemberOff(const int))); QObject::connect(pbUpdate, SIGNAL(clicked()), SLOT(slotUpdateClicked())); } else { picker = 0; setWidgetEnabledForInformation(false); tabWMain->setTabEnabled( tabMember, false); tabWMain->setTabEnabled( tabSetting, false); tabWMain->setTabEnabled( TabCard, false); pbUpdate->setEnabled(false); } QObject::connect(pbClose, SIGNAL(clicked()), SLOT(slotClose()));}void QunDetailsWindow::initInformation( ){ if(!mQun) return; QunInfo info = mQun->getDetails(); QString title, name; if(info.getExtID() == 0){ name = QString::number(mQun->getQunID()); }else name = codec->toUnicode(mQun->getDetails().getName().c_str()); title = i18n("Qun") + QString(" - %1").arg(name); setCaption(title); //QIconSet face; setIcon(*(EvaMain::images->getIcon("QUN"))); lblLogo->setPixmap(*(EvaMain::images->getIcon("QUN_LOGO"))); lblQunFace->setPixmap(*(EvaMain::images->getIcon("QUN"))); if(info.getExtID() == 0){ leQunName->setText( name); return; } QString notice = codec->toUnicode(mQun->getDetails().getNotice().c_str()); QString description = codec->toUnicode(mQun->getDetails().getDescription().c_str()); if(mQun->getDetails().getCreator() == EvaMain::user->getQQ() || (mQun->isAdmin(EvaMain::user->getQQ())) ){ leQunName->setEnabled(true); teNotice->setEnabled(true); teDescription->setEnabled(true); bgAuthen->setEnabled(true); tbCategory->setEnabled(true); QObject::connect(tbCategory, SIGNAL(clicked()), SLOT(slotCategoryClicked())); }else{ leQunName->setEnabled(false); teNotice->setEnabled(false); teDescription->setEnabled(false); bgAuthen->setEnabled(false); tbCategory->setEnabled(false); } leQunID->setText( QString::number(mQun->getDetails().getExtID())); leCreator->setText( QString::number(mQun->getDetails().getCreator())); leQunName->setText( name); category = mQun->getDetails().getCategory(); QunCategory qunCate; QString cateDescription = qunCate.getDescription(category); tbCategory->setText(cateDescription); teNotice->setText(notice); teDescription->setText(description); switch(mQun->getDetails().getAuthType()){ case QQ_QUN_NO_AUTH: rbNoAuthenNeed->setChecked(true); break; case QQ_QUN_NEED_AUTH: rbNeedAuthen->setChecked(true); break; case QQ_QUN_NO_ADD: rbRejectAnyone->setChecked(true); break; } switch(mQun->getMessageType()){ case Qun::Notify: rbRecord_Show->setChecked(true); break; case Qun::Popup: rbPopupWindow->setChecked(true); break; case Qun::Numbers: rbDisplayNumbers->setChecked(true); break; case Qun::RecordOnly: rbRecord_only->setChecked(true); break; case Qun::Reject: rbRejectMsgs->setChecked(true); break; default: rbRecord_Show->setChecked(true); } QString realName = codec->toUnicode(mQun->getCardName().c_str()); QString phone = codec->toUnicode(mQun->getCardPhone().c_str()); QString email = codec->toUnicode(mQun->getCardEmail().c_str()); QString memo = codec->toUnicode(mQun->getCardMemo().c_str()); leMyName->setText(realName); cbbMyGender->setCurrentItem(mQun->getCardGender()); leMyPhone->setText(phone); leMyEmail->setText(email); teMyMemo->setText(memo);}void QunDetailsWindow::slotUpdateClicked( ){ if(mQun->getDetails().getCreator() != EvaMain::user->getQQ() && // not creator !(mQun->isAdmin(EvaMain::user->getQQ())) && // not admin tabWMain->currentPageIndex() != 2 && // not message setting tabWMain->currentPageIndex() != 3){ // not modifying qun card pbUpdate->setEnabled(false); emit requestQunInfo(mQun->getQunID()); return; } switch(tabWMain->currentPageIndex()){ case 0: slotModifyInfo(); break; case 1: slotModifyMembers(); break; case 2: slotUpdateMessageSetting(); break; case 3: slotModifyQunCard(); break; }}void QunDetailsWindow::slotModifyInfo( ){ if(leQunName->text().stripWhiteSpace().isEmpty()){ QMessageBox::information(this, i18n("Eva Modify Qun Inforamtion"), i18n("Qun name cannot be empty.")); leQunName->setFocus(); return; } int id = mQun->getQunID(); unsigned char auth = 0x02; if(rbNoAuthenNeed->isChecked()) auth = 0x01; else if(rbNeedAuthen->isChecked()) auth = 0x02; else if(rbRejectAnyone->isChecked()) auth = 0x03; //unsigned short cate = mQun->getDetails().getCategory(); QString name = leQunName->text(); QString notice = teNotice->text(); QString description = teDescription->text(); setWidgetEnabledForInformation(false); pbUpdate->setEnabled(false); emit requestModifyQunInfo(id, auth, category, name, notice, description);}void QunDetailsWindow::setWidgetEnabledForInformation( bool enabled ){ leQunName->setEnabled(enabled); teNotice->setEnabled(enabled); teDescription->setEnabled(enabled); bgAuthen->setEnabled(enabled); tbCategory->setEnabled(enabled);}void QunDetailsWindow::slotModifyQunInfo(const unsigned int id, bool ok , QString msg){ if(id != mQun->getQunID()) return; setWidgetEnabledForInformation(true); emit requestQunInfo(mQun->getQunID()); QString title = i18n("Eva Modify Qun Inforamtion"); if(ok){ QMessageBox::information(this, title, i18n("Modify Qun information sucessfully.")); return; } else { QMessageBox::information(this, title, msg); }}void QunDetailsWindow::slotQunInfomationReady(const unsigned int id, const bool ok, QString msg){ if(!ok){ QMessageBox::information( this, i18n("Qun Details"), msg); return; } if(id != mQun->getQunID()) return; mQun = EvaMain::user->getQunList()->getQun(id); QString name = codec->toUnicode(mQun->getDetails().getName().c_str()); QString title = i18n("Qun") + QString(" - %1").arg(name); setCaption(title); QString notice = codec->toUnicode(mQun->getDetails().getNotice().c_str()); QString description = codec->toUnicode(mQun->getDetails().getDescription().c_str()); leQunID->setText( QString::number(mQun->getDetails().getExtID())); leCreator->setText( QString::number(mQun->getDetails().getCreator())); leQunName->setText( name); teNotice->setText(notice); teDescription->setText(description); switch(mQun->getDetails().getAuthType()){ case QQ_QUN_NO_AUTH: rbNoAuthenNeed->setChecked(true); break; case QQ_QUN_NEED_AUTH: rbNeedAuthen->setChecked(true); break; case QQ_QUN_NO_ADD: rbRejectAnyone->setChecked(true); break; } pbUpdate->setEnabled(true); slotLoadMembers();}void QunDetailsWindow::slotModifyQunCard( ){ if(m_CardId && m_CardId != EvaMain::user->getQQ()){ emit requestQunCard(mQun->getQunID(), m_CardId); return; } QString name = leMyName->text(); unsigned char gender = (unsigned char)(cbbMyGender->currentItem()); QString phone = leMyPhone->text(); QString email = leMyEmail->text(); QString memo = teMyMemo->text(); QString title = i18n("Modify Qun Card"); QString content = i18n("Your input is too long."); if(strlen(name.ascii()) > 255){ QMessageBox::information(this, title, content); leMyName->setFocus(); return; } if(strlen(phone.ascii()) > 255){ QMessageBox::information(this, title, content); leMyPhone->setFocus(); return; } if(strlen(email.ascii()) > 255){ QMessageBox::information(this, title, content); leMyEmail->setFocus(); return; } if(strlen(memo.ascii()) > 255){ QMessageBox::information(this, title, content); teMyMemo->setFocus(); return; } pbUpdate->setEnabled(false); emit requestModifyQunCard(mQun->getQunID(), EvaMain::user->getQQ(), name, gender, phone, email, memo);}void QunDetailsWindow::slotModifyQunCardReply( const unsigned int id, const bool ok, const unsigned int /*qqID*/, QString msg){ if(ok && id != mQun->getQunID()) return; pbUpdate->setEnabled(true); QString title = i18n("Modify Qun Card"); if(ok){ QMessageBox::information(this, title, i18n("Modify Qun Card sucessfully.")); QString name = leMyName->text(); unsigned char gender = (unsigned char)(cbbMyGender->currentItem()); QString phone = leMyPhone->text(); QString email = leMyEmail->text(); QString memo = teMyMemo->text(); std::string stdName = codec->fromUnicode(name).data(); std::string stdPhone = codec->fromUnicode(phone).data(); std::string stdEmail = codec->fromUnicode(email).data(); std::string stdMemo = codec->fromUnicode(memo).data(); EvaMain::user->getQunList()->setMyQunCardInfo(id, stdName, gender, stdPhone, stdEmail, stdMemo); return; } else { QMessageBox::information(0, title, msg); } }void QunDetailsWindow::slotLoadMembers( ){ for(int row=0; row<tblMembers->numRows(); row++){ for(int col=0; col<tblMembers->numCols(); col++){ tblMembers->clearCell(row, col); } } int i=0; std::list<FriendItem>::iterator iter; std::list<FriendItem> list = mQun->getMembers(); unsigned short face; unsigned int id; QString nick; tblMembers->setNumRows(list.size()); for(iter = list.begin(); iter!=list.end(); iter++){ face = iter->getFace(); id = iter->getQQ(); nick = EvaTextFilter::filter(codec->toUnicode(iter->getQunRealName().c_str())); if(nick.isEmpty()) nick = EvaTextFilter::filter(codec->toUnicode(iter->getNick().c_str())); QPixmap *typePic = NULL; if(iter->isAdmin()) typePic = EvaMain::images->getIcon("QUN_ADMIN"); if(iter->isShareHolder()) typePic = EvaMain::images->getIcon("QUN_SHAREHOLDER"); if(mQun->getDetails().getCreator() == id) typePic = EvaMain::images->getIcon("QUN_CREATOR"); if(typePic) tblMembers->setPixmap(i,0, *typePic); QPixmap *bmpFace = EvaMain::images->getFace(EvaMain::images->getFaceFileIndex(face)); if(bmpFace){ QImage img(bmpFace->convertToImage().smoothScale(16, 16)); tblMembers->setPixmap(i, 1, QPixmap(img)); } tblMembers->setText(i,1,QString::number(id)); tblMembers->setText(i,2,nick); tblMembers->setText(i,3, iter->isBoy()?i18n("Male"):i18n("Female")); i++; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -