KVIrc  4.9.2
DeveloperAPIs
KviIrcView.h
Go to the documentation of this file.
1 #ifndef _KVI_IRCVIEW_H_
2 #define _KVI_IRCVIEW_H_
3 //=============================================================================
4 //
5 // File : KviIrcView.h
6 // Creation date : Fri Mar 19 1999 05:39:01 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 1999-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 
27 #include "kvi_settings.h"
28 #include "KviCString.h"
29 #include "KviPointerList.h"
30 
31 #include <QToolButton>
32 #include <QWidget>
33 #include <QPixmap> // needed
34 #include <QMultiHash>
35 #include <QDateTime>
36 
37 class QScrollBar;
38 class QLineEdit;
39 class QFile;
40 class QFontMetrics;
41 class QMenu;
42 
43 class KviWindow;
44 class KviMainWindow;
45 class KviConsoleWindow;
47 class KviIrcViewToolTip;
48 class KviAnimatedPixmap;
49 
54 
55 #define KVI_IRCVIEW_INVALID_LINE_MARK_INDEX 0xffffffff
56 
57 class KVIRC_API KviIrcView : public QWidget
58 {
59  Q_OBJECT
60  Q_PROPERTY(int TransparencyCapable READ dummyRead)
61  // we cannot #ifdef due to a bug in moc
62  Q_PROPERTY(bool usePaintOnScreen READ getPaintOnScreen WRITE setPaintOnScreen)
63 public:
64  friend class KviIrcViewToolTip;
65  friend class KviIrcViewToolWidget;
66 
67 public:
68  KviIrcView(QWidget * parent, KviWindow * pWnd);
69  ~KviIrcView();
70 
71 public:
72  int dummyRead() const { return 0; };
73  bool getPaintOnScreen() const { return testAttribute(Qt::WA_PaintOnScreen); };
74  void setPaintOnScreen(bool bFlag) { setAttribute(Qt::WA_PaintOnScreen, bFlag); };
75 private:
76  // QDate m_lastLogDay;
77  int m_iFlushTimer;
79  KviIrcViewLine * m_pCurLine; // Bottom line in the view
82  unsigned int m_uLineMarkLineIndex;
84 
85  // Highliting of links
89 
92 
93  unsigned int m_uNextLineIndex;
94 
96  QScrollBar * m_pScrollBar;
97  QToolButton * m_pToolsButton;
98  QMenu * m_pToolsPopup;
99 
101 
103 
104  // Font related stuff (needs precalculation!)
108  int m_iFontCharacterWidth[256]; //1024 bytes fixed
109 
115 
118 
119  // Selection
125 
129 
134  QFile * m_pLogFile;
141  QFontMetrics * m_pFm; // assume this valid only inside a paint event (may be 0 in other circumstances)
142 
143  QMouseEvent * m_pLastEvent;
144 
148 
149  QMultiHash<KviIrcViewLine *, KviAnimatedPixmap *> m_hAnimatedSmiles;
150 
151 public:
152  void clearUnreaded();
153  void applyOptions();
154  void enableDnd(bool bEnable);
155  bool haveUnreadedMessages() { return m_bHaveUnreadedMessages; };
156  bool haveUnreadedHighlightedMessages() { return m_bHaveUnreadedHighlightedMessages; };
158  {
159  NoRepaint = 1,
160  NoTimestamp = 2,
161  SetLineMark = 4,
162  TriggersNotification = 8
163  };
164  void appendText(int msg_type, const kvi_wchar_t * data_ptr, int iFlags = 0, const QDateTime & datetime = QDateTime());
165  void clearLineMark(bool bRepaint = false);
166  bool hasLineMark() { return m_uLineMarkLineIndex != KVI_IRCVIEW_INVALID_LINE_MARK_INDEX; };
167  void removeHeadLine(bool bRepaint = false);
168  void emptyBuffer(bool bRepaint = true);
169  void getTextBuffer(QString & buffer);
170  void setMaxBufferSize(int maxBufSize, bool bRepaint = true);
171  int maxBufferSize() { return m_iMaxLines; }; //Never used ?
172  bool saveBuffer(const char * filename);
173  void findNext(const QString & szText, bool bCaseS = false, bool bRegExp = false, bool bExtended = false);
174  void findPrev(const QString & szText, bool bCaseS = false, bool bRegExp = false, bool bExtended = false);
175  KviWindow * parentKviWindow() { return m_pKviWindow; };
176  KviConsoleWindow * console();
177  // A null pixmap passed here unsets the private backgrdound.
178  void setPrivateBackgroundPixmap(const QPixmap & pixmap, bool bRepaint = true);
179  bool hasPrivateBackgroundPixmap() { return (m_pPrivateBackgroundPixmap != 0); };
180 
181  //==============================================================================================
182  // Logging
183  // Stops previous logging session too...
184  bool startLogging(const QString & fname = QString(), bool bPrependCurBuffer = false);
185  void stopLogging();
186  bool isLogging() { return (m_pLogFile != 0); };
187  void getLogFileName(QString & buffer);
188  void add2Log(const QString & szBuffer, int iMsgType = 0, bool bPrependDate = false);
189 
190  //==============================================================================================
191  // Channel view splitting
192  void setMasterView(KviIrcView * v);
193  void splitMessagesTo(KviIrcView * v);
194  void joinMessagesFrom(KviIrcView * v);
195  void appendMessagesFrom(KviIrcView * v);
196 
197  // Return true if the specified message type should be "split" to the user message specific view.
198  bool messageShouldGoToMessageView(int iMsgType);
199 
200  void prevLine();
201  void nextLine();
202  void nextPage();
203  void prevPage();
204  virtual QSize sizeHint() const;
205  const QString & lastLineOfText();
206  const QString & lastMessageText();
207  virtual void setFont(const QFont & f);
208  void scrollToMarker();
209 
210 protected:
211  virtual void paintEvent(QPaintEvent *);
212  virtual void resizeEvent(QResizeEvent *);
213  virtual void mousePressEvent(QMouseEvent * e);
214  virtual void mouseReleaseEvent(QMouseEvent *);
215  virtual void mouseDoubleClickEvent(QMouseEvent * e);
216  virtual void mouseMoveEvent(QMouseEvent * e);
217  virtual void timerEvent(QTimerEvent * e);
218  virtual void dragEnterEvent(QDragEnterEvent * e);
219  virtual void dropEvent(QDropEvent * e);
220  virtual bool event(QEvent * e);
221  virtual void wheelEvent(QWheelEvent * e);
222  virtual void keyPressEvent(QKeyEvent * e);
223  void maybeTip(const QPoint & pnt);
224  virtual void leaveEvent(QEvent *);
225 
226 private:
227  void triggerMouseRelatedKvsEvents(QMouseEvent * e);
228  void setCursorLine(KviIrcViewLine * l);
229  void ensureLineVisible(KviIrcViewLine * pLineToShow);
230  KviIrcViewLine * getVisibleLineAt(int yPos);
231  int getVisibleCharIndexAt(KviIrcViewLine * line, int xPos, int yPos);
232  void getLinkEscapeCommand(QString & buffer, const QString & escape_cmd, const QString & escape_label);
233  void appendLine(KviIrcViewLine * ptr, bool bRepaint);
234  void postUpdateEvent();
235  void fastScroll(int lines = 1);
236  const kvi_wchar_t * getTextLine(int msg_type, const kvi_wchar_t * data_ptr, KviIrcViewLine * line_ptr, bool bEnableTimeStamp = true, const QDateTime & datetime = QDateTime());
237  void calculateLineWraps(KviIrcViewLine * ptr, int maxWidth);
238  void recalcFontVariables(const QFontMetrics & fm, const QFontInfo & fi);
239  bool checkSelectionBlock(KviIrcViewLine * line, int bufIndex);
240  KviIrcViewWrappedBlock * getLinkUnderMouse(int xPos, int yPos, QRect * pRect = 0, QString * linkCmd = 0, QString * linkText = 0);
241  void doLinkToolTip(const QRect & rct, QString & linkCmd, QString & linkText);
242  void doMarkerToolTip();
243  bool checkMarkerArea(const QPoint & mousePos);
244  void addControlCharacter(KviIrcViewLineChunk * pC, QString & szSelectionText);
245  void reapplyMessageColors();
246 public slots:
247  void flushLog();
248  void showToolsPopup();
249  void clearBuffer();
250  void toggleToolWidget();
251  void increaseFontSize();
252  void decreaseFontSize();
253  void resetDefaultFont();
254  void chooseFont();
255  void chooseBackground();
256  void resetBackground();
257 protected slots:
258  virtual void scrollBarPositionChanged(int newValue);
259  void masterDead();
260  void animatedIconChange();
261 signals:
262  void rightClicked();
263  void dndEntered();
264  void fileDropped(const QString &);
265 };
266 
267 #endif //_KVI_IRCVIEW_H_
bool m_bPostedPaintEventPending
Definition: KviIrcView.h:138
Definition: KviAnimatedPixmap.h:67
bool m_bMouseIsDown
Definition: KviIrcView.h:126
KviIrcViewLine * m_pLastLine
Definition: KviIrcView.h:80
QScrollBar * m_pScrollBar
Definition: KviIrcView.h:96
AppendTextFlags
Definition: KviIrcView.h:157
Definition: KviIrcView_private.h:108
Definition: KviMainWindow.h:60
Definition: KviConsoleWindow.h:75
KviIrcViewWrappedBlockSelectionInfo * m_pWrappedBlockSelectionInfo
Definition: KviIrcView.h:133
QMenu * m_pToolsPopup
Definition: KviIrcView.h:98
#define KVIRC_API
Definition: kvi_settings.h:128
int m_iSelectionEndCharIndex
Definition: KviIrcView.h:123
#define f
Definition: detector.cpp:70
KviIrcViewToolWidget * m_pToolWidget
Definition: KviIrcView.h:100
int m_iMaxLines
Definition: KviIrcView.h:91
int m_iLastLinkRectHeight
Definition: KviIrcView.h:88
Definition: KviIrcView_private.h:134
int maxBufferSize()
Definition: KviIrcView.h:171
#define l
Definition: detector.cpp:76
int m_iFontDescent
Definition: KviIrcView.h:107
QFontMetrics * m_pFm
Definition: KviIrcView.h:141
int m_iRelativePixmapY
Definition: KviIrcView.h:112
KviMainWindow * m_pFrm
Definition: KviIrcView.h:135
unsigned int m_uNextLineIndex
Definition: KviIrcView.h:93
kvi_u16_t kvi_wchar_t
Definition: KviCString.h:87
QPoint m_mousePressPos
Definition: KviIrcView.h:116
int m_iFontLineSpacing
Definition: KviIrcView.h:105
bool hasPrivateBackgroundPixmap()
Definition: KviIrcView.h:179
Definition: KviIrcView_private.h:100
bool hasLineMark()
Definition: KviIrcView.h:166
#define e
Definition: detector.cpp:69
bool m_bSkipScrollBarRepaint
Definition: KviIrcView.h:130
bool m_bHaveUnreadedHighlightedMessages
Definition: KviIrcView.h:146
QRect m_lineMarkArea
Definition: KviIrcView.h:83
bool getPaintOnScreen() const
Definition: KviIrcView.h:73
int m_iFontLineWidth
Definition: KviIrcView.h:106
bool haveUnreadedHighlightedMessages()
Definition: KviIrcView.h:156
KviIrcView * m_pMasterView
Definition: KviIrcView.h:140
KviIrcViewLine * m_pSelectionInitLine
Definition: KviIrcView.h:120
int m_iUnprocessedPaintEventRequests
Definition: KviIrcView.h:137
int m_iWrapMargin
Definition: KviIrcView.h:110
KviIrcViewLine * m_pCursorLine
Definition: KviIrcView.h:81
Definition: KviIrcView_tools.h:42
int m_iSelectionInitCharIndex
Definition: KviIrcView.h:122
int m_iNumLines
Definition: KviIrcView.h:90
Definition: KviIrcView.h:57
int m_iMinimumPaintWidth
Definition: KviIrcView.h:111
bool m_bShiftPressed
Definition: KviIrcView.h:127
#define KVI_IRCVIEW_INVALID_LINE_MARK_INDEX
Definition: KviIrcView.h:55
QMultiHash< KviIrcViewLine *, KviAnimatedPixmap * > m_hAnimatedSmiles
Definition: KviIrcView.h:149
unsigned int m_uLineMarkLineIndex
Definition: KviIrcView.h:82
int m_iLastScrollBarValue
Definition: KviIrcView.h:102
QPixmap * m_pPrivateBackgroundPixmap
Definition: KviIrcView.h:95
KviWindow * m_pKviWindow
Definition: KviIrcView.h:132
C++ Template based double linked pointer list class.
bool m_bAcceptDrops
Definition: KviIrcView.h:136
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
int m_iIconSideSpacing
Definition: KviIrcView.h:114
A template double linked list of pointers.
Definition: KviPointerList.h:55
KviIrcViewWrappedBlock * m_pLastLinkUnderMouse
Definition: KviIrcView.h:86
QToolButton * m_pToolsButton
Definition: KviIrcView.h:97
KviIrcViewToolTip * m_pToolTip
Definition: KviIrcView.h:145
QFile * m_pLogFile
Definition: KviIrcView.h:134
Definition: KviIrcView_private.h:80
KviIrcViewLine * m_pFirstLine
Definition: KviIrcView.h:78
int m_iSelectTimer
Definition: KviIrcView.h:124
KviWindow * parentKviWindow()
Definition: KviIrcView.h:175
char szBuffer[4096]
Definition: winamp.cpp:77
bool m_bHaveUnreadedMessages
Definition: KviIrcView.h:147
This file contains compile time settings.
#define v
Definition: detector.cpp:86
KviIrcViewLine * m_pSelectionEndLine
Definition: KviIrcView.h:121
int m_iMouseTimer
Definition: KviIrcView.h:131
KviPointerList< KviIrcViewLine > * m_pMessagesStoppedWhileSelecting
Definition: KviIrcView.h:139
bool m_bCtrlPressed
Definition: KviIrcView.h:128
bool isLogging()
Definition: KviIrcView.h:186
bool haveUnreadedMessages()
Definition: KviIrcView.h:155
KviIrcViewLine * m_pCurLine
Definition: KviIrcView.h:79
int m_iIconWidth
Definition: KviIrcView.h:113
void setPaintOnScreen(bool bFlag)
Definition: KviIrcView.h:74
Definition: KviIrcView_tools.h:93
int m_iLastLinkRectTop
Definition: KviIrcView.h:87
QPoint m_mouseCurrentPos
Definition: KviIrcView.h:117
QMouseEvent * m_pLastEvent
Definition: KviIrcView.h:143