/***************************************************************************
 *   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.             *
 ***************************************************************************/ 

#ifndef EVACHATWINDOW_H
#define EVACHATWINDOW_H

#include "evachatuibase.h"
#include <qdatetime.h>
#include <qcolor.h>
#include <list>

class EvaImageResource;
class QQFriend;
class EvaSmileyPopup;
class QTextCodec;
class QKeyEvent;
class EvaFontSelecter;
class QPopupMenu;

class EvaChatWindow : public EvaChatUIBase
{
	Q_OBJECT
public:
	EvaChatWindow(const QQFriend * frd, QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
	~EvaChatWindow();
	static void setupImages(EvaImageResource *res);
	static void setQuickReplyMessages(const std::list<QString> &list);
	void setQuickReplyMenu();
	const int getBuddyQQ();
	static int myQQ;
	static QString myName;
	static bool isSentByEnter;
public slots:
	void graphicChanged();
	void slotReceivedMessage(int sender, bool isNormal, QString message, QDateTime time, const char size=9, 
			const bool u=false, const bool i=false, const bool b=false, 
			const char blue=0, const char green=0, const char red=0);
	void slotAddMessage(int sender, QString sNick, int receiver, QString rNick, bool isNormal, QString message, 
			QDateTime time, const char size=9, 
			const bool u=false, const bool i=false, const bool b=false, 
			const char blue=0, const char green=0, const char red=0);
	void slotSendResult(bool ok);
	void slotBuddyQQShowReady(const int id);
	void slotMyQQShowReady();
signals:
	void requestDetails(const int );
	void sendMessage(const int , const bool, QString &, const char , 
			const bool, const bool , const bool , 
			const char , const char , const char );
	void requestHistory(const int );
	void requestBuddyQQShow(const int);
	void requestMyQQShow();
private:
	void initObjects();
	void initInformation();
	void initConnection();

	
	void displaySendingMessage();
	
	EvaSmileyPopup *smileyPopup;
	static EvaImageResource *images;
// 	static QString htmlHeader;
// 	static QString htmlTail;
	
	static std::list<QString> quickList;
	
	EvaFontSelecter *fontSelecter;
	QPopupMenu *sendKey;
	QPopupMenu *quickMenu;
	
	QQFriend *buddy;
	QTextCodec *codec;
	
	QColor fontColor;
	int fontSize;
	QDateTime sendtime;
	
private slots:
	void slotSmileySelected(Q_UINT8);
// 	void slotMailClick(const QString &, const QString &);
// 	void slotURLClick(const QString &);
	
	void slotTbBuddyClick();
	
	void slotSmileyClick();
	void slotFontClick();
	void slotQuickReplyClick();
	void slotQuickReplyActivated(int id);
	
	void slotHistoryClick();
	void slotSendKeyClick();
	void slotSend();
	
	void slotTbShowBuddyClick();
	void slotTbShowMeClick();
	
	void slotInputKeyPress(QKeyEvent *e);
	
	void slotFontChanged(QColor, int);
	
	void setEnterSend();
	void setCtrlEnterSend();
	void slotPbCloseClick();
};

#endif
