Cache ChatLine layout data for visible chatlines
[quassel.git] / src / qtui / chatline.h
index a7c68e8..4536520 100644 (file)
@@ -35,6 +35,8 @@ public:
            const QPointF &senderPos, const QPointF &contentsPos,
            QGraphicsItem *parent = 0);
 
            const QPointF &senderPos, const QPointF &contentsPos,
            QGraphicsItem *parent = 0);
 
+  virtual ~ChatLine();
+
   virtual inline QRectF boundingRect () const { return QRectF(0, 0, _width, _height); }
 
   inline QModelIndex index() const { return model()->index(row(), 0); }
   virtual inline QRectF boundingRect () const { return QRectF(0, 0, _width, _height); }
 
   inline QModelIndex index() const { return model()->index(row(), 0); }
@@ -44,7 +46,7 @@ public:
 
   inline const QAbstractItemModel *model() const { return _model; }
   inline ChatScene *chatScene() const { return qobject_cast<ChatScene *>(scene()); }
 
   inline const QAbstractItemModel *model() const { return _model; }
   inline ChatScene *chatScene() const { return qobject_cast<ChatScene *>(scene()); }
-  inline ChatView *chatView() const { return chatScene()->chatView(); }
+  inline ChatView *chatView() const { return chatScene() ? chatScene()->chatView() : 0; }
 
   inline qreal width() const { return _width; }
   inline qreal height() const { return _height; }
 
   inline qreal width() const { return _width; }
   inline qreal height() const { return _height; }
@@ -69,6 +71,8 @@ public:
   void setSelected(bool selected, ChatLineModel::ColumnType minColumn = ChatLineModel::ContentsColumn);
   void setHighlighted(bool highlighted);
 
   void setSelected(bool selected, ChatLineModel::ColumnType minColumn = ChatLineModel::ContentsColumn);
   void setHighlighted(bool highlighted);
 
+  void clearCache();
+
 protected:
   virtual bool sceneEvent(QEvent *event);
 
 protected:
   virtual bool sceneEvent(QEvent *event);