source: psi/vendor/affinix/current/src/contactview.h@ 2

Last change on this file since 2 was 2, checked in by dmik, 19 years ago

Imported original Psi 0.10 sources from Affinix

File size: 9.5 KB
Line 
1/*
2 * contactview.h - contact list widget
3 * Copyright (C) 2001, 2002 Justin Karneges
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#ifndef CONTACTVIEW_H
22#define CONTACTVIEW_H
23
24#include<qobject.h>
25#include<qlistview.h>
26#include<qtooltip.h>
27#include<qvaluelist.h>
28#include"xmpp.h"
29#include"common.h"
30
31class IconAction;
32class UserListItem;
33class ContactView;
34class ContactViewItem;
35class PsiAccount;
36class Icon;
37class QTimer;
38class QPixmap;
39
40using namespace XMPP;
41
42class ContactProfile;
43
44// ContactProfile: this holds/manipulates a roster profile for an account
45class ContactProfile : public QObject
46{
47 Q_OBJECT
48public:
49 ContactProfile(PsiAccount *, const QString &name, ContactView *, bool unique=false);
50 ~ContactProfile();
51
52 void setEnabled(bool e=TRUE);
53
54 const QString & name() const;
55 void setName(const QString &name);
56 void setState(int);
57 void setUsingSSL(bool);
58 ContactView *contactView() const;
59 ContactViewItem *self() const;
60
61 PsiAccount *psiAccount() const;
62
63 void updateEntry(const UserListItem &);
64 void removeEntry(const Jid &);
65 void updateSelf();
66 void addSelf();
67 void removeSelf();
68 void setAlert(const Jid &, const Icon *);
69 void clearAlert(const Jid &);
70 void animateNick(const Jid &);
71
72 void addAllNeededContactItems();
73 void removeAllUnneededContactItems();
74
75 void ensureVisible(const Jid &);
76 void clear();
77
78 QString makeTip(bool trim, bool doLinkify) const;
79
80 ContactViewItem *checkGroup(int type);
81 ContactViewItem *checkGroup(const QString &name);
82
83 void setName(const char *);
84
85
86signals:
87 void actionDefault(const Jid &);
88 void actionRecvEvent(const Jid &);
89 void actionSendMessage(const Jid &);
90 void actionSendMessage(const JidList &);
91 void actionSendUrl(const Jid &);
92 void actionRemove(const Jid &);
93 void actionRename(const Jid &, const QString &);
94 void actionGroupRename(const QString &, const QString &);
95 void actionHistory(const Jid &);
96 void actionOpenChat(const Jid &);
97 void actionOpenChatSpecific(const Jid &);
98 void actionAgentSetStatus(const Jid &, Status &);
99 void actionInfo(const Jid &);
100 void actionAuth(const Jid &);
101 void actionAuthRequest(const Jid &);
102 void actionAuthRemove(const Jid &);
103 void actionAdd(const Jid &);
104 void actionGroupAdd(const Jid &, const QString &);
105 void actionGroupRemove(const Jid &, const QString &);
106 void actionTest(const Jid &);
107 void actionSendFile(const Jid &);
108 void actionSendFiles(const Jid &, const QStringList &);
109 void actionDisco(const Jid &, const QString &);
110 void actionInvite(const Jid &, const QString &);
111 void actionAssignKey(const Jid &);
112 void actionUnassignKey(const Jid &);
113
114private slots:
115 void updateGroups();
116
117public:
118 class Entry;
119 class Private;
120private:
121 Private *d;
122
123 ContactViewItem *addGroup(int type);
124 ContactViewItem *addGroup(const QString &name);
125 ContactViewItem *ensureGroup(int type);
126 ContactViewItem *ensureGroup(const QString &name);
127 void checkDestroyGroup(ContactViewItem *group);
128 void checkDestroyGroup(const QString &group);
129 ContactViewItem *addContactItem(Entry *e, ContactViewItem *group_item);
130 ContactViewItem *ensureContactItem(Entry *e, ContactViewItem *group_item);
131 void removeContactItem(Entry *e, ContactViewItem *i);
132 void addNeededContactItems(Entry *e);
133 void removeUnneededContactItems(Entry *e);
134 void clearContactItems(Entry *e);
135
136 void removeEntry(Entry *);
137 Entry *findEntry(const Jid &) const;
138 Entry *findEntry(ContactViewItem *) const;
139
140 void ensureVisible(Entry *);
141
142 // useful functions to grab groups of users
143 JidList contactListFromCVGroup(ContactViewItem *) const;
144 int contactSizeFromCVGroup(ContactViewItem *) const;
145 int contactsOnlineFromCVGroup(ContactViewItem *) const;
146 JidList contactListFromGroup(const QString &groupName) const;
147 int contactSizeFromGroup(const QString &groupName) const;
148
149 void updateGroupInfo(ContactViewItem *group);
150 QStringList groupList() const;
151
152 void deferredUpdateGroups();
153
154 friend class ContactView;
155 void scActionDefault(ContactViewItem *);
156 void scRecvEvent(ContactViewItem *);
157 void scSendMessage(ContactViewItem *);
158 void scRename(ContactViewItem *);
159 void scVCard(ContactViewItem *);
160 void scHistory(ContactViewItem *);
161 void scOpenChat(ContactViewItem *);
162 void scAgentSetStatus(ContactViewItem *, Status &);
163 void scRemove(ContactViewItem *);
164 void doItemRenamed(ContactViewItem *, const QString &);
165 void doContextMenu(ContactViewItem *, const QPoint &);
166
167 friend class ContactViewItem;
168 void dragDrop(const QString &, ContactViewItem *);
169 void dragDropFiles(const QStringList &, ContactViewItem *);
170};
171
172// ContactView: the actual widget
173class ContactView : public QListView, public QToolTip
174{
175 Q_OBJECT
176public:
177 ContactView(QWidget *parent=0, const char *name=0);
178 ~ContactView();
179
180 bool isShowOffline() const { return v_showOffline; }
181 bool isShowAgents() const { return v_showAgents; }
182 bool isShowAway() const { return v_showAway; }
183 bool isShowHidden() const { return v_showHidden; }
184 bool isShowSelf() const { return v_showSelf; }
185
186 void clear();
187 void resetAnim();
188 QTimer *animTimer() const;
189
190 IconAction *qa_send, *qa_chat, *qa_ren, *qa_hist, *qa_logon, *qa_recv, *qa_rem, *qa_vcard;
191 IconAction *qa_assignAvatar, *qa_clearAvatar;
192
193 QSize minimumSizeHint() const;
194 QSize sizeHint() const;
195
196protected:
197 // reimplemented
198 void maybeTip(const QPoint &);
199 void keyPressEvent(QKeyEvent *);
200 bool eventFilter( QObject *, QEvent * );
201 QDragObject *dragObject();
202
203signals:
204 void showOffline(bool);
205 void showAway(bool);
206 void showHidden(bool);
207 void showAgents(bool);
208 void showSelf(bool);
209
210public slots:
211 void setShowOffline(bool);
212 void setShowAgents(bool);
213 void setShowAway(bool);
214 void setShowHidden(bool);
215 void setShowSelf(bool);
216 void optionsUpdate();
217 void recalculateSize();
218
219private slots:
220 void qlv_singleclick(int, QListViewItem *, const QPoint &, int);
221 void qlv_doubleclick(QListViewItem *);
222 void qlv_contextPopup(QListViewItem *, const QPoint &, int);
223 void qlv_contextMenuRequested(QListViewItem *, const QPoint &, int);
224 void qlv_itemRenamed(QListViewItem *, int, const QString &);
225 void leftClickTimeOut();
226
227 void doRecvEvent();
228 void doRename();
229 void doEnter();
230 void doContext();
231 void doSendMessage();
232 void doOpenChat();
233 void doHistory();
234 void doVCard();
235 void doLogon();
236 void doRemove();
237
238 void doAssignAvatar();
239 void doClearAvatar();
240
241public:
242 class Private;
243 friend class Private;
244private:
245 Private *d;
246
247 QPoint mousePressPos; // store pressed position, idea taken from Licq
248 bool v_showOffline, v_showAgents, v_showAway, v_showHidden, v_showSelf;
249 bool lcto_active; // double click active?
250 QPoint lcto_pos;
251 QListViewItem *lcto_item;
252 QSize lastSize;
253
254 friend class ContactProfile;
255 void link(ContactProfile *);
256 void unlink(ContactProfile *);
257 bool allowResize() const;
258};
259
260// ContactViewItem: an entry in the ContactView (profile, group, or contact)
261class ContactViewItem : public QObject, public QListViewItem
262{
263 Q_OBJECT
264public:
265 enum { Profile, Group, Contact };
266 enum { gGeneral, gNotInList, gAgents, gPrivate, gUser };
267
268 ContactViewItem(const QString &profileName, ContactProfile *, ContactView *parent);
269 ContactViewItem(const QString &groupName, int groupType, ContactProfile *, ContactView *parent);
270 ContactViewItem(const QString &groupName, int groupType, ContactProfile *, ContactViewItem *parent);
271 ContactViewItem(UserListItem *, ContactProfile *, ContactViewItem *parent);
272 ~ContactViewItem();
273
274 ContactProfile *contactProfile() const;
275 int type() const;
276 int groupType() const;
277 const QString & groupName() const;
278 const QString & groupInfo() const;
279 UserListItem *u() const;
280 int status() const;
281 bool isAgent() const;
282 bool isAlerting() const;
283 bool isAnimatingNick() const;
284 int parentGroupType() const; // use with contacts: returns grouptype of parent group
285
286 void setContact(UserListItem *);
287 void setProfileName(const QString &);
288 void setProfileState(int);
289 void setProfileSSL(bool);
290 void setGroupName(const QString &);
291 void setGroupInfo(const QString &);
292 void setAnimateNick();
293 void setAlert(const Icon *);
294 void clearAlert();
295 void setIcon(const Icon *, bool alert = false);
296
297 void resetStatus();
298 void resetName(); // use this to cancel a rename
299 void resetGroupName();
300
301 void updatePosition();
302 void optionsUpdate();
303
304 // reimplemented functions
305 int rtti() const;
306 void paintFocus(QPainter *, const QColorGroup &, const QRect &);
307 void paintBranches(QPainter *, const QColorGroup &, int, int, int);
308 void paintCell(QPainter *, const QColorGroup & cg, int column, int width, int alignment);
309 void setOpen(bool o);
310 void insertItem(QListViewItem * newChild);
311 void takeItem(QListViewItem * item);
312 int compare(QListViewItem *, int, bool) const;
313 bool acceptDrop(const QMimeSource *) const;
314
315public slots:
316 void resetAnim();
317 void iconUpdated(const QPixmap &);
318 void animateNick();
319 void stopAnimateNick();
320
321protected:
322 void dragEntered();
323 void dragLeft();
324 void dropped(QDropEvent *);
325
326private:
327 class Private;
328 Private *d;
329
330 void cacheValues();
331 int rankGroup(int groupType) const;
332 int rankStatus(int status) const;
333 void drawGroupIcon();
334};
335
336#endif
Note: See TracBrowser for help on using the repository browser.