Logo Search packages:      
Sourcecode: qchat version File versions  Download package


 *   Copyright (C) 2007 by Anistratov Oleg                                 *
 *   ower@users.sourceforge.net                                            *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation;                         *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   GNU General Public License for more details.                          *
 *                                                                         *

#include <QWidget>
#include <QString>
#include <QPushButton>
#include <QTextEdit>
#include <QUdpSocket>
#include <QHostInfo>
#include <QLineEdit>
#include <QHostAddress>
#include <QTabWidget>
#include <QSplitter>
#include <QCheckBox>
#include <QList>
#include <QTimer>
#include <QFile>
#include <QComboBox>
#include <QGridLayout>
#include <QStackedWidget>
#include <QTime>
#include <QEvent>

#include "globals.h"

class ChatWgt;
class MsgHistory;
class UsersList;
class UsersListWgt;
class StatusEditWgt;
class ChatTextWgt;
class InputTextWgt;
class Message;
class StatusEditWgt;
class UserWgt;
class UsersStatisticsWgt;
class UsersStatisticsModel;

struct Smile;
struct QC_DatagramHeader;

        @author Anistratov Oleg <ower@users.sourceforge.net>

00060 class ChannelWgt : public QWidget
    quint8          m_myStatus;
    quint8          m_oldStatus;

    QGridLayout*    mw_grid;
    QStackedWidget* mw_chatTextStack;
    ChatWgt*        m_parent;
    quint32         m_type; // 0 - common, 1 - private
    QHostAddress    m_destIp;
    QString         m_name;

    MsgHistory*     m_chatMsgs;
    UsersList*      m_users;
    quint32         m_usersNum;
    quint16         m_passwordSize;
    quint32         m_messageSize;

    bool            m_displayInfoMsgs;
    bool            m_soundOnMessageIn;

    QTimer*        m_refreshTimer;
    // информация об изменении статуса отсылается не моментально, а через определенный промежуток времени
    QTimer*        m_statusChangedTimer;
    QTimer*        m_initTimer;

    ChatTextWgt*   mw_chatText;
    ChatTextWgt*   mw_clearChatText; // without system messages
    InputTextWgt*  mw_inputText;
    UsersListWgt*  mw_usersList;
    UsersStatisticsModel* m_usersModel;
    UsersStatisticsWgt* mw_usersStatistics;
    QStackedWidget* mw_usersStack;

    QPushButton*   m_sendBtn;
    QPushButton*   m_refreshUlBtn;
    QCheckBox*     m_sysMessagesChbx;

    QFile*         m_file;
    StatusEditWgt* m_statusWgt;
    QString        m_statusDescription;

    QList<Smile>*  m_smilesFromSender;

    QHostAddress   m_msgsReqAddr;
    uint           m_msgsReqNum;
    QTime          m_msgsReqSent;
    QTime          m_msgsReqReceived;

    mutable QByteArray     m_parametrs;

    QVector<QSplitter*> m_splitters;

    int            m_requestsRest;

    QPixmap* drawUsersIcon(const QPixmap*, UserInfo*);

    ChannelWgt(QString name_, QWidget *parent = 0, quint32 type = 0, QHostAddress destIP = QHostAddress());

    void retranslate();

    void processData      (QC_DatagramHeader* Hdr);
    void getSmilesFromData(QC_DatagramHeader* Hdr);
    void addUser          (QC_DatagramHeader* Hdr);
    void hideUser         (QC_DatagramHeader* Hdr);
    void addUserInfo      (QC_DatagramHeader* Hdr);
    void addMsg           (QC_DatagramHeader* Hdr);
    void addAvatar        (QC_DatagramHeader* Hdr);
    void addMsg2Chat      (Message* msg);
    void sendInfoAnswer   (QC_DatagramHeader* Hdr);
    void sendStatusAnswer (const QString &, const QHostAddress &, bool = 0);

    UserWgt* findUser(quint64 Ip) const;
    const QString      & name  () const {return m_name;}
    const QHostAddress & destIp() const {return m_destIp;}
    quint32              type  () const {return m_type;}
    InputTextWgt*     inputText() const {return mw_inputText;}

    void initChannel    ();
    void rebuildChatText();
    void msgsNumAnswer  (QC_DatagramHeader* );

    void emitSomeData(uint, const QString & = "", QHostAddress = QHostAddress("")) const;

    QByteArray saveState() const;
    void restoreState(const QByteArray&);

  public slots:
    void setFocus2InputText  ();
    void slot_msgOut         ();
    void slot_refreshUL      (); // UL - users list
    void slot_deepRefreshUL  ();
    void addInfoMsg          (QC_DatagramHeader* Hdr);
    void slot_chbxInfChgd    ();
    void setSndOnMsgIn       (bool b) {m_soundOnMessageIn = b;}

    void slot_infoRequest  (UserWgt*);
    void slot_statusRequest() const {emitSomeData(Globals::STATUS_REQUEST);}
    void slot_connected    () const {emitSomeData(Globals::CONNECTED, "Connected");}
    void slot_disconnected () const {emitSomeData(Globals::DISCONNECTED, "Disconnected");}

    void slot_statusChanged   ();
    void slot_startStatusChangedTimer();
    void slot_finMsgsHistoryReq();
    void slot_changeUlRefreshInterval(uint);
    void slot_changeUlDeepRefreshInterval(uint);

    void slot_controlSplitter(int, int);
    void updateUsersView();
    void nextStatusRequest();

    void changeEvent(QEvent *ev)
      if(ev->type() == QEvent::LanguageChange)

    void statusAnswer    (const QString &, const QHostAddress &, quint32, bool changed = 0, bool = 0);
    void avatarAnswer    (const QString &, const QHostAddress &, quint32);
    void infStatusChanged(const QString &, const QHostAddress &, quint32);
    void infoAnswer      (const QString &, const QHostAddress &, quint32, uchar);
    void sendMsgsHistory (const QString &, const QHostAddress &, const QByteArray &, uint);
    void sendMsgsNum     (const QString &, const QHostAddress &, quint32, uint);
    void sendSomeData    (const QString &, const QHostAddress &, uint, const QString &, quint32, QByteArray*) const;
    void sendMessage     (const QString &, const QHostAddress &, quint32, QTextDocument*);

    void wantActivate    ();
    void rebuildChat     (short type);
    void showStatusDescriptionDlg();
    void wantSaveState(const QString &, const QByteArray &);


Generated by  Doxygen 1.6.0   Back to index