[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-14 18:05:51
Message-ID: 1208196351.683664.24536.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 797011 by scheepmaker:

RSSNOW compiles again... it even runs, but the layouting is seriously broken at the \
moment. I'm working on that.



 M  +8 -16     header.cpp  
 M  +5 -7      header.h  
 M  +13 -12    news.cpp  
 M  +2 -1      news.h  
 M  +12 -17    scroller.cpp  
 M  +7 -8      scroller.h  


--- trunk/playground/base/plasma/applets/rssnow/header.cpp #797010:797011
@@ -23,16 +23,14 @@
 #include <kdebug.h>
 #include <kicon.h>
 #include <QPainter>
-#include <QFont>
-#include <QTimer>
 #include <QStyleOptionGraphicsItem>
-#include <kcursor.h>
+#include <QGraphicsWidget>
 #include <plasma/svg.h>
 
 using namespace Plasma;
 
 Header::Header(QGraphicsItem *parent) :
-        Plasma::Widget(parent),
+        QGraphicsWidget(parent),
         m_icon(0)
 {
     setMaximumSize(QSizeF(600, 48));
@@ -41,22 +39,16 @@
     m_icon = new Plasma::Svg("rssnow/rssnow", this);
     m_icon->resize(96, 48);
     m_icon->setContentType(Plasma::Svg::SingleImage);
-}
 
-Qt::Orientations Header::expandingDirections() const
-{
-    return Qt::Horizontal | Qt::Vertical;
+    setPreferredSize(QSizeF(300, 48));
+    setMinimumSize(QSizeF(96, 48));
+    setMaximumSize(QSizeF(1000, 48));
 }
 
-QSizeF Header::sizeHint() const
+void Header::paint(QPainter *p,
+                   const QStyleOptionGraphicsItem *option,
+                   QWidget *widget)
 {
-    return QSizeF(300, 48);
-}
-
-void Header::paintWidget(QPainter *p,
-                         const QStyleOptionGraphicsItem *option,
-                         QWidget *widget)
-{
     Q_UNUSED(widget);
     Q_UNUSED(option);
 
--- trunk/playground/base/plasma/applets/rssnow/header.h #797010:797011
@@ -20,8 +20,8 @@
 #ifndef HEADER_HEADER
 #define HEADER_HEADER
 
+#include <QGraphicsWidget>
 #include <plasma/plasma_export.h>
-#include <plasma/widgets/widget.h>
 
 namespace Plasma
 {
@@ -29,20 +29,18 @@
 } // namespace Plasma
 
 
-class Header : public Plasma::Widget
+class Header : public QGraphicsWidget
 {
     Q_OBJECT
 
 public:
     Header(QGraphicsItem *parent = 0);
 
-    virtual QSizeF sizeHint() const;
-    virtual Qt::Orientations expandingDirections() const;
 
 protected:
-    virtual void paintWidget(QPainter *p,
-                             const QStyleOptionGraphicsItem *option,
-                             QWidget *widget = 0);
+    virtual void paint(QPainter *p,
+                       const QStyleOptionGraphicsItem *option,
+                       QWidget *widget = 0);
     Plasma::Svg *m_icon;
 };
 
--- trunk/playground/base/plasma/applets/rssnow/news.cpp #797010:797011
@@ -25,6 +25,7 @@
 
 //QT
 #include <QGraphicsSceneDragDropEvent>
+#include <QGraphicsLinearLayout>
 #include <QTimer>
 #include <QPainter>
 #include <QDateTime>
@@ -62,8 +63,7 @@
     m_showdroptarget = cg.readEntry("droptarget", true);
     m_feedlist       = cg.readEntry("feeds", \
QStringList("http://www.kde.org/dotkdeorg.rdf"));  
-    m_layout = new Plasma::VBoxLayout(this);
-    m_layout->setMargin(0);
+    m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
     m_layout->setSpacing(2);
 
     m_header = new Header(this);
@@ -73,9 +73,6 @@
     updateScrollers();
 
     connect(m_timer, SIGNAL(timeout()), this, SLOT(switchItems()));
-
-    //TODO: I don't know why, but sometimes the geometry gets screwed up right
-    //after starting the applet. Look into that.
 }
 
 void News::switchItems()
@@ -123,7 +120,6 @@
         m_dialog->setCaption(i18n("Configure News"));
 
         ui.setupUi(m_dialog->mainWidget());
-        m_dialog->mainWidget()->layout()->setMargin(0);
         m_dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
         connect(m_dialog, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
         connect(m_dialog, SIGNAL(okClicked()), this, SLOT(configAccepted()));
@@ -241,8 +237,9 @@
     m_layout->removeItem(m_header);
     m_header->hide(); //else a weird bug shows up when removing the logo
     while (m_layout->count() > 0) {
-        Plasma::LayoutItem * scroller = m_layout->takeAt(0);
+        QGraphicsLayoutItem * scroller = m_layout->itemAt(0);
         delete scroller;
+        m_layout->removeAt(0);
     }
 
     if (m_logo) {
@@ -270,8 +267,8 @@
         scroller->listUpdated();
     }
 
-    m_layout->setSize(contentSize());
-    m_layout->updateGeometry();
+    m_layout->setGeometry(geometry());
+    //m_layout->updateGeometry();
 
     m_timer->start();
     connectToEngine();
@@ -301,6 +298,9 @@
                 start = 1;
             }
 
+            //ok, let's just temporarily disable this, since this has to be
+            //ported to WoC, and is less trivial at a glance.
+            /**
             for (int i = start; i < (m_layout->count()); i++ ) {
                 QGraphicsItem * item = m_layout->itemAt(i)->graphicsItem();
                 QRectF rect = item->boundingRect();
@@ -316,6 +316,7 @@
                     }
                 }
             }
+            */
 
             KConfigGroup cg = config();
             cg.writeEntry("feeds", m_feedlist);
@@ -335,7 +336,7 @@
             m_showdroptarget = false;
             int minSize = (m_feedlist.size() * \
                m_scrollerList.first()->minimumSize().height());
             kDebug() << "minimum size to contain all scrollers: " << minSize;
-            if (size().height() < minSize) {
+            if (geometry().height() < minSize) {
                 //group all feeds together so it can fit:
                 QString allfeeds;
                 foreach (QString feed, m_feedlist) {
@@ -354,8 +355,8 @@
         }
     }
     if (constraints & Plasma::SizeConstraint) {
-        m_layout->setSize(contentSize());
-        updateGeometry();
+        m_layout->setGeometry(geometry());
+       // updateGeometry();
     }
 }
 #include "news.moc"
--- trunk/playground/base/plasma/applets/rssnow/news.h #797010:797011
@@ -36,6 +36,7 @@
 }
 
 class Scroller;
+class QGraphicsLinearLayout;
 
 class News : public Plasma::Applet
 {
@@ -77,7 +78,7 @@
 
         int                 m_maxAge;
 
-        Plasma::VBoxLayout  *m_layout;
+        QGraphicsLinearLayout  *m_layout;
         Header              *m_header;
         KDialog             *m_dialog;
         Ui::config          ui;
--- trunk/playground/base/plasma/applets/rssnow/scroller.cpp #797010:797011
@@ -41,7 +41,7 @@
 using namespace Plasma;
 
 Scroller::Scroller(QGraphicsItem *parent) :
-        Plasma::Widget(parent),
+        QGraphicsWidget(parent),
         m_animid(0),
         m_current(0),
         m_animdirection(0),
@@ -60,6 +60,7 @@
     setAcceptedMouseButtons(Qt::LeftButton);
     setMaximumSize(QSizeF(600, 64));
     setMinimumSize(QSizeF(100, 32));
+    setPreferredSize(QSizeF(300, 56));
     setAcceptsHoverEvents(true);
 
     m_hovered = false;
@@ -101,11 +102,6 @@
     return m_list;
 }
 
-Qt::Orientations Scroller::expandingDirections() const
-{
-    return Qt::Horizontal | Qt::Vertical;
-}
-
 bool Scroller::hovering()
 {
     return m_hovered;
@@ -194,7 +190,7 @@
     }
 }
 
-void Scroller::doAnimation() 
+void Scroller::doAnimation()
 {
     if (m_list->size() > 1) {
         if (m_animations) {
@@ -283,16 +279,10 @@
     m_itemlist->last()->setZValue(0);
 }
 
-
-QSizeF Scroller::sizeHint() const
+void Scroller::paint(QPainter *p,
+                     const QStyleOptionGraphicsItem *option,
+                     QWidget *widget)
 {
-    return QSizeF(300, 56);
-}
-
-void Scroller::paintWidget(QPainter *p,
-                         const QStyleOptionGraphicsItem *option,
-                         QWidget *widget)
-{
     Q_UNUSED(widget);
     Q_UNUSED(option);
 
@@ -303,7 +293,7 @@
 
 void Scroller::setGeometry(const QRectF &geometry)
 {
-    Widget::setGeometry(geometry);
+    QGraphicsWidget::setGeometry(geometry);
     updateSize();
 }
 
@@ -506,6 +496,11 @@
     }
 }
 
+int Scroller::maxAge()
+{
+    return m_maxAge;
+}
+
 void Scroller::setMaxAge(int maxAge)
 {
     m_maxAge = maxAge;
--- trunk/playground/base/plasma/applets/rssnow/scroller.h #797010:797011
@@ -21,11 +21,11 @@
 #define SCROLLER_HEADER
 
 #include "feeddata.h"
+#include <QList>
+#include <QGraphicsWidget>
 #include <plasma/plasma_export.h>
-#include <plasma/widgets/widget.h>
 #include <plasma/phase.h>
 #include <plasma/dataengine.h>
-#include <QList>
 
 
 class KIcon;
@@ -39,7 +39,7 @@
   class Svg;
 }
 
-class Scroller : public Plasma::Widget
+class Scroller : public QGraphicsWidget
 {
     Q_OBJECT
 
@@ -47,8 +47,6 @@
     Scroller(QGraphicsItem *parent = 0);
     virtual ~Scroller();
 
-    virtual QSizeF sizeHint() const;
-    virtual Qt::Orientations expandingDirections() const;
     virtual void setGeometry(const QRectF &geometry);
 
     QList<FeedData> * list();
@@ -58,6 +56,7 @@
     void setAnimations(bool animations);
     bool animations();
 
+    int  maxAge();
     void setMaxAge(int maxAge);
 
     bool dropTarget();
@@ -69,9 +68,9 @@
     void dataUpdated(const QString& source, const Plasma::DataEngine::Data &data);
 
 protected:
-    virtual void paintWidget(QPainter *p,
-                             const QStyleOptionGraphicsItem *option,
-                             QWidget *widget = 0);
+    virtual void paint(QPainter *p,
+                       const QStyleOptionGraphicsItem *option,
+                       QWidget *widget = 0);
     virtual void wheelEvent (QGraphicsSceneWheelEvent *event);
     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);


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

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