- inline const QAbstractItemModel *model() const;
- inline int row() const;
- virtual ChatLineModel::ColumnType column() const = 0;
- inline ChatScene *chatScene() const { return qobject_cast<ChatScene *>(scene()); }
-
- inline QRectF boundingRect() const { return _boundingRect; }
- inline qreal width() const { return _boundingRect.width(); }
- inline qreal height() const { return _boundingRect.height(); }
-
- QTextLayout *createLayout(QTextOption::WrapMode, Qt::Alignment = Qt::AlignLeft) const;
- virtual void doLayout();
- void clearLayout();
-
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- enum { Type = ChatScene::ChatItemType };
- virtual inline int type() const { return Type; }
-
- QVariant data(int role) const;
-
- // selection stuff, to be called by the scene
- QString selection() const;
- void clearSelection();
- void setFullSelection();
- void continueSelecting(const QPointF &pos);
- bool hasSelection() const;
- bool isPosOverSelection(const QPointF &pos) const;
-
- QList<QRectF> findWords(const QString &searchWord, Qt::CaseSensitivity caseSensitive);
-
- virtual void handleClick(const QPointF &pos, ChatScene::ClickMode);
+ const QAbstractItemModel* model() const;
+ ChatLine* chatLine() const;
+ ChatScene* chatScene() const;
+ ChatView* chatView() const;
+ int row() const;
+ virtual ChatLineModel::ColumnType column() const = 0;
+
+ // The boundingRect() is relative to the parent ChatLine
+ inline QRectF boundingRect() const;
+ inline qreal width() const;
+ inline qreal height() const;
+ inline QPointF pos() const;
+ inline qreal x() const;
+ inline qreal y() const;
+
+ QPointF mapToLine(const QPointF&) const;
+ QPointF mapFromLine(const QPointF&) const;
+ QPointF mapToScene(const QPointF&) const;
+ QPointF mapFromScene(const QPointF&) const;
+
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
+ virtual inline int type() const { return ChatScene::ChatItemType; }
+
+ QVariant data(int role) const;
+
+ // selection stuff, to be called by the scene
+ QString selection() const;
+ void clearSelection();
+ void setFullSelection();
+ void continueSelecting(const QPointF& pos);
+ bool hasSelection() const;
+ bool isPosOverSelection(const QPointF& pos) const;
+
+ QList<QRectF> findWords(const QString& searchWord, Qt::CaseSensitivity caseSensitive);
+
+ virtual void addActionsToMenu(QMenu* menu, const QPointF& itemPos);
+ virtual void handleClick(const QPointF& pos, ChatScene::ClickMode);
+
+ void initLayoutHelper(QTextLayout* layout, QTextOption::WrapMode, Qt::Alignment = Qt::AlignLeft) const;
+
+ //! Remove internally cached data
+ /** This removes e.g. the cached QTextLayout to avoid wasting space for nonvisible ChatLines
+ */
+ virtual void clearCache();