[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-11 0:46:56
Message-ID: 1207874816.775804.3645.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 795609 by scheepmaker:

The user can now configure a maximum age in hours for items. Items older then this are not displayed.



 M  +50 -3     config.ui  
 M  +5 -0      news.cpp  
 M  +2 -0      news.h  
 M  +27 -15    scroller.cpp  
 M  +4 -0      scroller.h  


--- trunk/playground/base/plasma/applets/rssnow/config.ui #795608:795609
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>399</width>
-    <height>332</height>
+    <height>407</height>
    </rect>
   </property>
   <property name="styleSheet" >
@@ -175,6 +175,53 @@
     </layout>
    </item>
    <item>
+    <layout class="QHBoxLayout" >
+     <item>
+      <widget class="QLabel" name="label_6" >
+       <property name="text" >
+        <string>Maximum age of items (0 for no limit)</string>
+       </property>
+       <property name="buddy" >
+        <cstring>intervalSpinBox</cstring>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QSpinBox" name="maxAge" >
+       <property name="minimum" >
+        <number>0</number>
+       </property>
+       <property name="maximum" >
+        <number>525600</number>
+       </property>
+       <property name="value" >
+        <number>0</number>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_7" >
+       <property name="text" >
+        <string>hours</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
     <widget class="QCheckBox" name="logo" >
      <property name="text" >
       <string>Show RSSNOW logo</string>
@@ -195,8 +242,8 @@
      </property>
      <property name="sizeHint" >
       <size>
-       <width>20</width>
-       <height>40</height>
+       <width>381</width>
+       <height>16</height>
       </size>
      </property>
     </spacer>
--- trunk/playground/base/plasma/applets/rssnow/news.cpp #795608:795609
@@ -57,6 +57,7 @@
     m_interval       = cg.readEntry("interval", 30);
     m_switchInterval = cg.readEntry("switchInterval", 10);
     m_logo           = cg.readEntry("logo", true);
+    m_maxAge         = cg.readEntry("maxAge", 0);
     m_animations     = cg.readEntry("animations", true);
     m_showdroptarget = cg.readEntry("droptarget", true);
     m_feedlist       = cg.readEntry("feeds", QStringList("http://www.kde.org/dotkdeorg.rdf"));
@@ -202,6 +203,7 @@
 {
     m_interval = ui.intervalSpinBox->value();
     m_switchInterval = ui.switchInterval->value();
+    m_maxAge = ui.maxAge->value();
     m_logo = ui.logo->isChecked();
     m_animations = ui.animations->isChecked();
 
@@ -221,6 +223,7 @@
     cg.writeEntry("switchInterval", m_switchInterval);
     cg.writeEntry("animations", m_animations);
     cg.writeEntry("logo", m_logo);
+    cg.writeEntry("maxAge", m_maxAge);
 
     updateScrollers();
 }
@@ -248,6 +251,7 @@
         m_layout->addItem(scroller);
         m_scrollerList.append(scroller);
         scroller->setAnimations(m_animations);
+        scroller->setMaxAge(m_maxAge);
         scroller->listUpdated();
     }
 
@@ -257,6 +261,7 @@
         m_scrollerList.append(scroller);
         scroller->setAnimations(m_animations);
         scroller->setDropTarget(true);
+        scroller->setMaxAge(m_maxAge);
         scroller->listUpdated();
     }
 
--- trunk/playground/base/plasma/applets/rssnow/news.h #795608:795609
@@ -72,6 +72,8 @@
         bool                m_logo;
         bool                m_showdroptarget;
 
+        int                 m_maxAge;
+
         Plasma::VBoxLayout  *m_layout;
         Header              *m_header;
         KDialog             *m_dialog;
--- trunk/playground/base/plasma/applets/rssnow/scroller.cpp #795608:795609
@@ -48,6 +48,7 @@
         m_animations(true),
         m_delayedNext(0),
         m_delayedPrev(0),
+        m_maxAge(0),
         m_droptarget(false),
         m_list(new QList<FeedData>()),
         m_itemlist(new QList<SingleFeedItem *>()),
@@ -412,26 +413,32 @@
             QString icon = item["icon"].toString();
             QString feedtitle = item["feed_title"].toString();
             QString feedurl = item["feed_url"].toString();
+
             uint timestamp = item["time"].toUInt();
+            QDateTime datetime;
+            datetime.setTime_t(timestamp);
 
-            FeedData data;
-            data.text = title;
-            data.title = feedtitle;
-            data.url = url;
-            data.time = timestamp;
+            if (!(timestamp > 0 &&  m_maxAge > 0 &&  //Only add if not too old
+                datetime.addSecs(m_maxAge * 3600) < QDateTime::currentDateTime())) {
+                FeedData data;
+                data.text = title;
+                data.title = feedtitle;
+                data.url = url;
+                data.time = timestamp;
 
-            if (!m_feedIcons.contains(icon)) {
-                QPixmap p = QPixmap(icon);
-                if (!p.isNull()) {
-                    m_feedIcons[icon] = new KIcon(p.scaled(16, 16));
-                } else {
-                    m_feedIcons[icon] = m_feedIcons["generic"];
+                if (!m_feedIcons.contains(icon)) {
+                    QPixmap p = QPixmap(icon);
+                    if (!p.isNull()) {
+                        m_feedIcons[icon] = new KIcon(p.scaled(16, 16));
+                    } else {
+                        m_feedIcons[icon] = m_feedIcons["generic"];
+                    }
                 }
+
+                data.icon = m_feedIcons[icon];
+                data.itemNumber = m_list->size();
+                m_list->append(data);
             }
-
-            data.icon = m_feedIcons[icon];
-            data.itemNumber = m_list->size();
-            m_list->append(data);
         }
 
         //TODO: seperate this and use a timer to update fuzzyDate
@@ -492,7 +499,12 @@
     }
 }
 
+void Scroller::setMaxAge(int maxAge)
+{
+    m_maxAge = maxAge;
+}
 
+
 #include "scroller.moc"
 #endif // SCROLLER_CPP
 
--- trunk/playground/base/plasma/applets/rssnow/scroller.h #795608:795609
@@ -60,6 +60,8 @@
     void setAnimations(bool animations);
     bool animations();
 
+    void setMaxAge(int maxAge);
+
     bool dropTarget();
     void setDropTarget(bool droptarget);
 
@@ -102,6 +104,8 @@
     int m_delayedNext;
     int m_delayedPrev;
 
+    int m_maxAge;
+
     bool m_droptarget;
 
     QList<FeedData> *m_list;
[prev in list] [next in list] [prev in thread] [next in thread] 

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