ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00164
[Branch ~agateau/libindicate-qt/trunk] Rev 86: Added bool and int property getters/setters.
------------------------------------------------------------
revno: 86
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: libindicate-qt
timestamp: Mon 2009-09-14 11:52:28 +0200
message:
Added bool and int property getters/setters.
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 2009-09-14 09:44:41 +0000
+++ src/qindicateindicator.cpp 2009-09-14 09:52:28 +0000
@@ -95,12 +95,41 @@
value.data());
}
+void Indicator::setIndicatorProperty(const QString& key, bool value)
+{
+ setIndicatorProperty(key, value ? "true" : "false");
+}
+
+void Indicator::setIndicatorProperty(const QString& key, int value)
+{
+ setIndicatorProperty(key, QString::number(value));
+}
+
QString Indicator::indicatorProperty(const QString& key) const
{
const gchar* value = indicate_indicator_get_property(d->mGIndicator, key.toUtf8().data());
return QString::fromUtf8(value);
}
+bool Indicator::indicatorProperty(const QString& key, bool defaultValue) const
+{
+ QString str = indicatorProperty(key);
+ if (str == "true") {
+ return true;
+ }
+ if (str == "false") {
+ return false;
+ }
+ return defaultValue;
+}
+
+int Indicator::indicatorProperty(const QString& key, int defaultValue) const
+{
+ bool ok = false;
+ int value = indicatorProperty(key).toInt(&ok);
+ return ok ? value : defaultValue;
+}
+
static void propertyList_helper(gchar* _item, QStringList* list)
{
*list << QString::fromUtf8(_item);
@@ -132,22 +161,22 @@
int Indicator::countProperty() const
{
- return indicatorProperty("count").toInt();
+ return indicatorProperty("count", 0);
}
void Indicator::setCountProperty(int value)
{
- setIndicatorProperty("count", QString::number(value));
+ setIndicatorProperty("count", value);
}
void Indicator::setDrawAttentionProperty(bool value)
{
- setIndicatorProperty("draw_attention", value ? "true" : "false");
+ setIndicatorProperty("draw_attention", value);
}
bool Indicator::drawAttentionProperty() const
{
- return indicatorProperty("draw_attention") == "true";
+ return indicatorProperty("draw_attention", false);
}
void Indicator::emitDisplay()
=== modified file 'src/qindicateindicator.h'
--- src/qindicateindicator.h 2009-09-14 09:44:41 +0000
+++ src/qindicateindicator.h 2009-09-14 09:52:28 +0000
@@ -41,7 +41,11 @@
*/
void setIndicatorProperty(const QString& key, const QDateTime& value);
void setIndicatorProperty(const QString& key, const QImage& value);
+ void setIndicatorProperty(const QString& key, int value);
+ void setIndicatorProperty(const QString& key, bool value);
QString indicatorProperty(const QString& key) const;
+ int indicatorProperty(const QString& key, int defaultValue) const;
+ bool indicatorProperty(const QString& key, bool defaultValue) const;
/**
* Convenience method to define count