← Back to team overview

ayatana-commits team mailing list archive

[Branch ~agateau/libindicate-qt/trunk] Rev 100: - Use the new set_property_* setters

 

------------------------------------------------------------
revno: 100
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: libindicate-qt
timestamp: Wed 2010-02-10 17:34:32 +0100
message:
  - Use the new set_property_* setters
  - Added getters for int, bool and dateTime
modified:
  src/qindicateindicator.cpp
  src/qindicateindicator.h


--
lp:libindicate-qt
https://code.launchpad.net/~agateau/libindicate-qt/trunk

Your team ayatana-commits is subscribed to branch lp:libindicate-qt.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/libindicate-qt/trunk/+edit-subscription.
=== modified file 'src/qindicateindicator.cpp'
--- src/qindicateindicator.cpp	2010-02-10 15:46:12 +0000
+++ src/qindicateindicator.cpp	2010-02-10 16:34:32 +0000
@@ -107,12 +107,16 @@
 
 void Indicator::setIndicatorProperty(const QString& key, bool value)
 {
-    setIndicatorProperty(key, QString(value ? "true" : "false"));
+    indicate_indicator_set_property_bool(
+        INDICATE_INDICATOR(d->mGIndicator),
+        key.toUtf8().data(), value);
 }
 
 void Indicator::setIndicatorProperty(const QString& key, int value)
 {
-    setIndicatorProperty(key, QString::number(value));
+    indicate_indicator_set_property_int(
+        INDICATE_INDICATOR(d->mGIndicator),
+        key.toUtf8().data(), value);
 }
 
 QByteArray Indicator::indicatorProperty(const QString& key) const
@@ -121,6 +125,24 @@
     return QByteArray(value);
 }
 
+QDateTime Indicator::dateTimeIndicatorProperty(const QString& key) const
+{
+    const gchar* value = indicate_indicator_get_property(d->mGIndicator, key.toUtf8().data());
+    return Decode::dateTimeFromValue(value);
+}
+
+int Indicator::intIndicatorProperty(const QString& key, int defaultValue) const
+{
+    const GValue* value = indicate_indicator_get_property_value(d->mGIndicator, key.toUtf8().data());
+    return value ? g_value_get_int(value) : defaultValue;
+}
+
+bool Indicator::boolIndicatorProperty(const QString& key, bool defaultValue) const
+{
+    const GValue* value = indicate_indicator_get_property_value(d->mGIndicator, key.toUtf8().data());
+    return value ? g_value_get_boolean(value) : defaultValue;
+}
+
 static void propertyList_helper(gchar* _item, QStringList* list)
 {
     *list << QString::fromUtf8(_item);
@@ -163,7 +185,7 @@
 
 QDateTime Indicator::timeProperty() const
 {
-    return Decode::dateTimeFromValue(indicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_TIME));
+    return dateTimeIndicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_TIME);
 }
 
 void Indicator::setTimeProperty(const QDateTime& value)
@@ -183,7 +205,7 @@
 
 int Indicator::countProperty() const
 {
-    return Decode::intFromValue(indicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_COUNT));
+    return intIndicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_COUNT);
 }
 
 void Indicator::setCountProperty(int value)
@@ -198,7 +220,7 @@
 
 bool Indicator::drawAttentionProperty() const
 {
-    return Decode::boolFromValue(indicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION));
+    return boolIndicatorProperty(INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION);
 }
 
 void Indicator::emitDisplay()

=== modified file 'src/qindicateindicator.h'
--- src/qindicateindicator.h	2009-09-16 08:38:45 +0000
+++ src/qindicateindicator.h	2010-02-10 16:34:32 +0000
@@ -43,6 +43,9 @@
     void setIndicatorProperty(const QString& key, bool value);
 
     QByteArray indicatorProperty(const QString& key) const;
+    QDateTime dateTimeIndicatorProperty(const QString& key) const;
+    int intIndicatorProperty(const QString& key, int defaultValue=0) const;
+    bool boolIndicatorProperty(const QString& key, bool defaultValue=false) const;
 
     /**
      * Convenience method to define icon