[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/applets/rssnow
From:       Rob Scheepmaker <r.scheepmaker () student ! utwente ! nl>
Date:       2008-04-10 23:58:47
Message-ID: 1207871927.094224.2951.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 795604 by scheepmaker:

Now the configuration made by dragging and dropping feed urls is also saved.
Next to the title the number of the current item, and the total number of items is \
displayed. The fuzzydate is by default only visible on hover to make for a cleaner \
interface.



 M  +1 -0      feeddata.h  
 M  +3 -0      news.cpp  
 M  +39 -8     scroller.cpp  
 M  +19 -10    single-feed.cpp  
 M  +3 -0      single-feed.h  


--- trunk/playground/base/plasma/applets/rssnow/feeddata.h #795603:795604
@@ -31,6 +31,7 @@
         QString extrainfo;
         KIcon *icon;
         int itemNumber;
+        uint time;
 };
 
 #endif
--- trunk/playground/base/plasma/applets/rssnow/news.cpp #795603:795604
@@ -307,6 +307,9 @@
                 }
             }
 
+            KConfigGroup cg = config();
+            cg.writeEntry("feeds", m_feedlist);
+
             updateScrollers();
             connectToEngine();
         }
--- trunk/playground/base/plasma/applets/rssnow/scroller.cpp #795603:795604
@@ -125,6 +125,7 @@
     if (m_list->size() < 1 && m_droptarget) {
         FeedData data;
         data.title = i18n("Drop a feed here...");
+        data.extrainfo = i18n("Drop a feed here...");
         //TODO: the wording of this phrase could be better:
         data.text = i18n("...to start a new group or drop a feed on an existing \
group to add the feed there");  data.icon = m_feedIcons["generic"];
@@ -191,11 +192,13 @@
     }
 }
 
-void Scroller::doAnimation() {
+void Scroller::doAnimation() 
+{
     if (m_list->size() > 1) {
         if (m_animations) {
             SingleFeedItem * item = new SingleFeedItem(this);
             item->setFeedData(m_list->at(m_current));
+            item->setDisplayExtra(m_hovered);
             item->setZValue(m_itemlist->size() + 1);
             item->show();
             item->setPos(m_animdirection * size().width(), 0);
@@ -361,7 +364,11 @@
         m_right->show();
     }
     m_hovered = true;
-
+    foreach (SingleFeedItem * item, *m_activeitemlist) {
+        item->setDisplayExtra(true);
+        item->update();
+    }
+    update();
 }
 
 void Scroller::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@@ -372,6 +379,11 @@
         m_right->hide();
     }
     m_hovered = false;
+    foreach (SingleFeedItem * item, *m_activeitemlist) {
+        item->setDisplayExtra(false);
+        item->update();
+    }
+    update();
 }
 
 void Scroller::setAnimations(bool animations)
@@ -406,13 +418,8 @@
             data.text = title;
             data.title = feedtitle;
             data.url = url;
+            data.time = timestamp;
 
-            if (timestamp != 0) {
-                QDateTime datetime;
-                datetime.setTime_t(timestamp);
-                data.extrainfo = fuzzyDate(datetime);
-            }
-
             if (!m_feedIcons.contains(icon)) {
                 QPixmap p = QPixmap(icon);
                 if (!p.isNull()) {
@@ -427,8 +434,32 @@
             m_list->append(data);
         }
 
+        //TODO: seperate this and use a timer to update fuzzyDate
+        //every minute.
+        for (int i = 0; i < m_list->size(); i++) {
+            uint timestamp = m_list->at(i).time;
+            if (timestamp != 0) {
+                QDateTime datetime;
+                datetime.setTime_t(timestamp);
+                (*m_list)[i].extrainfo = QString("(%1/%2) %3")
+                                                 .arg(i+1)
+                                                 .arg(m_list->size())
+                                                 .arg(fuzzyDate(datetime));
+            } else {
+                (*m_list)[i].extrainfo = QString("(%1/%2) %3")
+                                                 .arg(i+1)
+                                                 .arg(m_list->size())
+                                                 .arg(m_list->at(i).title);
+            }
+            (*m_list)[i].title = QString("(%1/%2) %3")
+                                         .arg(i+1)
+                                         .arg(m_list->size())
+                                         .arg(m_list->at(i).title);
+        }
+
         FeedData noitems;
         noitems.title = "no items to display";
+        noitems.extrainfo = "no items to display";
         noitems.text = data["title"].toString();
         noitems.icon = m_feedIcons["generic"];
 
--- trunk/playground/base/plasma/applets/rssnow/single-feed.cpp #795603:795604
@@ -44,7 +44,8 @@
     return m_rect;
 }
 
-SingleFeedItem::SingleFeedItem(QGraphicsItem * parent) : QGraphicsItem(parent)
+SingleFeedItem::SingleFeedItem(QGraphicsItem * parent) : QGraphicsItem(parent),
+                                                         m_displayExtra(true)
 {
     m_background = new Plasma::Svg("rssnow/background");
 
@@ -88,9 +89,14 @@
     p->setPen(Plasma::Theme::self()->textColor());
     font.setBold(true);
     p->setFont(font);
+    QString text;
+    if (m_displayExtra) {
+        text = m_feeditem.extrainfo;
+    } else {
+        text = m_feeditem.title;
+    }
     p->drawText(QRectF(22, 2, width - 24, 16),
-                Qt::AlignLeft | Qt::AlignBottom,
-                m_feeditem.title);
+                Qt::AlignLeft | Qt::AlignBottom, text);
 
     //draw text
     font.setBold(false);
@@ -98,13 +104,6 @@
     p->drawText(QRectF(2, 20, width - 4, height - 22),
                 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
                 m_html->toPlainText());
-
-    //draw extra info
-    font.setBold(false);
-    p->setFont(font);
-    p->drawText(QRectF(22, 2, width - 26, 16),
-                Qt::AlignRight | Qt::AlignBottom,
-                m_feeditem.extrainfo);
 }
 
 void SingleFeedItem::setRect(const QRect& rect)
@@ -137,3 +136,13 @@
 {
     return m_feeditem.itemNumber;
 }
+
+void SingleFeedItem::setDisplayExtra(bool extra)
+{
+    m_displayExtra = extra;
+}
+
+bool SingleFeedItem::displayExtra()
+{
+    return m_displayExtra;
+}
--- trunk/playground/base/plasma/applets/rssnow/single-feed.h #795603:795604
@@ -38,6 +38,8 @@
         FeedData feedData();
         void setRect(const QRect& rect);
         int itemNumber();
+        void setDisplayExtra(bool extra);
+        bool displayExtra();
 
         virtual QRectF boundingRect() const;
         virtual void paint(QPainter *p,
@@ -48,6 +50,7 @@
         FeedData m_feeditem;
         Plasma::Svg * m_background;
         QGraphicsTextItem * m_html;
+        bool m_displayExtra;
        // QImage m_htmlImg;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic