equal
deleted
inserted
replaced
38 class QListView; |
38 class QListView; |
39 class QSettings; |
39 class QSettings; |
40 class QAbstractItemModel; |
40 class QAbstractItemModel; |
41 class QMenu; |
41 class QMenu; |
42 |
42 |
43 /// Class for custom nickname sorting |
|
44 class ListWidgetNickItem : public QListWidgetItem |
|
45 { |
|
46 public: |
|
47 enum StateFlag { |
|
48 Ready = Qt::UserRole, |
|
49 ServerAdmin = Qt::UserRole + 1, |
|
50 RoomAdmin = Qt::UserRole + 2, |
|
51 Registered = Qt::UserRole + 3, |
|
52 Friend = Qt::UserRole + 4, |
|
53 Ignore = Qt::UserRole + 5 |
|
54 }; |
|
55 |
|
56 ListWidgetNickItem(const QString & nick, bool isFriend, bool isIgnored); |
|
57 void setData(StateFlag role, const QVariant &value); |
|
58 bool operator<(const QListWidgetItem & other) const; |
|
59 |
|
60 private: |
|
61 QHash<quint32, QIcon> & m_icons(); |
|
62 void updateIcon(); |
|
63 }; |
|
64 |
|
65 |
|
66 /** |
43 /** |
67 * @brief Chat widget. |
44 * @brief Chat widget. |
68 * |
45 * |
69 * By default uses :res/css/chat.css as style sheet for chat. |
46 * By default uses :res/css/chat.css as style sheet for chat. |
70 * See \repo{res/css/chat.css} for a more detailed description. |
47 * See \repo{res/css/chat.css} for a more detailed description. |
76 { |
53 { |
77 Q_OBJECT |
54 Q_OBJECT |
78 |
55 |
79 public: |
56 public: |
80 HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); |
57 HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); |
81 void loadLists(const QString & nick); |
|
82 void saveLists(const QString & nick); |
|
83 void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible) |
58 void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible) |
84 void setShowFollow(bool enabled); |
59 void setShowFollow(bool enabled); |
85 QStringList ignoreList, friendsList; |
|
86 static const QString & styleSheet(); |
60 static const QString & styleSheet(); |
87 void displayError(const QString & message); |
61 void displayError(const QString & message); |
88 void displayNotice(const QString & message); |
62 void displayNotice(const QString & message); |
89 void displayWarning(const QString & message); |
63 void displayWarning(const QString & message); |
90 void setUser(const QString & nickname); |
64 void setUser(const QString & nickname); |
101 static QString s_tsFormat; |
75 static QString s_tsFormat; |
102 static const QRegExp URLREGEXP; |
76 static const QRegExp URLREGEXP; |
103 |
77 |
104 static void setStyleSheet(const QString & styleSheet = ""); |
78 static void setStyleSheet(const QString & styleSheet = ""); |
105 |
79 |
106 void loadList(QStringList & list, const QString & file); |
|
107 void saveList(QStringList & list, const QString & file); |
|
108 void updateNickItem(QListWidgetItem *item); |
|
109 void updateNickItems(); |
|
110 void addLine(const QString & cssClass, QString line, bool isHighlight = false); |
80 void addLine(const QString & cssClass, QString line, bool isHighlight = false); |
111 bool parseCommand(const QString & line); |
81 bool parseCommand(const QString & line); |
112 void discardStyleSheet(); |
82 void discardStyleSheet(); |
113 void saveStyleSheet(); |
83 void saveStyleSheet(); |
114 QString linkedNick(const QString & nickname); |
84 QString linkedNick(const QString & nickname); |
118 void onChatString(const QString& nick, const QString& str); |
88 void onChatString(const QString& nick, const QString& str); |
119 void onServerMessage(const QString& str); |
89 void onServerMessage(const QString& str); |
120 void nickAdded(const QString& nick, bool notifyNick); |
90 void nickAdded(const QString& nick, bool notifyNick); |
121 void nickRemoved(const QString& nick); |
91 void nickRemoved(const QString& nick); |
122 void clear(); |
92 void clear(); |
123 void setReadyStatus(const QString & nick, bool isReady); |
|
124 void setAdminStatus(const QString & nick, bool isAdmin); |
|
125 void setRoomMasterStatus(const QString & nick, bool isAdmin); |
|
126 void setRegisteredStatus(const QStringList & nicks, bool isRegistered); |
|
127 void adminAccess(bool); |
93 void adminAccess(bool); |
128 |
94 |
129 signals: |
95 signals: |
130 void chatLine(const QString& str); |
96 void chatLine(const QString& str); |
131 void kick(const QString & str); |
97 void kick(const QString & str); |
155 QString m_clickedNick; |
121 QString m_clickedNick; |
156 QList<QRegExp> m_highlights; ///< regular expressions used for highlighting |
122 QList<QRegExp> m_highlights; ///< regular expressions used for highlighting |
157 bool notify; |
123 bool notify; |
158 bool m_autoKickEnabled; |
124 bool m_autoKickEnabled; |
159 |
125 |
160 void setStatus(const QString & nick, ListWidgetNickItem::StateFlag flag, bool status); |
|
161 |
|
162 private slots: |
126 private slots: |
163 void returnPressed(); |
127 void returnPressed(); |
164 void onBan(); |
128 void onBan(); |
165 void onKick(); |
129 void onKick(); |
166 void onInfo(); |
130 void onInfo(); |
167 void onFollow(); |
131 void onFollow(); |
168 void onIgnore(); |
132 void onIgnore(); |
169 void onFriend(); |
133 void onFriend(); |
170 void chatNickDoubleClicked(QListWidgetItem * item); |
|
171 void chatNickSelected(); |
|
172 void linkClicked(const QUrl & link); |
134 void linkClicked(const QUrl & link); |
173 void nicksContextMenuRequested(const QPoint & pos); |
135 void nicksContextMenuRequested(const QPoint & pos); |
174 }; |
136 }; |
175 |
137 |
176 #endif // _CHAT_WIDGET_INCLUDED |
138 #endif // _CHAT_WIDGET_INCLUDED |