/***************************************************************************
                          dcchat.h  -  description
                             -------------------
    begin                : Don Mär 28 2002
    copyright            : (C) 2002 by Mathias Küster
    email                : mathen@users.berlios.de
 ***************************************************************************/

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

#ifndef DCCHAT_H
#define DCCHAT_H

/**
  *@author Mathias Küster
  */

#include <QWidget>
#include <QEvent>
#include <QList>
#include <QStringList>
#include <QShowEvent>
#include <QTextEdit>
#include <QMouseEvent>
#include <QCloseEvent>

/* for enum eSecureState */
#include <dclib/core/types.h>

#include "DCDialogChat.h"

class DCQTextEdit;
class DCClient;
class QLabel;
class QStatusBar;
class DCShellCommandRunner;
class CMessagePrivateChat;


class DCChat : public QWidget, public Ui::DCDialogChat {
Q_OBJECT

public: 
	/** construtor */
	DCChat( QWidget * parent, DCClient * client, bool bprivate = true );
	/** destructor */
	virtual ~DCChat();

	/** */
	void InitDocument();
	/** */
	void SetNick( QString nick, QString hubname );
	/** */
	QString GetNick() { return m_sNick; };
	/** */
	void AddMessage( QString nick, QString message, bool bremote = true, bool forward = false );
	/** */
	void AddMessage( CMessagePrivateChat * msg, bool bremote = true, bool forward = false );
	/** show statusmessage, if show true the settings are ignored */
	void AddStatus( QString message, bool show = false );
	/** */
	void SetCrypt( eSecureState e );

	/** */
	bool close();
	/** */
	void addStringToChat(QString nick);
	/** Made public for auto responder */
	void SendChat( QString message = "" );
        /** */
        void ClearChat();
        /** */
        void ZoomIn();
        /** */
        void ZoomOut();
        /** */
        void SetChatOff();

protected:
	/** event filter */
	virtual bool eventFilter( QObject * object, QEvent * event );
	/** for translation event */
	virtual void customEvent( QEvent * event );
        /** */
        virtual void showEvent( QShowEvent *e );
        /** */
        virtual void closeEvent( QCloseEvent *e);

private:
	/** */
	bool CheckForCommand();
	/** */
	bool CheckForData( QString message );
	/** */
	void NickCompletion();
	/** */
	void QT3TranslationSync();

	/** */
	QString GetTimeStamp();
	/** */
	void AddOutput( QString message );

	/** */
	void AddHistory( QString message );

	/** */
	DCQTextEdit * m_pTextEdit_CHATOUTPUT;
	/** */
	QString m_sLanguage;
	/** */
	bool m_bPrivateChat;
	/** */
	bool m_bSendAway;
	/** */
	DCClient * m_pClient;
	/** */
	QString m_sNick;
	/** */
	QStatusBar * m_pStatusBar;
	/** */
	QLabel * m_pStatusCrypt;
	/** */
	eSecureState m_eSecureState;
	/** */
	QStringList m_lHistory;
	/** last line */
	QString m_sHistoryTempString;
	/** cursor pos */
	/* int m_nHistoryTempPara; */
	/** cursor pos */
	int m_nHistoryTempIndex;
	/** */
	int m_nCurrentHistoryIndex;
	/** */
	QString m_sTimeStamp;
	/** */
	int m_nTabStart;
	/** */
	int m_nTabEnd;
	/** */
	int m_nTabPressed;
	/** */
	QString m_sTabSaved;
	/** */
	QString m_sTabNick;
	/** */
	QWidget * m_pParent;
	/** */
	QString m_sLabel;
	/** List of running shell command threads */
	QList<DCShellCommandRunner*> * m_pShellRunners;
        /** */
        bool bChatOff;
        /** */
        bool bRawChat;
	
public slots:
	/** */
	void slotRightButtonClickedChatOutput( const QPoint& );

private slots:
	/** */
	void slotClickedChatOutput();
	/** */
	void slotDoubleClickedChatOutput();
	/** */
	void slotTextChangedChatInput();
	/** */
	void slotSendChat();
	/** */
	void slotShellCommandFinished( bool ok, QString output );
	/** */
	void slotLoadEmoticons();
	/** */
	void slotBGColorChanged();
	/** */
	void slotFGColorChanged();
        /** */
        void slotSmyle();
};

#endif
