← Back to team overview

ayatana-commits team mailing list archive

[Branch ~agateau/plasma-widget-message-indicator/trunk] Rev 115: Fixes broken count and needs-attention.

 

------------------------------------------------------------
revno: 115
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-widget-message-indicator
timestamp: Tue 2010-02-16 11:25:12 +0100
message:
  Fixes broken count and needs-attention.
  
  - Fetch all properties at once instead of queueing them.
  - Handle bool and int properties.
modified:
  src/listenermodel.cpp
  src/listenermodel.h


--
lp:plasma-widget-message-indicator
https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk

Your team ayatana-commits is subscribed to branch lp:plasma-widget-message-indicator.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk/+edit-subscription.
=== modified file 'src/listenermodel.cpp'
--- src/listenermodel.cpp	2009-09-28 09:06:26 +0000
+++ src/listenermodel.cpp	2010-02-16 10:25:12 +0000
@@ -56,20 +56,19 @@
     void updateIndicatorItem(QStandardItem* item)
     {
         QStringList outdatedKeyList = item->data(OutdatedKeyListRole).toStringList();
-        Q_ASSERT(!outdatedKeyList.isEmpty());
-        QString key = outdatedKeyList.takeFirst();
-        item->setData(QVariant(outdatedKeyList), OutdatedKeyListRole);
-
-        QIndicate::Listener::Server* server = item->parent()->data(ServerRole).value<QIndicate::Listener::Server*>();
-        QIndicate::Listener::Indicator* indicator = item->data(IndicatorRole).value<QIndicate::Listener::Indicator*>();
-
-        mListener->getIndicatorProperty(server, indicator, key,
-                                        q, SLOT(slotPropertyReceived(
-                                                QIndicate::Listener::Server*,
-                                                QIndicate::Listener::Indicator*,
-                                                const QString&,
-                                                const QByteArray&))
-                                        );
+        item->setData(QVariant(QStringList()), OutdatedKeyListRole);
+        Q_FOREACH(const QString& key, outdatedKeyList) {
+            QIndicate::Listener::Server* server = item->parent()->data(ServerRole).value<QIndicate::Listener::Server*>();
+            QIndicate::Listener::Indicator* indicator = item->data(IndicatorRole).value<QIndicate::Listener::Indicator*>();
+
+            mListener->getIndicatorPropertyAsVariant(server, indicator, key,
+                                                     q, SLOT(slotPropertyReceived(
+                                                             QIndicate::Listener::Server*,
+                                                             QIndicate::Listener::Indicator*,
+                                                             const QString&,
+                                                             const QVariant&))
+                                                     );
+        }
     }
 
     void removeIndicatorItem(QStandardItem* item) {
@@ -315,7 +314,7 @@
 void ListenerModel::slotPropertyReceived(QIndicate::Listener::Server* server,
                                          QIndicate::Listener::Indicator* indicator,
                                          const QString& key,
-                                         const QByteArray& value)
+                                         const QVariant& value)
 {
     QStandardItem* item = d->mItemForIndicator.value(ServerIndicatorPair(server, indicator));
     if (!item) {
@@ -324,32 +323,28 @@
     }
 
     if (key == INDICATE_INDICATOR_MESSAGES_PROP_NAME) {
-        item->setText(QIndicate::Decode::stringFromValue(value));
+        QByteArray data = value.toByteArray();
+        item->setText(QIndicate::Decode::stringFromValue(data));
     } else if (key == INDICATE_INDICATOR_MESSAGES_PROP_ICON) {
-        QImage image = QIndicate::Decode::imageFromValue(value);
+        QByteArray data = value.toByteArray();
+        QImage image = QIndicate::Decode::imageFromValue(data);
         QPixmap pix = QPixmap::fromImage(image);
         item->setData(KIcon(pix), Qt::DecorationRole);
     } else if (key == INDICATE_INDICATOR_MESSAGES_PROP_TIME) {
-        QDateTime dateTime = QIndicate::Decode::dateTimeFromValue(value);
+        QByteArray data = value.toByteArray();
+        QDateTime dateTime = QIndicate::Decode::dateTimeFromValue(data);
         item->setData(QVariant(dateTime), IndicatorDateTimeRole);
     } else if (key == INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION) {
-        QVariant oldAttention = item->data(IndicatorDrawAttentionRole).toBool();
-        bool attention = QIndicate::Decode::boolFromValue(value);
-        item->setData(QVariant(attention), IndicatorDrawAttentionRole);
-        if (oldAttention != attention) {
+        QVariant old = item->data(IndicatorDrawAttentionRole);
+        item->setData(value, IndicatorDrawAttentionRole);
+        if (old != value) {
             emit drawAttentionChanged(indexFromItem(item));
         }
     } else if (key == INDICATE_INDICATOR_MESSAGES_PROP_COUNT) {
-        int count = QIndicate::Decode::intFromValue(value);
-        item->setData(QVariant(count), CountRole);
+        item->setData(value, CountRole);
     } else {
         kWarning() << "Unhandled key" << key;
     }
-
-    QStringList outdatedKeyList = item->data(OutdatedKeyListRole).toStringList();
-    if (!outdatedKeyList.isEmpty()) {
-        d->updateIndicatorItem(item);
-    }
 }
 
 #include "listenermodel.moc"

=== modified file 'src/listenermodel.h'
--- src/listenermodel.h	2009-09-28 09:06:26 +0000
+++ src/listenermodel.h	2010-02-16 10:25:12 +0000
@@ -63,7 +63,7 @@
     void slotPropertyReceived(QIndicate::Listener::Server*,
                               QIndicate::Listener::Indicator*,
                               const QString& key,
-                              const QByteArray& value);
+                              const QVariant& value);
 
 private:
     ListenerModelPrivate* const d;