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

List:       kde-commits
Subject:    branches/KDE/4.3/kdeplasma-addons/applets/microblog
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-07-07 22:51:13
Message-ID: 1247007073.869090.24167.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 992910 by aseigo:

* actually save the "with friends" setting to the config
* refresh the timeline when you dent/tweet
BUG:199286


 M  +31 -7     microblog.cpp  
 M  +3 -0      microblog.h  


--- branches/KDE/4.3/kdeplasma-addons/applets/microblog/microblog.cpp #992909:992910
@@ -69,6 +69,7 @@
       m_newTweets(0),
       m_service(0),
       m_profileService(0),
+      m_statusService(0),
       m_lastTweet(0),
       m_wallet(0),
       m_walletWait(None),
@@ -365,7 +366,7 @@
 
 void MicroBlog::dataUpdated(const QString& source, const Plasma::DataEngine::Data \
&data)  {
-    //kDebug() << source << data.count();
+    //kDebug() << source << data.count() << m_curTimeline;
     if (data.isEmpty()) {
         if (source.startsWith("Error")) {
             m_flash->kill(); //FIXME only clear it if it was showing an error msg
@@ -398,7 +399,11 @@
         //kDebug() << m_lastTweet << maxId << "<-- updated";
         m_lastTweet = maxId;
         m_newTweets = qMin(newCount, m_historySize);
-        m_flash->flash( i18np( "1 new tweet", "%1 new tweets", m_newTweets ), \
20*1000 ); +
+        if (m_newTweets > 0) {
+            m_flash->flash( i18np( "1 new tweet", "%1 new tweets", m_newTweets ), \
20*1000 ); +        }
+
         scheduleShowTweets();
     } else if (source == m_imageQuery) {
         foreach (const QString &user, data.keys()) {
@@ -458,7 +463,6 @@
     // Adjust the number of the TweetWidgets if the configuration has changed
     // Add more tweetWidgets if there are not enough
 
-    //kDebug() << m_tweetMap.count() << m_historySize;
     if (m_tweetMap.count() > m_historySize) {
         QMap<uint, Plasma::DataEngine::Data>::iterator it = m_tweetMap.begin();
         while (it != m_tweetMap.end() && m_tweetMap.count() > m_historySize) {
@@ -670,6 +674,7 @@
         m_includeFriends = includeFriends;
         m_tweetMap.clear();
         m_lastTweet = 0;
+        cg.writeEntry("includeFriends", m_includeFriends);
     }
 
     if (m_historySize != historySize) {
@@ -703,6 +708,7 @@
     delete m_colorScheme;
     delete m_service;
     delete m_profileService;
+    delete m_statusService;
 }
 
 void MicroBlog::editTextChanged()
@@ -738,16 +744,30 @@
 {
     QString status = m_statusEdit->nativeWidget()->toPlainText();
 
-    delete m_service;
-    m_service = m_engine->serviceForSource(m_curTimeline);
+    if (!m_statusService) {
+        m_statusService = m_engine->serviceForSource(m_curTimeline);
+    }
+
     KConfigGroup cg = m_service->operationDescription("update");
     cg.writeEntry("password", m_password);
     cg.writeEntry("status", status);
-    m_service->startOperationCall(cg);
+    //m_statusUpdates.insert(m_service->startOperationCall(cg), status);
+    connect(m_service, SIGNAL(finished(Plasma::ServiceJob*)), this, \
SLOT(updateCompleted(Plasma::ServiceJob*))); +    connect(m_service, \
SIGNAL(finished(Plasma::ServiceJob*)), this, \
SLOT(serviceFinished(Plasma::ServiceJob*)));  
     m_statusEdit->nativeWidget()->setPlainText("");
 }
 
+void MicroBlog::updateCompleted(Plasma::ServiceJob *job)
+{
+    if (!job->error()) {
+        //m_statusUpdates.value(job);
+        downloadHistory();
+    }
+
+    //m_statusUpdates.remove(job);
+}
+
 //what this really means now is 'reconnect to the timeline source'
 void MicroBlog::downloadHistory()
 {
@@ -760,7 +780,7 @@
         return;
     }
 
-    m_flash->flash( i18n("Refreshing timeline..."), -1 );
+    m_flash->flash(i18n("Refreshing timeline..."), -1);
 
     QString query;
     if (m_includeFriends) {
@@ -778,6 +798,10 @@
             m_engine->disconnectSource(m_curTimeline, this);
             m_engine->disconnectSource("Error:" + m_curTimeline, this);
         }
+
+        delete m_statusService;
+        m_statusService = 0;
+
         m_curTimeline = query;
     }
 
--- branches/KDE/4.3/kdeplasma-addons/applets/microblog/microblog.h #992909:992910
@@ -92,6 +92,7 @@
     protected slots:
         void configAccepted();
         void updateStatus();
+        void updateCompleted(Plasma::ServiceJob *job);
         void downloadHistory();
         void openProfile();
         void editTextChanged();
@@ -148,6 +149,7 @@
         QString m_password;
         QString m_serviceUrl;
         QString m_imageQuery;
+        //QHash<Plasma::ServiceJob *, QString> m_statusUpdates;
         int m_historySize;
         int m_historyRefresh;
         int m_newTweets;
@@ -156,6 +158,7 @@
         Plasma::DataEngine *m_engine;
         Plasma::Service *m_service;
         Plasma::Service *m_profileService;
+        Plasma::Service *m_statusService;
         QString m_curTimeline;
 
         QMap<QString, QPixmap> m_pictureMap;


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

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