improved web preview removinatings
[quassel.git] / src / qtui / chatitem.h
index 31fdd5e..dd926bb 100644 (file)
@@ -74,8 +74,8 @@ protected:
   virtual inline QVector<QTextLayout::FormatRange> additionalFormats() const { return QVector<QTextLayout::FormatRange>(); }
   qint16 posToCursor(const QPointF &pos);
 
-  inline void ChatItem::setPrivateData(ChatItemPrivate *data) { Q_ASSERT(!_data); _data = data; }
-  inline ChatItemPrivate *ChatItem::privateData() const;
+  inline void setPrivateData(ChatItemPrivate *data) { Q_ASSERT(!_data); _data = data; }
+  inline ChatItemPrivate *privateData() const;
 
   // WARNING: setGeometry and setHeight should not be used without either:
   //  a) calling prepareGeometryChange() immediately before setColumns()
@@ -166,7 +166,10 @@ private:
 
   QList<Clickable> findClickables();
   void endHoverMode();
+  void showWebPreview(const Clickable &click);
+  void clearWebPreview();
 
+  
   // WARNING: setGeometry and setHeight should not be used without either:
   //  a) calling prepareGeometryChange() immediately before setColumns()
   //  b) calling Chatline::setPos() immediately afterwards
@@ -197,12 +200,40 @@ struct ContentsChatItem::Clickable {
 };
 
 struct ContentsChatItemPrivate : ChatItemPrivate {
+  ContentsChatItem *contentsItem;
   QList<ContentsChatItem::Clickable> clickables;
   ContentsChatItem::Clickable currentClickable;
   bool hasDragged;
 
-  ContentsChatItemPrivate(QTextLayout *l, const QList<ContentsChatItem::Clickable> &c) : ChatItemPrivate(l), clickables(c), hasDragged(false) {}
+#ifndef HAVE_WEBKIT
+  ContentsChatItemPrivate(QTextLayout *l, const QList<ContentsChatItem::Clickable> &c, ContentsChatItem *parent) : ChatItemPrivate(l), contentsItem(parent), clickables(c), hasDragged(false) {}
+#else
+  ContentsChatItemPrivate(QTextLayout *l, const QList<ContentsChatItem::Clickable> &c, ContentsChatItem *parent) : ChatItemPrivate(l), contentsItem(parent), clickables(c), hasDragged(false), previewItem(0) {}
+  ~ContentsChatItemPrivate();
+
+  void loadWebPreview(const QString &url, const QRectF &urlRect);
+  void clearWebPreview();
+
+private:
+  class PreviewItem;
+  PreviewItem *previewItem;
+  QString previewUrl;
+  QRectF previewUrlRect;
+#endif //#ifndef HAVE_WEBKIT
+};
+
+#ifdef HAVE_WEBKIT
+class QWebView;
+class ContentsChatItemPrivate::PreviewItem : public QGraphicsItem {
+public:
+  PreviewItem(QWebView *webView);
+  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+  virtual inline QRectF boundingRect() const { return _boundingRect; }
+
+private:
+  QRectF _boundingRect;
 };
+#endif //#ifdef HAVE_WEBKIT
 
 //inlines regarding ContentsChatItemPrivate
 ContentsChatItemPrivate *ContentsChatItem::privateData() const { return (ContentsChatItemPrivate *)ChatItem::privateData(); }
@@ -222,9 +253,6 @@ private:
   qint16 wordidx;
   qint16 lineCount;
   qreal choppedTrailing;
-  qint16 lastwrapcol;
-  qreal lastwrappos;
-  qreal width;
 };
 
 /*************************************************************************************************/