<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/textured_element.cpp</filename>
    </added>
    <added>
      <filename>src/textured_element.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -153,7 +153,7 @@ void Element::update_stats(void) {
   if( wantedSize &lt; 1.0 )
     wantedSize = 1.0;
 
-  radius = CUTOFF * size * 0.5;
+  radius = CUTOFF * size / 2;
 
   if( showInfo &gt; 0 ) {
     showInfo--;</diff>
      <filename>src/element.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -36,7 +36,7 @@
 /**
         @author Erlend Simonsen &lt;mr@fudgie.org&gt;
 */
-class Element{
+class Element {
 
 public:
   Element() {};
@@ -44,11 +44,12 @@ public:
 
   virtual ~Element();
 
-  void render(GLWidget *gl);
-  void renderRelations(GLWidget *gl);
+  virtual void render(GLWidget *gl);
+  virtual void renderRelations(GLWidget *gl);
 
   void update(GLWidget *gl);
   void update_stats(void);
+
   bool contains(GLWidget *gl, Element *e);
   void repulsive_check(GLWidget *gl, Element *e);
   void attractive_check(GLWidget *gl, Element *e);</diff>
      <filename>src/element.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,10 +19,8 @@
  ***************************************************************************/
 #include &quot;glwidget.h&quot;
 #include &quot;element.h&quot;
+#include &quot;textured_element.h&quot;
 #include &lt;QHash&gt;
-
-using namespace std;
-
 #include &lt;iostream&gt;
 #include &lt;stdlib.h&gt;
 #include &lt;list&gt;
@@ -31,6 +29,8 @@ using namespace std;
 #include &lt;sys/time.h&gt;
 #include &lt;math.h&gt;
 
+using namespace std;
+
 Elements elements;
 Nodes    nodes;
 
@@ -110,7 +110,7 @@ void GLWidget::initializeGL()
    //      glEnable(GL_LIGHTING);
    //      glEnable(GL_LIGHT0);
 
-   glDisable(GL_TEXTURE_2D);
+   glEnable(GL_TEXTURE_2D);
 
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
@@ -136,7 +136,6 @@ void GLWidget::initializeGL()
    glVertex3f(0.0, r, 0.0);
    glEnd();
    glEndList();
-
 }
 
 void GLWidget::paintGL()
@@ -409,12 +408,19 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
   //  cout &lt;&lt; &quot;x: &quot; &lt;&lt; x &lt;&lt; &quot;, y: &quot; &lt;&lt; y &lt;&lt; endl;
 }
 
-void GLWidget::addRelation(Input *h, QString &amp;url, QString &amp;ref, bool external) {
+void GLWidget::addRelation(Input *h, QString &amp;url, QString &amp;ref, bool external, QImage *img) {
 
   if( elements.contains(h-&gt;getDomain() + url) == false ) {
     QColor color = h-&gt;getColor();
-    elements[h-&gt;getDomain() + url] = new Element(h, url, color);
-    nodes.push_back( elements[h-&gt;getDomain() + url] );
+    Element *e;
+    if( img != NULL ) {
+      cout &lt;&lt; &quot;addRelation image[&quot; &lt;&lt; img-&gt;width() &lt;&lt; &quot;x&quot; &lt;&lt; img-&gt;height() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+      e = new TexturedElement(this, h, url, color, img);
+    } else {
+      e = new Element(h, url, color);
+    }
+    elements[h-&gt;getDomain() + url] = e;
+    nodes.push_back( e );
   }
 
   if( ref != &quot;-&quot; &amp;&amp; !ref.isEmpty() ) {</diff>
      <filename>src/glwidget.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -70,7 +70,7 @@ public:
    QSize minimumSizeHint() const;
    QSize sizeHint() const;
 
-   void addRelation(Input *h, QString &amp;url, QString &amp;ref, bool external = false);
+   void addRelation(Input *h, QString &amp;url, QString &amp;ref, bool external = false, QImage *img = NULL);
 
    int  showLines() { return linesMode; };
    bool showForces() const { return forces; };</diff>
      <filename>src/glwidget.h</filename>
    </modified>
    <modified>
      <diff>@@ -20,11 +20,15 @@ using namespace std;
 
 
 Digg::Digg(QObject *parent) {
-  http = new QHttp(this);
+  http = new QHttp(&quot;services.digg.com&quot;, 80, this);
 
-  connect(http, SIGNAL(done(bool)),
-          this, SLOT(parse(bool)) );
+  connect(http, SIGNAL(requestFinished(int,bool)),
+          this, SLOT(parse(int,bool)) );
 
+  httpImages = new QHttp(&quot;digg.com&quot;, 80, this);
+
+  connect(httpImages, SIGNAL(requestFinished(int,bool)),
+          this, SLOT(getImage(int,bool)) );
 
   maxDate = 0;
   curDate = 0;
@@ -46,7 +50,7 @@ void Digg::fetchDiggs( void ) {
   header.setValue(&quot;Host&quot;, &quot;services.digg.com&quot;);
   header.setValue(&quot;User-Agent&quot;, &quot;glTrail v0.01 (http://www.fudgie.org/gltrail.html)&quot; );
 
-  http-&gt;setHost(&quot;services.digg.com&quot;);
+  //  http-&gt;setHost(&quot;services.digg.com&quot;);
 
   cout &lt;&lt; &quot;Fetching[&quot; &lt;&lt; url.toString().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
 
@@ -64,7 +68,7 @@ void Digg::fetchStory( QString story ) {
   header.setValue(&quot;Host&quot;, &quot;services.digg.com&quot;);
   header.setValue(&quot;User-Agent&quot;, &quot;glTrail v0.01 (http://www.fudgie.org/gltrail.html)&quot; );
 
-  http-&gt;setHost(&quot;services.digg.com&quot;);
+  //  http-&gt;setHost(&quot;services.digg.com&quot;);
 
   cout &lt;&lt; &quot;Fetching[&quot; &lt;&lt; url.toString().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
 
@@ -72,23 +76,49 @@ void Digg::fetchStory( QString story ) {
 }
 
 
+void Digg::fetchImage( QString img ) {
+  QUrl url;
+  url.setPath(img );
+
+  QHttpRequestHeader header(&quot;GET&quot;, url.toString() );
+
+  header.setValue(&quot;Host&quot;, &quot;digg.com&quot;);
+  header.setValue(&quot;User-Agent&quot;, &quot;glTrail v0.01 (http://www.fudgie.org/gltrail.html)&quot; );
+
+  //  http-&gt;setHost(&quot;services.digg.com&quot;);
+
+  cout &lt;&lt; &quot;Fetching[&quot; &lt;&lt; url.toString().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+
+  httpImages-&gt;request(header);
+}
+
+
 void Digg::run( void ) {
 
   fetchDiggs();
   forever {
-    if( duggQueue.size() &gt; 0 ) {
+
+    if( duggQueue.size() &gt; 0 &amp;&amp; curDate &gt; 5) {
       cout &lt;&lt; duggQueue.size() &lt;&lt; &quot; pending diggs&quot; &lt;&lt; endl;
 
       Dugg d = duggQueue.first();
 
-      cout &lt;&lt; d.date &lt;&lt; &quot; &lt;=&gt; &quot; &lt;&lt; curDate &lt;&lt; endl;
+      cout &lt;&lt; d.date &lt;&lt; &quot; &lt;= &quot; &lt;&lt; curDate &lt;&lt; endl;
 
       if( d.date &gt; curDate + 5 ) {
         curDate = d.date;
       }
 
       while( d.date &lt;= curDate &amp;&amp; duggQueue.size() &gt; 0 ) {
-        gl-&gt;addRelation(this, d.story, d.user, true);
+
+        if( d.image.isEmpty() ) {
+          gl-&gt;addRelation(this, d.story, d.user, true);
+        } else {
+          if( images[d.image] == NULL )
+            cout &lt;&lt; &quot;Adding rel with MISSING image[&quot; &lt;&lt; d.image.toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+
+          gl-&gt;addRelation(this, d.story, d.user, true, images[d.image] );
+        }
 
         duggQueue.removeFirst();
         if( duggQueue.size() &gt; 0 ) {
@@ -110,16 +140,32 @@ void Digg::run( void ) {
       }
     }
 
-    if( curDate &gt; 0 ) {
-      curDate += 1;
-    }
-
+    curDate += 1;
     sleep(1);
   }
 }
 
-void Digg::parse( bool error ) {
+void Digg::getImage( int id, bool error ) {
+  if(!error) {
+    cout &lt;&lt; &quot;Got image[&quot; &lt;&lt; httpImages-&gt;currentRequest().path().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+    QByteArray buf = httpImages-&gt;readAll();
+    if( !images.contains(httpImages-&gt;currentRequest().path()) ) {
+      QImage *img = new QImage();
+      img-&gt;loadFromData(buf);
+      images.insert( httpImages-&gt;currentRequest().path(), img);
+      cout &lt;&lt; &quot;Added width: &quot; &lt;&lt; img-&gt;width() &lt;&lt; &quot;, height: &quot; &lt;&lt; img-&gt;height() &lt;&lt; endl;
+    } else {
+      cout &lt;&lt; &quot;Already in cache[&quot; &lt;&lt; httpImages-&gt;currentRequest().path().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+    }
+  } else {
+    cout &lt;&lt; &quot;Error getting [&quot; &lt;&lt; httpImages-&gt;currentRequest().path().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+  }
+}
+
+void Digg::parse( int id, bool error ) {
   if( !error ) {
+    cout &lt;&lt; &quot;Got[&quot; &lt;&lt; http-&gt;currentRequest().path().toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+
     QString result = http-&gt;readAll();
     //    cout &lt;&lt; &quot;Got &quot; &lt;&lt; result.toStdString() &lt;&lt; endl;
 
@@ -160,29 +206,35 @@ void Digg::parse( bool error ) {
 
         QString id;
         QString title;
+        QString image;
 
         QString storyPattern(&quot;&lt;story id=\&quot;(\\d+)\&quot; link=\&quot;([^\&quot;]+)\&quot;.*diggs=\&quot;(\\d+)\&quot; comments=\&quot;(\\d+)\&quot;&quot;);
         QString titlePattern(&quot;&lt;title&gt;(.*)&lt;/title&gt;&quot;);
-        //        cout &lt;&lt; &quot;pattern[&quot; &lt;&lt; storyPattern.toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+        QString imagePattern(&quot;&lt;thumbnail .* src=\&quot;([^\&quot;]+)\&quot;&quot;);
 
         QRegExp rx(storyPattern);
         QRegExp rxTitle(titlePattern);
+        QRegExp rxImage(imagePattern);
 
         for( int i = 2; i &lt; lines.size(); i++ ) {
           if( rx.indexIn(lines[i]) &gt; -1 ) {
             id = rx.cap(1);
           } else if( rxTitle.indexIn(lines[i]) &gt; -1 ) {
             title = rxTitle.cap(1);
+          } else if( rxImage.indexIn(lines[i]) &gt; -1 ) {
+            image = rxImage.cap(1);
+            fetchImage(image);
           }
         }
 
-        cout &lt;&lt; &quot;id[&quot; &lt;&lt; id.toStdString() &lt;&lt; &quot;], title[&quot; &lt;&lt; title.toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
+        cout &lt;&lt; &quot;id[&quot; &lt;&lt; id.toStdString() &lt;&lt; &quot;], title[&quot; &lt;&lt; title.toStdString() &lt;&lt; &quot;], image[&quot; &lt;&lt; image.toStdString() &lt;&lt; &quot;]&quot; &lt;&lt; endl;
 
         if( !id.isEmpty() &amp;&amp; !title.isEmpty() ) {
           stories.insert(id, title);
           d.story = title;
+          d.image = image;
+          duggQueue &lt;&lt; d;
         }
-        duggQueue &lt;&lt; d;
       }
     }
 </diff>
      <filename>src/inputs/digg.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@
 #include &lt;QThread&gt;
 #include &lt;QColor&gt;
 #include &lt;QHttp&gt;
+#include &lt;QImage&gt;
 #include &quot;../input.h&quot;
 
 class GLWidget;
@@ -16,6 +17,7 @@ struct Dugg {
   QString story;
   QString user;
   QString status;
+  QString image;
 };
 
 class Digg : public QThread, public Input  {
@@ -30,18 +32,21 @@ class Digg : public QThread, public Input  {
 
   void fetchDiggs();
   void fetchStory(QString story);
+  void fetchImage(QString image);
   void startProcessing() {};
   void endProcessing() {};
 
  public slots:
 
-  void parse(bool);
+  void parse(int,bool);
+  void getImage(int,bool);
 
  protected:
   void run();
 
  private:
   QHttp *http;
+  QHttp *httpImages;
 
   qlonglong maxDate;
   qlonglong curDate;
@@ -49,7 +54,7 @@ class Digg : public QThread, public Input  {
   QList&lt;Dugg&gt; duggQueue;
   QList&lt;Dugg&gt; storiesQueue;
   QHash&lt;QString,QString&gt; stories;
-
+  QHash&lt;QString,QImage *&gt; images;
 };
 
 #endif</diff>
      <filename>src/inputs/digg.h</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ CONFIG += debug
 SOURCES += main.cpp \
            activity.cpp \
            element.cpp \
+           textured_element.cpp \
            window.cpp \
            glwidget.cpp \
            background_updater.cpp \
@@ -14,6 +15,7 @@ SOURCES += main.cpp \
 
 HEADERS += input.h \
            element.h \
+           textured_element.h \
            activity.h \
            relation.h \
            window.h \</diff>
      <filename>src/src.pro</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>39cc0eee427b53a09cf3e1c67aab2a0b3a66a93e</id>
    </parent>
    <parent>
      <id>9e9bc275d8c6740dcf34e0fdb0804667afadddeb</id>
    </parent>
  </parents>
  <author>
    <name>Erlend Simonsen</name>
    <email>mr@fudgie.org</email>
  </author>
  <url>http://github.com/Fudge/gltrail/commit/9acb397527f0a6f79db92fc4f0f211aaf4b7f22d</url>
  <id>9acb397527f0a6f79db92fc4f0f211aaf4b7f22d</id>
  <committed-date>2008-03-25T13:46:24-07:00</committed-date>
  <authored-date>2008-03-25T13:46:24-07:00</authored-date>
  <message>Merge branch 'images'</message>
  <tree>586cd0277be7b0f1b7d1035e5bb1a43c82c44573</tree>
  <committer>
    <name>Erlend Simonsen</name>
    <email>mr@fudgie.org</email>
  </committer>
</commit>
