root/trunk/qt4-gui/src/userevents/usereventcommon.h

Revision 6463, 3.3 kB (checked in by flynd, 4 months ago)

Use a const pointer for user objects that are only fetched for read access. Fixed some places where we changed the user even though we just had a read lock.

Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of Licq, an instant messaging client for UNIX.
4 * Copyright (C) 2007 Licq developers
5 *
6 * Licq is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Licq is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Licq; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20
21#ifndef USEREVENTCOMMON_H
22#define USEREVENTCOMMON_H
23
24#include <QWidget>
25
26#include <list>
27#include <string>
28
29class QActionGroup;
30class QHBoxLayout;
31class QMenu;
32class QToolBar;
33class QVBoxLayout;
34
35class CICQSignal;
36class ICQUser;
37
38
39namespace LicqQtGui
40{
41class InfoField;
42
43class UserEventCommon : public QWidget
44{
45  Q_OBJECT
46
47public:
48  UserEventCommon(QString id, unsigned long ppid, QWidget* parent = 0, const char* name = 0);
49  virtual ~UserEventCommon();
50
51  QString id() { return QString::fromAscii(myUsers.front().c_str()); }
52  unsigned long ppid() { return myPpid; }
53  unsigned long convoId() { return myConvoId; }
54  std::list<std::string>& convoUsers() { return myUsers; }
55  void setConvoId(unsigned long n) { myConvoId = n; }
56  void addEventTag(unsigned long n) { if (n) myEventTag.push_back(n); }
57
58  bool isUserInConvo(QString id);
59  void setTyping(unsigned short type);
60
61protected:
62  std::list<unsigned long> myEventTag;
63
64  bool myIsOwner;
65  bool myDeleteUser;
66  unsigned long myPpid;
67  unsigned long myConvoId;
68  time_t myRemoteTimeOffset;
69  std::list<std::string> myUsers;
70  unsigned long mySendFuncs;
71
72  // ID of the higest event we've processed. Helps determine
73  // which events we already processed in the ctor.
74  int myHighestEventId;
75
76  QString myId;
77  QString myBaseTitle;
78  QString myProgressMsg;
79
80  QHBoxLayout* myTophLayout;
81  QVBoxLayout* myTopLayout;
82  QVBoxLayout* myMainWidget;
83  QToolBar* myToolBar;
84  QMenu* myEncodingsMenu;
85  QActionGroup* myEncodingsGroup;
86  QAction* myMenu;
87  QAction* myHistory;
88  QAction* myInfo;
89  QAction* myEncoding;
90  QAction* mySecure;
91  QAction* myEmoticon;
92  QAction* myForeColor;
93  QAction* myBackColor;
94  InfoField* myTimezone;
95  QTextCodec* myCodec;
96  QTimer* myTimeTimer;
97  QTimer* myTypingTimer;
98
99  void flashTaskbar();
100  void updateWidgetInfo(const ICQUser* u);
101  void pushToolTip(QAction* action, QString tooltip);
102
103  virtual void userUpdated(CICQSignal* sig, QString id = QString::null, unsigned long ppid = 0) = 0;
104
105protected slots:
106  /**
107   * Update iconset in menus and on buttons
108   */
109  virtual void updateIcons();
110
111  void connectSignal();
112  void setEncoding(QAction* action);
113  void setMsgWinSticky(bool sticky = true);
114  void showHistory();
115  void showUserInfo();
116  void switchSecurity();
117  void updateTime();
118  void updateTyping();
119  void showUserMenu();
120  void showEncodingsMenu();
121  void updatedUser(CICQSignal* sig);
122
123signals:
124  void finished(QString id, unsigned long ppid);
125  void encodingChanged();
126};
127
128} // namespace LicqQtGui
129
130#endif
Note: See TracBrowser for help on using the browser.