/***************************************************************************
 *   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 EVAMAINWINDOW_H
#define EVAMAINWINDOW_H

#include "evamainuibase.h"
#include <qpoint.h>
#include <qsize.h>
#include <list>
#include <string>

class QListViewItem;
class QPopupMenu;
class EvaMainWindow : public EvaMainUIBase
{
	Q_OBJECT
public:
	EvaMainWindow(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); // | WDestructiveClose
	~EvaMainWindow();
	
	void setMainInfo(const int id, const QString &nick, QPixmap *p);
	const int getQQ() const { return qqNum; }
	void setStatusPixmaps(QPixmap *online, QPixmap *offline, QPixmap *leave, QPixmap *invisble);
	void setSystemMenu( QPopupMenu *sys);
	void setStatusMenu( QPopupMenu *status);
	void setBasicPixmaps(QPixmap *sys, QPixmap *open, QPixmap *close, QPixmap *na, QPixmap *msg);
	void setGroupMenu(QPixmap *rename, QPixmap *newGroup, QPixmap *deleleGroup, 
			QPixmap *onlineBuddies, QPixmap *allBuddies);
	void setBuddyMenu(QPixmap *chat, QPixmap * details, QPixmap *msgHistory, QPixmap *deleteBuddy);

	void changeGroupTo(const int id, const int index);	
	void addGroup(QString &name, const int index);	
	void addBuddy(QString &nick, const int id, const int index, QPixmap *on, QPixmap *off);
	
	void refreshFace(const QSize &size);
	void setFaceSize(const QSize &size);
	void clearList();
public slots:
	void changeToOnline(int id);
	void changeToOffline(int id);
	void changeToLeave(int id);
	void changeToInvisible(int id);
	void newMessage(int id);
	void gotMessage(int id);
	void slotShowOnlineBuddies();
	void slotShowAllBuddies();
	
	void deleteBuddy(int id);
	
	void online();
	void offline();
	void leave();
	void invisible();
signals:
	void groupDeleted(const int);  // paremeter is the group index
	void groupAdded(QString, int); // group name & index
	void groupRenamed(QString, int); // group name & index
	void deleteMeFrom(int);
	void groupChanged(int,int);
	void requestAddBuddy(int);
	
	void requestChat(const int);
	void requestDetails(const int);
	void requestHistory(const int);
	void requestDelete(const int);  // the deleting qq number 
	void requestSearch();
	void requestSystemMessages();
	
private:
	int qqNum;
	QPopupMenu *groupMenu; 
	QPopupMenu *buddyMenu;
	QPopupMenu *sysMenu;
	QPopupMenu *statusMenu;
	
	QPixmap *pixOnline;
	QPixmap *pixOffline;
	QPixmap *pixLeave;
	QPixmap *pixInvisible;
private slots:
	void slotTbMyFace();
	void slotContextMenu(QListViewItem *, const QPoint & , int);

	void slotItemRenamed(QListViewItem *, int);
		
	void slotRenameGroup();
	void slotNewGroup();
	void slotDelGroup();
	
	void slotIMChat();
	void slotDetails();
	void slotHistory();
	void slotDelBuddy();
	
	void slotBuddyDoubleClick(QListViewItem *, const QPoint & , int);
	
	void slotSearch();
	void slotSystemMessages();
};

#endif
