-
Notifications
You must be signed in to change notification settings - Fork 1
/
chatmessagedelegate.h
67 lines (47 loc) · 1.56 KB
/
chatmessagedelegate.h
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
#ifndef CHATMESSAGEDELEGATE_H
#define CHATMESSAGEDELEGATE_H
#include <QStyledItemDelegate>
#include <QItemDelegate>
#include <QTimer>
#include <QTime>
class ChatMessageView;
class ChatMessageDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit ChatMessageDelegate(QObject *parent = 0);
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor,
const QModelIndex &index) const;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;
bool createInRealTime() const;
void setCreateInRealTime(bool createInRealTime);
protected:
bool editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index);
signals:
public slots:
private slots:
void timerCheck();
private:
ChatMessageView *m_parent;
mutable QMap<QModelIndex, qint64> m_mapIndexClock;
struct PrivateData
{
QWidget *editor;
QSize lastSize;
};
mutable QMap<QModelIndex, PrivateData> m_mapEditor;
QTimer m_timerCheck;
bool m_createInRealTime;
};
#endif // CHATMESSAGEDELEGATE_H