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

List:       kde-commits
Subject:    playground/base/plasma/applets/presence
From:       George Goldberg <grundleborg () googlemail ! com>
Date:       2008-07-05 13:40:40
Message-ID: 1215265240.525719.9381.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 828344 by gberg:

Get the presence applet working again with current plasma API.


 M  +1 -1      CMakeLists.txt  
 M  +50 -51    presence.cpp  
 M  +15 -16    presence.h  


--- trunk/playground/base/plasma/applets/presence/CMakeLists.txt #828343:828344
@@ -8,7 +8,7 @@
     presence.cpp)
 
 kde4_add_plugin(plasma_applet_presence ${presence_SRCS})
-target_link_libraries(plasma_applet_presence  ${PLASMA_LIBS} decibel \
${KDE4_KDEUI_LIBS}) +target_link_libraries(plasma_applet_presence plasmaappletdialog \
${PLASMA_LIBS} decibel ${KDE4_KDEUI_LIBS})  
 install(TARGETS plasma_applet_presence DESTINATION ${PLUGIN_INSTALL_DIR})
 install(FILES plasma-applet-presence.desktop DESTINATION ${SERVICES_INSTALL_DIR})
--- trunk/playground/base/plasma/applets/presence/presence.cpp #828343:828344
@@ -20,86 +20,84 @@
 #include "presence.h"
 
 #include <plasma/theme.h>
+#include <plasma/widgets/icon.h>
 
-#include <QPainter>
 #include <QString>
 #include <QStandardItemModel>
 #include <QTreeView>
 #include <QHeaderView>
-#include <QGraphicsProxyWidget>
-#include <QGraphicsLinearLayout>
-#include <QGraphicsWidget>
+#include <QWidget>
 #include <QList>
+#include <QVBoxLayout>
 
 #include <KLineEdit>
 #include <KDebug>
 #include <KColorScheme>
+#include <KIcon>
 
 Presence::Presence(QObject *parent, const QVariantList &args)
-    : Plasma::Applet(parent, args),
+    : PlasmaAppletDialog(parent, args),
     m_accountsModel(0),
     m_accountsView(0),
-    m_accountsViewProxyWidget(0),
-    m_messageEditProxyWidget(0),
     m_messageEdit(0)
 {
     m_layout = 0;
-    m_form = 0;
+    m_widget = 0;
 }
 
-void Presence::init() 
+void Presence::initialize()
 {
-    setHasConfigurationInterface(false);
+    kDebug() << "Initializing applet.";
+    // Set up the icon.
+    m_icon = new Plasma::Icon(KIcon("utilities-terminal"), QString(), this);
 
-    /*
-     * set up the accounts model.
-     */
+    // Set up the accounts model.
     m_accountsModel = new QStandardItemModel(this);
     m_accountsModel->setColumnCount(4);
     m_accountsModel->setHeaderData(1, Qt::Horizontal, QVariant("online?"), \
                Qt::DisplayRole);
     m_accountsModel->setHeaderData(2, Qt::Horizontal, QVariant("status"), \
                Qt::DisplayRole);
     m_accountsModel->setHeaderData(3, Qt::Horizontal, QVariant("message"), \
Qt::DisplayRole);  
-    /*
-     * set up the accounts view.
-     */
-    m_accountsView = new QTreeView;
-    m_accountsView->setModel(m_accountsModel);
-    m_accountsView->header()->setVisible(true);
-    m_accountsView->setColumnHidden(0, true);   //Hide the source id column
+    m_engine = dataEngine("presence");
 
-    /*
-     * set up the rest of the view/layout etc. stuff
-     */
-    m_accountsViewProxyWidget = new QGraphicsProxyWidget(this);
-    m_accountsViewProxyWidget->setWidget(m_accountsView);
-    m_accountsView->show();
-    m_accountsViewProxyWidget->show();
-    m_messageEdit = new KLineEdit;
-    m_messageEditProxyWidget = new QGraphicsProxyWidget(this);
-    m_messageEditProxyWidget->setWidget(m_messageEdit);
-    m_messageEdit->show();
-    m_messageEditProxyWidget->show();
+    QStringList sources = m_engine->sources();
+    foreach(const QString & source, sources)
+    {
+        sourceAdded(source);
+    }
 
-    m_form = new QGraphicsWidget(this);
-    m_layout = new QGraphicsLinearLayout(Qt::Vertical, m_form);
-    m_layout->addItem(m_accountsViewProxyWidget);
-    m_layout->addItem(m_messageEditProxyWidget);
-    m_form->setLayout(m_layout);
+    connect(m_engine, SIGNAL(sourceAdded(QString)), this, \
SLOT(sourceAdded(QString))); +    connect(m_engine, SIGNAL(sourceRemoved(QString)), \
this, SLOT(sourceRemoved(QString))); +}
 
-    updateGeometry();
+QWidget * Presence::widget()
+{
+    if(!m_widget)
+    {
+        // Set up the accounts view.
+        m_accountsView = new QTreeView;
+        m_accountsView->setModel(m_accountsModel);
+        m_accountsView->header()->setVisible(true);
+        m_accountsView->setColumnHidden(0, true);   //Hide the source id column
 
-    m_engine = dataEngine("presence");
+        // Set up the rest of the view/layout etc. stuff.
+        m_messageEdit = new KLineEdit;
 
-    connect(m_engine, SIGNAL(sourceAdded(QString)), this, \
                SLOT(sourceAdded(QString)));
-    connect(m_engine, SIGNAL(sourceRemoved(QString)), this, \
SLOT(sourceRemoved(QString))); +        m_widget = new QWidget();
+        m_layout = new QVBoxLayout(m_widget);
+        m_layout->addWidget(m_accountsView);
+        m_layout->addWidget(m_messageEdit);
+        m_widget->setLayout(m_layout);
+    }
+
+    return m_widget;
 }
 
 Presence::~Presence()
 {
 
 }
-
+/*
 void Presence::constraintsEvent(Plasma::Constraints constraints)
 {
     if (constraints & Plasma::SizeConstraint) {
@@ -111,23 +109,24 @@
             update();
         }
     }
-}
-
+}*/
+/*
 QSizeF Presence::contentSizeHint() const
 {
     if (m_layout) {
         kDebug() << "Returning the m_form size geometry";
         return m_form->effectiveSizeHint(Qt::PreferredSize, contentSize());
-    }
+    }*/
     /*
      * this is the hardcoded default size
      * of the plasmoid. (apparently not...)
      */
     // FIXME: change this to be a good size...
+    /*
     return QSizeF(300, 300);
 }
+*/
 
-
 void Presence::sourceAdded(const QString& source)
 {
     kDebug() << "started with source: " << source;
@@ -155,9 +154,9 @@
     QStandardItem *online = new QStandardItem;
     QStandardItem *status = new QStandardItem;
     QStandardItem *message = new QStandardItem;
-    online->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
-    status->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
-    message->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
+    //online->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
+    //status->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
+    //message->setData(Plasma::Theme::self()->textColor(), Qt::ForegroundRole);
     QString decibelCurrentPresence = \
data.value("decibel_current_presence").toString();  if(decibelCurrentPresence == "1")
     {
@@ -222,12 +221,12 @@
         kDebug() << "ERROR: two or more rows for the same data source in the \
model!";  }
 }
-
+/*
 void Presence::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, \
const QRect &contentsRect)  {
     Q_UNUSED(p);
     Q_UNUSED(option);
     Q_UNUSED(contentsRect);
 }
-
+*/
 #include "presence.moc"
--- trunk/playground/base/plasma/applets/presence/presence.h #828343:828344
@@ -17,10 +17,10 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-#ifndef PRESENCE_H
-#define PRESENCE_H
+#ifndef PLASMA_APPLET_PRESENCE_H
+#define PLASMA_APPLET_PRESENCE_H
 
-#include <plasma/applet.h>
+#include <plasmaappletdialog.h>
 #include <plasma/dataengine.h>
 
 #include <QGraphicsItem>
@@ -28,22 +28,22 @@
 class QString;
 class QStandardItemModel;
 class QTreeView;
-class QGraphicsProxyWidget;
-class QGraphicsLinearLayout;
-class QGraphicsWidget;
+class QVBoxLayout;
+class QWidget;
 
 class KLineEdit;
 
-class Presence : public Plasma::Applet
+class Presence : public PlasmaAppletDialog
 {
         Q_OBJECT
     public:
         Presence(QObject *parent, const QVariantList &args);
         ~Presence();
 
-        QSizeF contentSizeHint() const;
-        virtual void init(void);
-        void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect); +     //   QSizeF contentSizeHint() const;
+      //  virtual void init(void);
+     //   void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect); +        QWidget * widget();
 
     private slots:
         void sourceAdded(const QString& source);
@@ -51,17 +51,16 @@
         void dataUpdated(const QString &source, const Plasma::DataEngine::Data \
&data);  
     protected:
-        void constraintsEvent(Plasma::Constraints constraints);
-
+     //   void constraintsEvent(Plasma::Constraints constraints);
+        void initialize();
     private:
-        QGraphicsLinearLayout* m_layout;
+        QVBoxLayout* m_layout;
         Plasma::DataEngine* m_engine;
         QStandardItemModel *m_accountsModel;
         QTreeView *m_accountsView;
-        QGraphicsProxyWidget *m_accountsViewProxyWidget;
-        QGraphicsProxyWidget *m_messageEditProxyWidget;
-        QGraphicsWidget *m_form;
+        QWidget * m_widget;
         KLineEdit *m_messageEdit;
+
 };
 
 K_EXPORT_PLASMA_APPLET(presence, Presence)


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

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