gotyemsg.h
2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef GOTYEMSG_H
#define GOTYEMSG_H
#include <QWidget>
#include <QListWidget>
#include <QWebView>
#include <QLabel>
#include "gotye/GotyeAPI.h"
#include "gotye/GotyeDelegate.h"
#include <QMediaPlayer>
#include <QSound>
USING_NS_GOTYEAPI;
#define defaultHeadimg "qrc:/Images/ChatArea/Default_headimg.png"
#define imgTitle "file:///"
class GotyeMsg : public QWidget,public GotyeDelegate
{
Q_OBJECT
public:
explicit GotyeMsg(QWidget *parent = 0);
void init();
void login(QString uid);
void logout();
void apiist_exit();
static GotyeMsg *Instance();
virtual void onLogin(GotyeStatusCode code, const GotyeLoginUser& user);
virtual void onReceiveMessage(const GotyeMessage& message, bool* downloadMediaIfNeed);
virtual void onDownloadMediaInMessage(const GotyeStatusCode code, const GotyeMessage& message);
virtual void onGetUserDetail(GotyeStatusCode code, const GotyeUser& user);
virtual void onDownloadMedia(GotyeStatusCode code, GotyeMedia& media);
virtual void onSendMessage(GotyeStatusCode code, const GotyeMessage& message);
//设置接口
void setShowMsgWebviwe(QWebView *showViwe);
void setUpdataUserList(QListWidget *useList);
void setShowUserName(QLabel *showName);
GotyeChatTarget setChooseUser(int count);
void setMyHeadImg(QString img);
void setMyUid(int uid);
void setIsUpdata(bool flag);
void sendMessage(QString targetUid, QString msg, GotyeMessageType type);
void sendMessage(QString msg, GotyeMessageType type);
void uidGetChatLog(int uid);
void setShowMsgNum(QLabel *label);
void ShowNewMsgNum();
void showLastChatArea(GotyeChatTarget user);
public:
static GotyeMsg *m_GotypMsg;
bool isLogin;
signals:
public slots:
//聊天交互
void RevMsgShow(QString msg,QString head);
void RevImageShow(QString msg,QString head);
void SendMsgShow(QString msg ,QString head,QString status);
void SendImageShow(QString msg , QString head, QString status);
void showMsgTime(int lastTime,int nowTime);
QString getShowTime(int secondNum);
void msgChatAreaInit();
void showUpMsg(GotyeMessage upMessage);
// void showNowChat();
void delItemChat(QListWidgetItem *ChangedItem);
QString getNowUserName();
void scrollTop(int dx, int dy, const QRect& scrollViewRect);
private:
QWebView *showMsgViwe; //显示聊天的view
QListWidget *useShowList; //显示聊天列表
QLabel *showUserName;
QLabel *showNewMsg;
QString myHeadImg;
QString otherHeadImg;
std::vector<GotyeChatTarget> pTargetList; //存储聊天用户列表
GotyeChatTarget nowUser; //当前聊天用户
int markerMsgTime;
int myUid;
bool isUpdataMsg;
// QMediaPlayer *player;
QSound *sound;
QString loginUid;
int nowMessageNum;
// int flagMsgTime;
};
#endif // GOTYEMSG_H