KVIrc  4.9.2
DeveloperAPIs
KviStatusBarApplet.h
Go to the documentation of this file.
1 #ifndef _KVI_STATUSBARAPPLET_H_
2 #define _KVI_STATUSBARAPPLET_H_
3 //=============================================================================
4 //
5 // File : KviStatusBarApplet.h
6 // Creation date : Tue 07 Sep 2004 03:56:46 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2004 Szymon Stefanek <pragma at kvirc dot net>
10 // Copyright (C) 2008 Elvio Basello <hellvis69 at netsons dor org>
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
28 #include "kvi_settings.h"
29 #include "KviPointerList.h"
30 #include "KviHeapObject.h"
31 #include "KviStatusBar.h"
32 #include "KviPointerHashTable.h"
33 #include "KviHttpRequest.h"
34 
35 #include <QString>
36 #include <QStatusBar>
37 #include <QLabel>
38 #include <QPixmap>
39 
40 class QTimer;
41 class QLabel;
42 class QMenu;
44 class KviMainWindow;
45 class KviIrcContext;
46 class KviIrcConnection;
47 class KviStatusBarApplet;
49 
50 typedef KviStatusBarApplet * (*CreateAppletCallback)(KviStatusBar *, KviStatusBarAppletDescriptor *);
51 
53 {
54  friend class KviStatusBar;
55  friend class KviStatusBarApplet;
56 
57 protected:
58  QString m_szVisibleName; // visible name of the applet
59  QString m_szInternalName; // UNIQUE name of the applet
60  QString m_szPreloadModule; // name of the module that must be preloaded for this applet
61  CreateAppletCallback m_pProc; // creation callback
62  QPixmap * m_pIcon;
63  int m_iId;
65 
66 public:
67  KviStatusBarAppletDescriptor(const QString & szVisibleName,
68  const QString & szInternalName,
70  const QString & szPreloadModule = QString(),
71  const QPixmap & pixIcon = QPixmap());
73 
74 public:
75  const QString & visibleName() { return m_szVisibleName; };
76  const QString & internalName() { return m_szInternalName; };
77  const QString & preloadModule() { return m_szPreloadModule; };
78  int id() { return m_iId; };
79  QPixmap * icon() { return m_pIcon; };
80 protected:
81  KviStatusBarApplet * create(KviStatusBar * pBar);
82  void registerApplet(KviStatusBarApplet * a);
83  void unregisterApplet(KviStatusBarApplet * a);
84 };
85 
86 class KVIRC_API KviStatusBarApplet : public QLabel
87 {
88  friend class KviStatusBar;
89  Q_OBJECT
90 protected:
93  int mIndex;
94 
95 public:
97  virtual ~KviStatusBarApplet();
98 
99 public:
100  KviStatusBar * statusBar() { return m_pStatusBar; };
101  KviMainWindow * frame() { return m_pStatusBar->frame(); };
102  KviStatusBarAppletDescriptor * descriptor() { return m_pDescriptor; };
103  inline void setIndex(int i) { mIndex = i; };
104  inline int index() const { return mIndex; };
105 protected:
106  virtual void fillContextPopup(QMenu *){};
107  virtual void loadState(const char *, KviConfigurationFile *){};
108  virtual void saveState(const char *, KviConfigurationFile *){};
109  virtual QString tipText(const QPoint &);
110 };
111 
112 //this is needed to sort a KviPointerList<KviStatusBarApplet *>
113 inline int kvi_compare(const KviStatusBarApplet * p1, const KviStatusBarApplet * p2)
114 {
115  return p1->index() > p2->index();
116 }
117 
119 {
120  Q_OBJECT
121 public:
123  virtual ~KviStatusBarClock();
124  enum Format
125  {
128  };
129 
130 protected:
131  bool m_bUtc;
132  bool m_b24h;
133  int m_iType;
134 
135 public:
136  static void selfRegister(KviStatusBar * pBar);
137 
138 protected:
139  virtual void fillContextPopup(QMenu * p);
140  virtual void timerEvent(QTimerEvent * e);
141 
142  virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg);
143  virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg);
144  void adjustMinWidth();
145 protected slots:
146  void toggleUtc();
147  void toggle24h();
148  void changeFormat(QAction *);
149 };
150 
152 {
153  Q_OBJECT
154 public:
157 
158 protected:
159  bool m_bTotal;
160 
161 protected:
162  virtual void timerEvent(QTimerEvent * e);
163  virtual void fillContextPopup(QMenu * p);
164  virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg);
165  virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg);
166 
167 public:
168  static void selfRegister(KviStatusBar * pBar);
169 protected slots:
170  void toggleTotal();
171 };
172 
174 {
175  Q_OBJECT
176 public:
178  virtual ~KviStatusBarSeparator();
179 
180 public:
181  static void selfRegister(KviStatusBar * pBar);
182 };
183 
185 {
186  Q_OBJECT
187 public:
189  virtual ~KviStatusBarAwayIndicator();
190 
191 public:
192  static void selfRegister(KviStatusBar * pBar);
193 
194 protected:
196 
197 protected:
198  virtual void mouseDoubleClickEvent(QMouseEvent * e);
199  virtual QString tipText(const QPoint &);
200  virtual void fillContextPopup(QMenu * p);
201  virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg);
202  virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg);
203 protected slots:
204  void updateDisplay();
205  void toggleContext();
206 };
207 
209 {
210  Q_OBJECT
211 public:
213  virtual ~KviStatusBarLagIndicator();
214 
215 public:
216  static void selfRegister(KviStatusBar * pBar);
217 
218 protected:
219  virtual void mouseDoubleClickEvent(QMouseEvent * e);
220  virtual QString tipText(const QPoint &);
221 protected slots:
222  void updateDisplay();
223 };
224 
226 {
227  Q_OBJECT
228 public:
231  static void selfRegister(KviStatusBar * pBar);
232 
233 protected:
234  virtual void mouseDoubleClickEvent(QMouseEvent * e);
235  virtual QString tipText(const QPoint &);
236  virtual void fillContextPopup(QMenu * p);
237  virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg);
238  virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg);
239  void checkVersion();
240  void getNewVersion();
241 protected slots:
242  void updateDisplay();
243  void toggleStartup();
244  void toggleRevision();
245  void responseReceived(const QString &);
246  void requestCompleted(bool status);
247  void binaryDataReceived(const KviDataBuffer &);
248 
249 private:
252  QString m_szNewVersion;
258 };
259 
260 #endif //_KVI_STATUSBARAPPLET_H_
const QString & visibleName()
Definition: KviStatusBarApplet.h:75
Definition: KviHeapObject.h:124
bool m_bAwayOnAllContexts
Definition: KviStatusBarApplet.h:195
virtual void saveState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:507
virtual ~KviStatusBarClock()
Definition: KviMainWindow.h:60
#define KVIRC_API
Definition: kvi_settings.h:128
virtual void timerEvent(QTimerEvent *e)
Definition: KviStatusBarApplet.cpp:404
void adjustMinWidth()
Definition: KviStatusBarApplet.cpp:385
Definition: KviStatusBarApplet.h:126
Definition: KviStatusBarApplet.h:52
virtual ~KviStatusBarLagIndicator()
#define a
Definition: detector.cpp:91
m_iId
Definition: KvsObject_buttonGroup.cpp:62
void updateDisplay()
Definition: KviStatusBarApplet.cpp:657
KviStatusBarApplet *(* CreateAppletCallback)(KviStatusBar *, KviStatusBarAppletDescriptor *)
Definition: KviStatusBarApplet.h:50
virtual void loadState(const char *, KviConfigurationFile *)
Definition: KviStatusBarApplet.h:107
int id()
Definition: KviStatusBarApplet.h:78
Definition: KviStatusBarApplet.h:184
An abstraction of a connection to an IRC server.
Definition: KviIrcConnection.h:95
void requestCompleted(bool status)
Definition: KviStatusBarApplet.cpp:796
virtual ~KviStatusBarAwayIndicator()
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:524
KviStatusBar * statusBar()
Definition: KviStatusBarApplet.h:100
Definition: KviConfigurationFile.h:48
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:190
KviStatusBarUpdateIndicator(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:638
QString m_szNewVersion
Definition: KviStatusBarApplet.h:252
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: KviStatusBarApplet.cpp:741
QString m_szHttpResponse
Definition: KviStatusBarApplet.h:251
int mIndex
Definition: KviStatusBarApplet.h:93
Definition: KviStatusBarApplet.h:225
virtual void loadState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:496
Status Bar class.
Definition: KviStatusBar.h:115
const QString & internalName()
Definition: KviStatusBarApplet.h:76
virtual QString tipText(const QPoint &)
Definition: KviStatusBarApplet.cpp:838
Definition: KviStatusBarApplet.h:118
void updateDisplay()
Definition: KviStatusBarApplet.cpp:324
Definition: KviDataBuffer.h:30
void responseReceived(const QString &)
Definition: KviStatusBarApplet.cpp:752
void toggle24h()
Definition: KviStatusBarApplet.cpp:480
KviStatusBarAppletDescriptor * m_pDescriptor
Definition: KviStatusBarApplet.h:92
virtual void timerEvent(QTimerEvent *e)
Definition: KviStatusBarApplet.cpp:545
KviStatusBar * m_pStatusBar
Definition: KviStatusBarApplet.h:91
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: KviStatusBarApplet.cpp:198
#define e
Definition: detector.cpp:69
virtual void loadState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:170
void toggleRevision()
Definition: KviStatusBarApplet.cpp:670
int index() const
Definition: KviStatusBarApplet.h:104
#define i
Definition: detector.cpp:73
int kvi_compare(const KviStatusBarApplet *p1, const KviStatusBarApplet *p2)
Definition: KviStatusBarApplet.h:113
Pointer Hash Table.
bool m_bTotal
Definition: KviStatusBarApplet.h:159
void setIndex(int i)
Definition: KviStatusBarApplet.h:103
void changeFormat(QAction *)
Definition: KviStatusBarApplet.cpp:487
virtual void fillContextPopup(QMenu *p)
Definition: KviStatusBarApplet.cpp:677
KviStatusBarAppletDescriptor * descriptor()
Definition: KviStatusBarApplet.h:102
Definition: KviStatusBarApplet.h:151
bool m_bUpdateStatus
Definition: KviStatusBarApplet.h:255
Format
Definition: KviStatusBarApplet.h:124
Definition: KviStatusBarApplet.h:127
KviStatusBarLagIndicator(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:249
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:606
CreateAppletCallback m_pProc
Definition: KviStatusBarApplet.h:61
void toggleContext()
Definition: KviStatusBarApplet.cpp:158
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:363
virtual ~KviStatusBarSeparator()
QString m_szVisibleName
Definition: KviStatusBarApplet.h:58
int m_iId
Definition: KviStatusBarApplet.h:63
KviMainWindow * frame()
Definition: KviStatusBarApplet.h:101
void binaryDataReceived(const KviDataBuffer &)
Definition: KviStatusBarApplet.cpp:763
Definition: KviStatusBarApplet.h:208
KviStatusBarAwayIndicator(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:125
void getNewVersion()
Definition: KviStatusBarApplet.cpp:802
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:630
bool m_bCheckFailed
Definition: KviStatusBarApplet.h:254
virtual void fillContextPopup(QMenu *p)
Definition: KviStatusBarApplet.cpp:449
KviStatusBarConnectionTimer(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:532
QString m_szPreloadModule
Definition: KviStatusBarApplet.h:60
virtual void fillContextPopup(QMenu *p)
Definition: KviStatusBarApplet.cpp:580
Definition: KviHttpRequest.h:58
virtual void saveState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:176
virtual void saveState(const char *, KviConfigurationFile *)
Definition: KviStatusBarApplet.h:108
C++ Template based double linked pointer list class.
QPixmap * m_pIcon
Definition: KviStatusBarApplet.h:62
void toggleStartup()
Definition: KviStatusBarApplet.cpp:665
KviStatusBarSeparator(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:614
QPixmap * icon()
Definition: KviStatusBarApplet.h:79
virtual void fillContextPopup(QMenu *)
Definition: KviStatusBarApplet.h:106
Heap Object.
void updateDisplay()
Definition: KviStatusBarApplet.cpp:142
virtual void saveState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:593
KviStatusBarClock(KviStatusBar *pParent, KviStatusBarAppletDescriptor *pDescriptor)
Definition: KviStatusBarApplet.cpp:371
bool m_bUpdateOnStartup
Definition: KviStatusBarApplet.h:256
virtual void saveState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:699
QString m_szInternalName
Definition: KviStatusBarApplet.h:59
Definition: KviStatusBarApplet.h:173
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: KviStatusBarApplet.cpp:262
friend class KviStatusBarApplet
Definition: KviStatusBar.h:117
virtual QString tipText(const QPoint &)
Definition: KviStatusBarApplet.cpp:280
Definition: KviStatusBarApplet.h:86
static void selfRegister(KviStatusBar *pBar)
Definition: KviStatusBarApplet.cpp:714
KVIrc Status Bar management.
const QString & preloadModule()
Definition: KviStatusBarApplet.h:77
virtual QString tipText(const QPoint &)
Definition: KviStatusBarApplet.cpp:215
virtual ~KviStatusBarUpdateIndicator()
virtual ~KviStatusBarConnectionTimer()
int m_iType
Definition: KviStatusBarApplet.h:133
bool m_bUtc
Definition: KviStatusBarApplet.h:131
This file contains compile time settings.
bool m_bCheckDone
Definition: KviStatusBarApplet.h:253
bool m_bUpdateRevision
Definition: KviStatusBarApplet.h:257
KviHttpRequest * m_pHttpRequest
Definition: KviStatusBarApplet.h:250
virtual void loadState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:587
KviPointerList< KviStatusBarApplet > * m_pAppletList
Definition: KviStatusBarApplet.h:64
Definition: KviIrcContext.h:58
#define p
Definition: detector.cpp:80
void checkVersion()
Definition: KviStatusBarApplet.cpp:721
bool m_b24h
Definition: KviStatusBarApplet.h:132
void toggleTotal()
Definition: KviStatusBarApplet.cpp:575
void toggleUtc()
Definition: KviStatusBarApplet.cpp:474
virtual void loadState(const char *pcPrefix, KviConfigurationFile *pCfg)
Definition: KviStatusBarApplet.cpp:688
virtual void fillContextPopup(QMenu *p)
Definition: KviStatusBarApplet.cpp:163