KVIrc  4.9.2
DeveloperAPIs
KviUserListView.h
Go to the documentation of this file.
1 #ifndef _KVI_USERLISTVIEW_H_
2 #define _KVI_USERLISTVIEW_H_
3 //=============================================================================
4 //
5 // File : KviUserListView.h
6 // Creation date : Tue Aug 1 2000 21:03:41 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
40 #include "kvi_settings.h"
41 #include "KviPointerList.h"
42 #include "KviPointerHashTable.h"
43 #include "KviWindowToolWidget.h"
44 #include "KviCString.h"
45 #include "KviIrcUserDataBase.h"
46 #include "KviIrcMask.h"
47 #include "KviTimeUtils.h"
48 #include "KviTalToolTip.h"
49 
50 #include <time.h>
51 
52 #include <QWidget>
53 
54 class QLabel;
55 class QScrollBar;
56 class KviUserListView;
58 class KviConsoleWindow;
59 class KviWindow;
60 
61 #define KVI_USERLISTVIEW_GRIDTYPE_3DGRID 0
62 #define KVI_USERLISTVIEW_GRIDTYPE_3DBUTTONS 1
63 #define KVI_USERLISTVIEW_GRIDTYPE_PLAINGRID 2
64 #define KVI_USERLISTVIEW_GRIDTYPE_DOTGRID 3
65 #define KVI_USERLISTVIEW_GRIDTYPE_MAXIMUM 3
66 #define KVI_USERLISTVIEW_GRIDTYPE_DEFAULT 0
67 
74 {
75  unsigned int uTotal;
76  unsigned int uActive;
77  unsigned int uActiveOp;
78  unsigned int uHot;
79  unsigned int uHotOp;
80  unsigned int uIrcOp;
81  unsigned int uChanOwner;
82  unsigned int uChanAdmin;
83  unsigned int uOp;
84  unsigned int uHalfOp;
85  unsigned int uVoiced;
86  unsigned int uUserOp;
89 
95 {
96 public:
104 
108  virtual ~KviUserListToolTip();
109 
110 private:
112 
113 public:
119  virtual void maybeTip(const QPoint & pnt);
120 
127  void doTip(const QRect & rect, const QString & szStr) { tip(rect, szStr); };
128 };
129 
134 class KVIRC_API KviUserListEntry : public QObject
135 {
136  Q_OBJECT
137  friend class KviUserListView;
138  friend class KviUserListViewArea;
139 
140 public:
150  KviUserListEntry(KviUserListView * pParent, const QString & szNick, KviIrcUserEntry * pEntry, short int iFlags, bool bJoinTimeUnknown = true);
151 
155  ~KviUserListEntry();
156 
157 protected:
159  QString m_szNick;
161  short int m_iFlags;
162  short int m_iTemperature; // user temperature : 0 = neutral
165 
171 
172 public:
177  short int flags() const { return m_iFlags; };
178 
183  KviIrcUserEntry * globalData() { return m_pGlobalData; };
184 
189  const QString & nick() const { return m_szNick; };
190 
195  KviUserListEntry * next() { return m_pNext; };
196 
202  bool color(QColor & color);
203 
208  void updateAvatarData();
209  void detachAvatarData();
210 
211 protected:
216  void recalcSize();
217 private slots:
218  void avatarFrameChanged();
219  void avatarDestroyed();
220 };
221 
227 {
228  friend class KviUserListEntry;
229  friend class KviUserListViewArea;
230  friend class KviUserListToolTip;
231  friend class KviConsoleWindow;
232  friend class KviChannelWindow;
233  friend class KviQueryWindow;
234  Q_OBJECT
235 public:
247  KviUserListView(QWidget * pParent, KviWindowToolPageButton * pButton, KviIrcUserDataBase * pDb, KviWindow * pWnd, int iDictSize = 5, const QString & szTextLabel = QString(), const char * pName = "userslistview");
248 
252  ~KviUserListView();
253 
254 protected:
260  QLabel * m_pUsersLabel;
278 
279 public:
284  void updateArea();
285 
291  void select(const QString & szNick);
292 
298  void ensureVisible(const QString & szNick);
299 
304  void applyOptions();
305 
311 
316  KviUserListEntry * firstItem() { return m_pHeadItem; };
317 
324  KviUserListEntry * itemAt(const QPoint & pnt, QRect * pRect = 0);
325 
331  bool itemVisible(KviUserListEntry * pEntry);
332 
337  KviWindow * window() { return m_pKviWindow; };
338 
343  unsigned int count() { return m_pEntryDict->count(); };
344 
349  int selectedCount() { return m_iSelectedCount; };
350 
355  int ircOpCount() { return m_iIrcOpCount; };
356 
361  int chanOwnerCount() { return m_iChanOwnerCount; };
362 
367  int chanAdminCount() { return m_iChanAdminCount; };
368 
373  int opCount() { return m_iOpCount; };
374 
379  int halfOpCount() { return m_iHalfOpCount; };
380 
385  int voiceCount() { return m_iVoiceCount; };
386 
391  int userOpCount() { return m_iUserOpCount; };
392 
400  KviUserListEntry * findEntry(const QString & szNick) { return szNick.isEmpty() ? 0 : m_pEntryDict->find(szNick); };
401 
407  void appendSelectedNicknames(QString & szBuffer);
408 
413  QString * firstSelectedNickname();
414 
419  QString * nextSelectedNickname();
420 
425  void partAll();
426 
432  void partAllButOne(const QString & szWhoNot);
433 
439  void userStats(KviUserListViewUserStats * pStats);
440 
454  int getUserModeLevel(const QString & szNick);
455 
461  kvi_time_t getUserJoinTime(const QString & szNick);
462 
468  kvi_time_t getUserLastActionTime(const QString & szNick);
469 
475  char getUserFlag(KviUserListEntry * pEntry);
476 
482  char getUserFlag(const QString & szNick) { return getUserFlag(m_pEntryDict->find(szNick)); };
483 
489  bool part(const QString & szNick) { return partInternal(szNick, true); };
490 
497  void prependUserFlag(const QString & szNick, QString & szBuffer);
498 
504  int flags(const QString & szNick);
505 
512  bool isChanOwner(const QString & szNick, bool bAtLeast = false);
513 
520  bool isChanAdmin(const QString & szNick, bool bAtLeast = false);
521 
528  bool isOp(const QString & szNick, bool bAtLeast = false);
529 
536  bool isHalfOp(const QString & szNick, bool bAtLeast = false);
537 
544  bool isVoice(const QString & szNick, bool bAtLeast = false);
545 
552  bool isUserOp(const QString & szNick, bool bAtLeast = false);
553 
560  bool setChanOwner(const QString & szNick, bool bChanOwner);
561 
568  bool setChanAdmin(const QString & szNick, bool bChanAdmin);
569 
576  bool setOp(const QString & szNick, bool bOp);
577 
584  bool setHalfOp(const QString & szNick, bool bHalfOp);
585 
592  bool setVoice(const QString & szNick, bool bVoice);
593 
600  bool setUserOp(const QString & szNick, bool bUserOp);
601 
618  bool userActionVerifyMask(const QString & szNick, const QString & szUser, const QString & szHost, int iActionTemperature, QString & szOldUser, QString & szOldHost);
619 
630  void userAction(KviIrcMask * pUser, int iActionTemperature);
631 
644  void userAction(const QString & szNick, const QString & szUser, const QString & szHost, int iActionTemperature);
645 
656  void userAction(const QString & szNick, int iActionTemperature);
657 
664  bool nickChange(const QString & szOldNick, const QString & szNewNick);
665 
674  KviUserListEntry * join(const QString & szNick, const QString & szUser = QString(), const QString & szHost = QString(), int iFlags = 0);
675 
681  bool avatarChanged(const QString & szNick);
682 
688  void enableUpdates(bool bEnable);
689 
703  void setMaskEntries(char cType, int iNum);
704 
709  void emitRightClick();
710 
715  void emitDoubleClick();
716 
728  bool completeNickStandard(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask);
729 
741  void completeNickBashLike(const QString & szBegin, KviPointerList<QString> * pList, bool bAppendMask);
742 
743 protected:
750  void maybeTip(KviUserListToolTip * pTip, const QPoint & pnt);
751 
759  void triggerUpdate();
760 
765  void updateUsersLabel();
766 
773  void insertUserEntry(const QString & szNick, KviUserListEntry * pEntry);
774 
781  void removeAllEntries();
782 
789  bool partInternal(const QString & szNick, bool bRemove = true);
790 
796  void setUserDataBase(KviIrcUserDataBase * pDb) { m_pIrcUserDataBase = pDb; };
797 
802  void updateScrollBarRange();
803 
804  virtual void resizeEvent(QResizeEvent * e);
805 public slots:
810  void animatedAvatarUpdated(KviUserListEntry * e);
811 };
812 
817 class KVIRC_API KviUserListViewArea : public QWidget
818 {
819  friend class KviUserListView;
820 
821  Q_OBJECT
822  Q_PROPERTY(int TransparencyCapable READ dummyRead)
823 public:
830 
835 
836 public:
841  int dummyRead() const { return 0; };
842 protected:
843  KviUserListView * m_pListView;
845  QScrollBar * m_pScrollBar;
849 
850 protected:
851  virtual void paintEvent(QPaintEvent * e);
852  virtual void resizeEvent(QResizeEvent * e);
853  virtual void mousePressEvent(QMouseEvent * e);
854  virtual void mouseMoveEvent(QMouseEvent * e);
855  virtual void mouseReleaseEvent(QMouseEvent * e);
856  virtual void mouseDoubleClickEvent(QMouseEvent * e);
857  virtual void wheelEvent(QWheelEvent * e);
858  virtual void keyPressEvent(QKeyEvent * e);
859 protected slots:
865  void scrollBarMoved(int iNewVal);
866 };
867 
868 #endif //_KVI_USERLISTVIEW_H_
int m_iHeight
Definition: KviUserListView.h:166
KviUserListEntry * m_pNext
Definition: KviUserListView.h:168
int m_iTotalHeight
Definition: KviUserListView.h:271
int m_iFontHeight
Definition: KviUserListView.h:272
Definition: KviAnimatedPixmap.h:67
KviIrcUserEntry * globalData()
Returns the irc user db entry.
Definition: KviUserListView.h:183
int m_iIrcOpCount
Definition: KviUserListView.h:264
KviUserListView * m_pListView
Definition: KviUserListView.h:158
KviUserListEntry * m_pHeadItem
Definition: KviUserListView.h:257
KviUserListEntry * m_pLastEntryUnderMouse
Definition: KviUserListView.h:844
Irc user mask abstraction.
KviWindow * window()
Returns the window associated to the userlist.
Definition: KviUserListView.h:337
KviWindow * m_pKviWindow
Definition: KviUserListView.h:277
KviUserListViewArea * m_pViewArea
Definition: KviUserListView.h:261
virtual void applyOptions()
Applies the options.
Definition: KviQueryWindow.cpp:495
Definition: KviConsoleWindow.h:75
bool part(const QString &szNick)
Check if a user parts from a channel.
Definition: KviUserListView.h:489
#define KVIRC_API
Definition: kvi_settings.h:128
unsigned int uChanAdmin
Definition: KviUserListView.h:82
void userAction(KviIrcMask *user, unsigned int uActionType)
Called when a user performs an action.
Definition: KviQueryWindow.cpp:316
unsigned int uIrcOp
Definition: KviUserListView.h:80
virtual void tip(const QRect &rect, const QString &text)
Definition: KviTalToolTip.cpp:93
void doTip(const QRect &rect, const QString &szStr)
Shows the tooltip.
Definition: KviUserListView.h:127
A struct to hold user statistics.
Definition: KviUserListView.h:73
A class to manage userlist tooltips.
Definition: KviUserListView.h:94
int iAvgTemperature
Definition: KviUserListView.h:87
int selectedCount()
Returns the number of selected entries in the userlist.
Definition: KviUserListView.h:349
int m_iChanOwnerCount
Definition: KviUserListView.h:265
KviIrcUserEntry * m_pGlobalData
Definition: KviUserListView.h:160
int opCount()
Returns the number of operators.
Definition: KviUserListView.h:373
unsigned int count()
Returns the number of the entries in the userlist.
Definition: KviUserListView.h:343
int m_iTopItemOffset
Definition: KviUserListView.h:847
unsigned int uHotOp
Definition: KviUserListView.h:79
KviUserListView * m_pListView
Definition: KviUserListView.h:111
virtual void resizeEvent(QResizeEvent *e)
Definition: KviUserListView.cpp:1430
char getUserFlag(const QString &szNick)
Returns the flags of a user.
Definition: KviUserListView.h:482
int m_ibEntries
Definition: KviUserListView.h:274
KVIRC_API void join(QString &url, KviIrcServer *server)
Definition: KviIrcUrl.cpp:147
KviUserListToolTip * m_pToolTip
Definition: KviUserListView.h:273
struct _KviUserListViewUserStats KviUserListViewUserStats
#define kvi_time_t
Definition: KviTimeUtils.h:43
KviIrcUserDataBase * m_pIrcUserDataBase
Definition: KviUserListView.h:262
#define e
Definition: detector.cpp:69
KviUserListEntry * m_pTopItem
Definition: KviUserListView.h:256
Irc user mask handling.
Definition: KviIrcMask.h:45
bool nickChange(const QString &szOldNick, const QString &szNewNick)
Called when the target changes the nick.
Definition: KviQueryWindow.cpp:396
The class which manages a query.
Definition: KviQueryWindow.h:49
QLabel * m_pUsersLabel
Definition: KviUserListView.h:260
kvi_time_t m_lastActionTime
Definition: KviUserListView.h:163
bool m_bIgnoreScrollBar
Definition: KviUserListView.h:848
Pointer Hash Table.
Definition: KviWindowToolWidget.h:36
KviPointerHashTable< QString, KviUserListEntry > * entryDict()
Returns the entry in the list.
Definition: KviUserListView.h:310
Definition: KviTalToolTip.h:53
int userOpCount()
Returns the number of user operators.
Definition: KviUserListView.h:391
KviUserListEntry * findEntry(const QString &szNick)
Searches an entry in the userlist.
Definition: KviUserListView.h:400
int m_iHalfOpCount
Definition: KviUserListView.h:268
QString szHost
Definition: libkvisetup.cpp:45
unsigned int uVoiced
Definition: KviUserListView.h:85
int m_iOpCount
Definition: KviUserListView.h:267
virtual void resizeEvent(QResizeEvent *)
Definition: KviQueryWindow.cpp:509
virtual void maybeTip(const QPoint &p)
Definition: KviTalToolTip.cpp:102
int m_iChanAdminCount
Definition: KviUserListView.h:266
User list area management.
Definition: KviUserListView.h:817
User DB handling.
unsigned int uHot
Definition: KviUserListView.h:78
Definition: KviWindowToolWidget.h:47
int m_iVoiceCount
Definition: KviUserListView.h:269
unsigned int uTotal
Definition: KviUserListView.h:75
KviUserListEntry * firstItem()
Returns the first item of the user list.
Definition: KviUserListView.h:316
KviPointerHashTable< QString, KviUserListEntry > * m_pEntryDict
Definition: KviUserListView.h:255
Time management.
int m_iSelectedCount
Definition: KviUserListView.h:263
int m_iUserOpCount
Definition: KviUserListView.h:270
KviUserListEntry * m_pTailItem
Definition: KviUserListView.h:258
unsigned int uUserOp
Definition: KviUserListView.h:86
kvi_time_t m_joinTime
Definition: KviUserListView.h:164
void setUserDataBase(KviIrcUserDataBase *pDb)
Sets the user database.
Definition: KviUserListView.h:796
unsigned int uActive
Definition: KviUserListView.h:76
unsigned int uHalfOp
Definition: KviUserListView.h:84
C++ Template based double linked pointer list class.
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
A class to handle the entries of the user database.
Definition: KviIrcUserEntry.h:45
int ircOpCount()
Returns the number of ircops.
Definition: KviUserListView.h:355
QString m_szNick
Definition: KviUserListView.h:159
int halfOpCount()
Returns the number of half operators.
Definition: KviUserListView.h:379
KviAnimatedPixmap * m_pAvatarPixmap
Definition: KviUserListView.h:170
int chanAdminCount()
Returns the number of chan admins.
Definition: KviUserListView.h:367
int m_iIEntries
Definition: KviUserListView.h:276
friend class KviUserListViewArea
Definition: KviUserListView.h:229
KviUserListEntry * m_pIterator
Definition: KviUserListView.h:259
bool m_bSelected
Definition: KviUserListView.h:167
KviUserListEntry * m_pPrev
Definition: KviUserListView.h:169
unsigned int uChanOwner
Definition: KviUserListView.h:81
The class which manages the user database.
Definition: KviIrcUserDataBase.h:45
const QString & nick() const
Returns the nick of the entry.
Definition: KviUserListView.h:189
unsigned int uActiveOp
Definition: KviUserListView.h:77
char szBuffer[4096]
Definition: winamp.cpp:77
int m_ieEntries
Definition: KviUserListView.h:275
This file contains compile time settings.
int m_iLastScrollBarVal
Definition: KviUserListView.h:846
short int flags() const
Returns the flags of the user.
Definition: KviUserListView.h:177
int chanOwnerCount()
Returns the number of chan owners.
Definition: KviUserListView.h:361
short int m_iFlags
Definition: KviUserListView.h:161
User list view management class.
Definition: KviUserListView.h:226
QScrollBar * m_pScrollBar
Definition: KviUserListView.h:845
KviUserListEntry * next()
Returns the next entry in the list.
Definition: KviUserListView.h:195
int voiceCount()
Returns the number of voices.
Definition: KviUserListView.h:385
bool avatarChanged(const QString &szNick)
Called when the target changes the avatar.
Definition: KviQueryWindow.h:201
unsigned int uOp
Definition: KviUserListView.h:83
short int m_iTemperature
Definition: KviUserListView.h:162
Userlist entry management class.
Definition: KviUserListView.h:134
The class which manages a channel.
Definition: KviChannelWindow.h:113