+ QRectF _boundingRect;
+
+ SelectionMode _selectionMode;
+ qint16 _selectionStart, _selectionEnd;
+
+ friend class ChatLine;
+};
+
+// ************************************************************
+// TimestampChatItem
+// ************************************************************
+
+//! A ChatItem for the timestamp column
+class TimestampChatItem : public ChatItem {
+public:
+ TimestampChatItem(const qreal &width, const qreal &height, QGraphicsItem *parent) : ChatItem(width, height, QPointF(0, 0), parent) {}
+ enum { Type = ChatScene::TimestampChatItemType };
+ virtual inline int type() const { return Type; }
+ virtual inline ChatLineModel::ColumnType column() const { return ChatLineModel::TimestampColumn; }
+};
+
+// ************************************************************
+// SenderChatItem
+// ************************************************************
+//! A ChatItem for the sender column
+class SenderChatItem : public ChatItem {
+public:
+ SenderChatItem(const qreal &width, const qreal &height, const QPointF &pos, QGraphicsItem *parent) : ChatItem(width, height, pos, parent) {}
+ virtual inline ChatLineModel::ColumnType column() const { return ChatLineModel::SenderColumn; }
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ enum { Type = ChatScene::SenderChatItemType };
+ virtual inline int type() const { return Type; }
+ virtual inline void initLayout(QTextLayout *layout) const {
+ initLayoutHelper(layout, QTextOption::ManualWrap, Qt::AlignRight);
+ doLayout(layout);
+ }
+};
+
+// ************************************************************
+// ContentsChatItem
+// ************************************************************
+struct ContentsChatItemPrivate;
+
+//! A ChatItem for the contents column
+class ContentsChatItem : public ChatItem {
+ Q_DECLARE_TR_FUNCTIONS(ContentsChatItem);
+
+public:
+ ContentsChatItem(const qreal &width, const QPointF &pos, QGraphicsItem *parent);
+ ~ContentsChatItem();
+
+ enum { Type = ChatScene::ContentsChatItemType };
+ virtual inline int type() const { return Type; }
+
+ inline ChatLineModel::ColumnType column() const { return ChatLineModel::ContentsColumn; }
+ inline QFontMetricsF *fontMetrics() const { return _fontMetrics; }
+
+protected:
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void handleClick(const QPointF &pos, ChatScene::ClickMode clickMode);
+
+ virtual void addActionsToMenu(QMenu *menu, const QPointF &itemPos);
+ virtual void copyLinkToClipboard();
+
+ virtual QVector<QTextLayout::FormatRange> additionalFormats() const;
+
+ virtual inline void initLayout(QTextLayout *layout) const {
+ initLayoutHelper(layout, QTextOption::WrapAnywhere);
+ doLayout(layout);
+ }
+ virtual void doLayout(QTextLayout *layout) const;
+
+private:
+ struct Clickable;
+ class ActionProxy;
+ class WrapColumnFinder;
+
+ ContentsChatItemPrivate *_data;
+ ContentsChatItemPrivate *privateData() const;
+
+ QList<Clickable> findClickables() const;
+ Clickable clickableAt(const QPointF &pos) const;
+
+ void endHoverMode();
+ void showWebPreview(const Clickable &click);
+ void clearWebPreview();
+
+ qreal setGeometryByWidth(qreal w);
+ friend class ChatLine;
+ friend struct ContentsChatItemPrivate;
+
+ QFontMetricsF *_fontMetrics;
+
+ // we need a receiver for Action signals
+ static ActionProxy _actionProxy;
+};
+
+struct ContentsChatItem::Clickable {
+ // Don't change these enums without also changing the regexps in analyze()!
+ enum Type {
+ Invalid = -1,
+ Url = 0,
+ Channel = 1,
+ Nick = 2
+ };
+
+ Type type;
+ quint16 start;
+ quint16 length;
+
+ inline Clickable() : type(Invalid) {};
+ inline Clickable(Type type_, quint16 start_, quint16 length_) : type(type_), start(start_), length(length_) {};
+ inline bool isValid() const { return type != Invalid; }