[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:       2009-04-03 17:15:30
Message-ID: 1238778930.837934.16293.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 948749 by gberg:

Remove all tpqt4 stuff from the plasmoid - it should do stuff through the presence \
dataengine, not directly. It will now display the presence correctly for individual \
accounts.

Outstanding Issues:
- Master presence not displayed correctly.
- Cannot set the presence.
- Code is a mess
- Looks fugly.

 M  +1 -5      CMakeLists.txt  
 D             cmake (directory)  
 M  +12 -39    presence.cpp  
 M  +5 -7      presence.h  
 M  +22 -21    presenceitemdelegate.cpp  


--- trunk/playground/base/plasma/applets/presence/CMakeLists.txt #948748:948749
@@ -1,8 +1,6 @@
-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" \
                ${CMAKE_MODULE_PATH})
-project(plasma-presence)
+project(plasma-applet-presence)
 
 find_package(KDE4 REQUIRED)
-find_package (TelepathyQt4 REQUIRED)
 include(KDE4Defaults)
 
 add_definitions(${KDE4_DEFINITIONS})
@@ -11,7 +9,6 @@
 	${CMAKE_CURRENT_SOURCE_DIR}
 	${CMAKE_CURRENT_BINARY_DIR}
 	${KDE4_INCLUDES}
-	${TELEPATHY_QT4_INCLUDE_DIR}
 )
 
 set(presence_SRCS
@@ -22,7 +19,6 @@
 target_link_libraries(plasma_applet_presence 
 	${KDE4_PLASMA_LIBS} 
 	${KDE4_KDEUI_LIBS}
-	${TELEPATHY_QT4_LIBRARIES}
 )
 
 install(TARGETS plasma_applet_presence DESTINATION ${PLUGIN_INSTALL_DIR})
--- trunk/playground/base/plasma/applets/presence/presence.cpp #948748:948749
@@ -1,5 +1,6 @@
 /*
  *   Copyright (C) 2008 George Goldberg <grundleborg@googlemail.com>
+ *   Copyright (C) 2009 Collabora Ltd <http://www.collabora.co.uk>
  *
  *   This library is free software; you can redistribute it and/or
  *   modify it under the terms of the GNU Library General Public
@@ -29,11 +30,6 @@
 #include <KDebug>
 #include <KIcon>
 
-#include <TelepathyQt4/Types>
-#include <TelepathyQt4/Constants>
-#include <TelepathyQt4/Client/PendingReady>
-#include <TelepathyQt4/Client/Account>
-
 #include <QtCore/QList>
 #include <QtCore/QSharedPointer>
 
@@ -56,8 +52,7 @@
     m_accountsModel(0),
     m_accountsView(0),
     m_layout(0),
-    m_userSet(false),
-    m_accountManager(0)
+    m_userSet(false)
 {
     setBackgroundHints(StandardBackground);
 }
@@ -101,15 +96,6 @@
                                    QVariant("status-name"), Qt::DisplayRole);
     m_accountsModel->setHeaderData(3, Qt::Horizontal,
                                    QVariant("status-message"), Qt::DisplayRole);
-    //setup Telepathy Account Manager
-    m_accountManager = new \
                Telepathy::Client::AccountManager(QDBusConnection::sessionBus());
-    
-    QSet<Telepathy::Client::Feature> features;
-    features << Telepathy::Client::AccountManager::FeatureCore;
-    
-    connect(m_accountManager->becomeReady(features),
-            SIGNAL(finished(Telepathy::Client::PendingOperation *)), this,
-            SLOT(onReady(Telepathy::Client::PendingOperation *)));
 
     Q_ASSERT(!m_engine);  // Pointer should still be assigned to 0.
     m_engine = dataEngine("presence");
@@ -126,13 +112,9 @@
             this, SLOT(sourceRemoved(QString)));
 }
 
-void PresenceApplet::onReady(Telepathy::Client::PendingOperation *result)
-{
-
-}
 QWidget *PresenceApplet::widget()
 {
-	if(!m_widget)
+    if(!m_widget)
     {
         // Set up the accounts view.
         Q_ASSERT(!m_accountsView);  // Pointer should still be assigned to 0.
@@ -195,13 +177,13 @@
     kDebug() << "started with source: " << source;
     m_engine->disconnectSource(source, this);
 }
-
+/*
 void PresenceApplet::commitData(QWidget * editor)
 {
     kDebug()<<m_userSet;
     //m_userSet = true;
 }
-
+*/
 void PresenceApplet::dataUpdated(const QString & source,
                             const Plasma::DataEngine::Data & data)
 {
@@ -225,19 +207,9 @@
     presence_state->setData(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
                
     message->setData(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
  
-    // \brief: setup account presence
-    Telepathy::SimplePresence currentPresence
-        = data.value("current_presence").value<Telepathy::SimplePresence>();
-    if (m_currentPresence == currentPresence.status) {
-        return;
-    }
-
-    m_currentPresence = currentPresence.status;
-
-    presence_type->setData(static_cast<uint>(currentPresence.type),
-    						Qt::DisplayRole);
-    presence_state->setData(currentPresence.status, Qt::DisplayRole);
-    message->setData(currentPresence.statusMessage, Qt::DisplayRole);
+    presence_type->setData(data.value("current_presence_type"), Qt::DisplayRole);
+    presence_state->setData(data.value("current_presence_status"), Qt::DisplayRole);
+    message->setData(data.value("current_presence_status_message"), \
Qt::DisplayRole);  accountItem->setData(source, Qt::DisplayRole);
 
     /*
@@ -290,7 +262,7 @@
     // Update the master presence.
     updateMasterPresence();
 }
-
+/*
 void PresenceApplet::onItemChanged(QStandardItem * item)
 {
    QModelIndex index = m_accountsModel->indexFromItem(item);
@@ -314,7 +286,7 @@
     }
 
 }
-
+*/
 /**
  * @brief Update the master presence state.
  *
@@ -377,6 +349,7 @@
 
     // Iterate over all the accounts in the model, and total up how many are
     // in each type of presence state.
+    /* // FIXME: Port to new method
     for(int i=0; i<rowCount; i++)
     {
         Telepathy::ConnectionPresenceType status_type =
@@ -413,7 +386,7 @@
         	break;
         }
     }
-
+*/
     // Chose a master presence state from this.
     // FIXME: What should be the logic for choosing a master presence state?
     //        Shoud this be user customisable?
--- trunk/playground/base/plasma/applets/presence/presence.h #948748:948749
@@ -1,5 +1,6 @@
 /*
  *   Copyright (C) 2008 George Goldberg <grundleborg@googlemail.com>
+ *   Copyright (C) 2009 Collabora Ltd <http://www.collabora.co.uk>
  *
  *   This library is free software; you can redistribute it and/or
  *   modify it under the terms of the GNU Library General Public
@@ -32,8 +33,6 @@
 #include <QtGui/QLabel>
 #include <QtGui/QStandardItemModel>
 
-#include <TelepathyQt4/Client/AccountManager>
-
 class KColorScheme;
 
 class QHBoxLayout;
@@ -60,9 +59,8 @@
                      const Plasma::DataEngine::Data & data);
     void sourceAdded(const QString & source);
     void sourceRemoved(const QString & source);
-    void commitData(QWidget*editor);
-    void onItemChanged(QStandardItem*);
-    void onReady(Telepathy::Client::PendingOperation*);
+//    void commitData(QWidget*editor);
+//    void onItemChanged(QStandardItem*);
 
 private:
     void iconChanged();
@@ -81,7 +79,6 @@
     QTreeView * m_accountsView;
     QVBoxLayout * m_layout;
     QWidget *m_widget;
-    Telepathy::Client::AccountManager* m_accountManager;
     bool m_userSet;
     QString m_currentPresence;
 
@@ -91,5 +88,6 @@
 
 K_EXPORT_PLASMA_APPLET(presence, PresenceApplet)
 
-#endif
 
+#endif  // Include guard
+
--- trunk/playground/base/plasma/applets/presence/presenceitemdelegate.cpp \
#948748:948749 @@ -1,5 +1,6 @@
 /*
  *   Copyright (C) 2008 George Goldberg <grundleborg@googlemail.com>
+ *   Copyright (C) 2009 Collabora Ltd <http://www.collabora.co.uk>
  *
  *   This library is free software; you can redistribute it and/or
  *   modify it under the terms of the GNU Library General Public
@@ -24,9 +25,6 @@
 
 #include <QtGui/QPainter>
 
-#include <TelepathyQt4/Constants>
-#include <TelepathyQt4/Types>
-
 PresenceItemDelegate::PresenceItemDelegate(QWidget * parent)
   : QStyledItemDelegate(parent)
 { }
@@ -36,7 +34,7 @@
                             const QStyleOptionViewItem & option,
                             const QModelIndex & index) const
 {
-
+    kDebug();    // Where are we?
     if(option.state & QStyle::State_Selected)
     {
         painter->fillRect(option.rect, option.palette.highlight());
@@ -45,31 +43,34 @@
     if(index.column() == 1)
     {
         // We are painting the icon.
-    	Telepathy::SimplePresence currentPresence;
-    	index.model()->data(index).fromValue(currentPresence);
+        QString type = index.model()->data(index).toString();
     	
         KIcon icon;
-        switch(currentPresence.type)
+        if((type == "unset") || (type == "offline") || (type == "error"))
         {
-        case Telepathy::ConnectionPresenceTypeAvailable:
-            icon = KIcon("user-online");
-            break;
-        case Telepathy::ConnectionPresenceTypeAway:
+            icon = KIcon("user-offline");
+        }
+        else if(type == "away")
+        {
             icon = KIcon("user-away");
-            break;
-        case Telepathy::ConnectionPresenceTypeExtendedAway:
+        }
+        else if(type == "xa")
+        {
             icon = KIcon("user-away-extended");
-            break;
-        case Telepathy::ConnectionPresenceTypeHidden:
+        }
+        else if(type == "busy")
+        {
+            icon = KIcon("user-busy");
+        }
+        else if(type == "invisible")
+        {
             icon = KIcon("user-invisible");
-            break;
-        case Telepathy::ConnectionPresenceTypeBusy:
-            icon = KIcon("user-busy");
-            break;
-         default:
+        }
+        else
+        {
             icon = KIcon("user-offline");
-            break;
         }
+
         icon.paint(painter, option.rect);
 
         return;


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

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