1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include <QGraphicsItem>
27 #include "quasselui.h"
34 * Probably makes sense to have ChatLineData be the AbstractUiMsg instead, if it turns out that creating ChatLineData
35 is the expensive part... In that case, we could have a QHash<MsgId, ChatLineData*> in the Client, and ChatLine just
36 gets a data pointer. This would allow us to share most data between AbstractUiMsgs, and ChatLines themselves could
37 be pretty cheap - that'd be a clean solution for having a monitor buffer, highlight buffer etcpp.
43 class ChatLine : public QGraphicsItem, public AbstractUiMsg {
48 virtual QString sender() const;
49 virtual QString text() const;
50 virtual MsgId msgId() const;
51 virtual BufferInfo bufferInfo() const;
52 virtual QDateTime timestamp() const;
54 virtual QRectF boundingRect () const;
55 virtual void paint (QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
58 void setColumnWidths(int tsColWidth, int senderColWidth, int textColWidth);
60 void myMousePressEvent ( QGraphicsSceneMouseEvent * event ) { qDebug() << "press"; mousePressEvent(event); }
63 bool sceneEvent ( QEvent * event );
66 UiStyle::StyledText _styledTimestamp, _styledText, _styledSender;
71 ChatItem *_tsItem, *_senderItem, *_textItem;
72 int _tsColWidth, _senderColWidth, _textColWidth;
75 //! This contains the data of a ChatLine, i.e. mainly the styled message contents.
76 /** By separating ChatLine and ChatLineData, ChatLine itself is very small and we can reuse the
77 * same contents in several ChatLine objects without duplicating data.
82 ChatLineData(const Message &msg);
84 inline UiStyle::StyledText styledSender() const { return _styledSender; }
85 inline UiStyle::StyledText styledTimestamp() const { return _styledTimestamp; }
86 inline UiStyle::StyledText styledText() const { return _styledText; }
88 inline QString sender() const { return _styledSender.text; }
89 inline QString text() const { return _styledText.text; }
90 inline QDateTime timestamp() const { return _timestamp; }
91 inline MsgId msgId() const { return _msgId; }
94 UiStyle::StyledText _styledSender, _styledText, _styledTimestamp;