@@ -0,0 +1,84 @@
1+/*
2+ * Copyright (C) 2013 - Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU Lesser General Public License, as
6+ * published by the Free Software Foundation; either version 2.1 or 3.0
7+ * of the License.
8+ *
9+ * This program is distributed in the hope that it will be useful, but
10+ * WITHOUT ANY WARRANTY; without even the implied warranties of
11+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12+ * PURPOSE. See the applicable version of the GNU Lesser General Public
13+ * License for more details.
14+ *
15+ * You should have received a copy of both the GNU Lesser General Public
16+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
17+ *
18+ * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
19+ */
20+
21+#include <QLocale>
22+#include <QTimer>
23+
24+#include "Payments.h"
25+
26+Payments::Payments(QObject *parent)
27+ : QObject(parent)
28+{
29+}
30+
31+QString Payments::currency() const
32+{
33+ return m_currency;
34+}
35+
36+double Payments::price() const
37+{
38+ return m_price;
39+}
40+
41+QString Payments::storeItemId() const
42+{
43+ return m_store_item_id;
44+}
45+
46+QString Payments::formattedPrice() const
47+{
48+ QLocale locale;
49+ return locale.toCurrencyString(m_price, m_currency);
50+}
51+
52+void Payments::setCurrency(const QString ¤cy)
53+{
54+ if(m_currency != currency){
55+ m_currency = currency;
56+ Q_EMIT currencyChanged(currency);
57+ Q_EMIT formattedPriceChanged(formattedPrice());
58+ }
59+}
60+
61+void Payments::setPrice(const double price)
62+{
63+ if(m_price != price){
64+ m_price = price;
65+ Q_EMIT priceChanged(price);
66+ Q_EMIT formattedPriceChanged(formattedPrice());
67+ }
68+}
69+
70+void Payments::setStoreItemId(const QString &store_item_id)
71+{
72+ if(m_store_item_id != store_item_id){
73+ m_store_item_id = store_item_id;
74+ Q_EMIT storeItemIdChanged(store_item_id);
75+ }
76+}
77+
78+void Payments::start()
79+{
80+ qDebug("starting the purchase");
81+ // start the purchase here, raise finished(), error or canceled when done
82+ QTimer::singleShot(3000, this, SIGNAL(finished()));
83+ // FIXME ^^^^
84+}