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