← Back to team overview

ayatana-commits team mailing list archive

[Branch ~agateau/libindicate-qt/trunk] Rev 82: Added convenience method to get/set count and draw_attention properties

 

------------------------------------------------------------
revno: 82
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: libindicate-qt-v2api
timestamp: Fri 2009-09-11 17:50:33 +0200
message:
  Added convenience method to get/set count and draw_attention properties
modified:
  src/qindicateindicator.cpp
  src/qindicateindicator.h
  tests/indicatortest.cpp
  tests/indicatortest.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	2009-09-11 15:30:23 +0000
+++ src/qindicateindicator.cpp	2009-09-11 15:50:33 +0000
@@ -135,6 +135,26 @@
     return indicate_indicator_get_id(d->mGIndicator);
 }
 
+int Indicator::countProperty() const
+{
+    return property("count").toInt();
+}
+
+void Indicator::setCountProperty(int value)
+{
+    setProperty("count", QString::number(value));
+}
+
+void Indicator::setDrawAttentionProperty(bool value)
+{
+    setProperty("draw_attention", value ? "true" : "false");
+}
+
+bool Indicator::drawAttentionProperty() const
+{
+    return property("draw_attention") == "true";
+}
+
 void Indicator::emitDisplay()
 {
     indicate_indicator_user_display(d->mGIndicator);

=== modified file 'src/qindicateindicator.h'
--- src/qindicateindicator.h	2009-09-11 15:30:23 +0000
+++ src/qindicateindicator.h	2009-09-11 15:50:33 +0000
@@ -45,6 +45,26 @@
     QString property(const QString& key) const;
 
     /**
+     * Convenience method to define count
+     */
+    void setCountProperty(int);
+
+    /**
+     * Convenience method to read count
+     */
+    int countProperty() const;
+
+    /**
+     * Convenience method to define draw_attention
+     */
+    void setDrawAttentionProperty(bool);
+
+    /**
+     * Convenience method to read draw_attention
+     */
+    bool drawAttentionProperty() const;
+
+    /**
      * Returns a list containing all the property keys
      */
     QStringList propertyList() const;

=== modified file 'tests/indicatortest.cpp'
--- tests/indicatortest.cpp	2009-09-11 15:30:23 +0000
+++ tests/indicatortest.cpp	2009-09-11 15:50:33 +0000
@@ -79,6 +79,30 @@
     QCOMPARE(lst, expected);
 }
 
+void IndicatorTest::testCount()
+{
+    QIndicate::Indicator indicator;
+    QCOMPARE(indicator.countProperty(), 0);
+
+    indicator.setProperty("count", "1");
+    QCOMPARE(indicator.countProperty(), 1);
+
+    indicator.setCountProperty(2);
+    QCOMPARE(indicator.countProperty(), 2);
+}
+
+void IndicatorTest::testDrawAttention()
+{
+    QIndicate::Indicator indicator;
+    QVERIFY(!indicator.drawAttentionProperty());
+
+    indicator.setProperty("draw_attention", "true");
+    QVERIFY(indicator.drawAttentionProperty());
+
+    indicator.setDrawAttentionProperty(false);
+    QVERIFY(!indicator.drawAttentionProperty());
+}
+
 void IndicatorTest::testDisplay()
 {
     QIndicate::Indicator indicator;

=== modified file 'tests/indicatortest.h'
--- tests/indicatortest.h	2009-09-10 11:22:49 +0000
+++ tests/indicatortest.h	2009-09-11 15:50:33 +0000
@@ -27,6 +27,8 @@
     void testAddRemove();
     void testProperties();
     void testDisplay();
+    void testCount();
+    void testDrawAttention();
 
 private:
     QIndicate::Server* mServer;