alkimia  8.0.3
alkquoteitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2011 Alvaro Soliverez asoliverez@kde.org *
3  * *
4  * This file is part of libalkimia. *
5  * *
6  * libalkimia is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public License *
8  * as published by the Free Software Foundation; either version 2.1 of *
9  * the License or (at your option) version 3 or any later version. *
10  * *
11  * libalkimia is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program. If not, see <http://www.gnu.org/licenses/> *
18  ***************************************************************************/
19 
20 #include "alkquoteitem.h"
21 
23 {
24 public:
25  QString m_symbol;
26  QDateTime m_dateTime;
37  QString m_id;
38 };
39 
41  : QObject(parent)
42  , d(new Private)
43 {
44 }
45 
47 {
48 }
49 
50 AlkQuoteItem::AlkQuoteItem(const AlkQuoteItem &item, QObject *parent)
51  : QObject(parent)
52  , d(new Private)
53 {
54  setSymbol(item.symbol());
55  setDateTime(item.dateTime());
56  setCurrentValue(item.currentValue());
57  setOpeningValue(item.openingValue());
58  setHighValue(item.highValue());
59  setLowValue(item.lowValue());
60  setClosingValue(item.closingValue());
61  setVolume(item.volume());
62  setMarketCap(item.marketCap());
63  setEarningsPerShare(item.earningsPerShare());
64  setChangeToday(item.changeToday());
65  setEbitda(item.ebitda());
66  setRecordId(item.recordId());
67 }
68 
69 const QString &AlkQuoteItem::symbol() const
70 {
71  return d->m_symbol;
72 }
73 
74 const QDateTime &AlkQuoteItem::dateTime() const
75 {
76  return d->m_dateTime;
77 }
78 
80 {
81  return d->m_currentValue;
82 }
83 
85 {
86  return d->m_openingValue;
87 }
88 
90 {
91  return d->m_highValue;
92 }
93 
95 {
96  return d->m_lowValue;
97 }
98 
100 {
101  return d->m_closingValue;
102 }
103 
105 {
106  return d->m_volume;
107 }
108 
110 {
111  return d->m_marketCap;
112 }
113 
115 {
116  return d->m_earnings;
117 }
118 
120 {
121  return d->m_changeToday;
122 }
123 
125 {
126  return d->m_ebitda;
127 }
128 
129 const QString &AlkQuoteItem::recordId() const
130 {
131  return d->m_id;
132 }
133 
134 void AlkQuoteItem::setSymbol(const QString &symbol)
135 {
136  d->m_symbol = symbol;
137 }
138 
139 void AlkQuoteItem::setDateTime(const QDateTime &dateTime)
140 {
141  d->m_dateTime = dateTime;
142 }
143 
145 {
146  d->m_currentValue = value;
147 }
148 
150 {
151  d->m_openingValue = value;
152 }
153 
155 {
156  d->m_highValue = value;
157 }
158 
160 {
161  d->m_lowValue = value;
162 }
163 
165 {
166  d->m_closingValue = value;
167 }
168 
170 {
171  d->m_marketCap = value;
172 }
173 
175 {
176  d->m_volume = value;
177 }
178 
180 {
181  d->m_earnings = value;
182 }
183 
185 {
186  d->m_changeToday = value;
187 }
188 
190 {
191  d->m_ebitda = value;
192 }
193 
194 void AlkQuoteItem::setRecordId(const QString &recordId)
195 {
196  d->m_id = recordId;
197 }
198 
199 QDBusArgument &operator<<(QDBusArgument &argument, const AlkQuoteItem &item)
200 {
201  argument.beginStructure();
202  argument << item.symbol() << item.dateTime().toString(Qt::ISODate)
203  << item.currentValue().toString()
204  << item.openingValue().toString()
205  << item.highValue().toString() << item.lowValue().toString()
206  << item.closingValue().toString()
207  << item.marketCap().toString() << item.volume().toString()
208  << item.earningsPerShare().toString()
209  << item.changeToday().toString() << item.ebitda().toString() << item.recordId();
210  argument.endStructure();
211  return argument;
212 }
213 
214 const QDBusArgument &operator>>(const QDBusArgument &argument, AlkQuoteItem &item)
215 {
216  argument.beginStructure();
217  QString symbol;
218  QString dateTime;
219  QString currentValue;
220  QString openingValue;
221  QString highValue;
222  QString lowValue;
223  QString closingValue;
224  QString marketCap;
225  QString volume;
226  QString earnings;
227  QString change;
228  QString ebitda;
229  QString recordId;
230 
231  argument >> symbol >> dateTime >> currentValue >> openingValue >> highValue >> lowValue
232  >> closingValue >> marketCap >> volume >> earnings >> change >> ebitda >> recordId;
233  item.setSymbol(symbol);
234  item.setDateTime(QDateTime::fromString(dateTime, Qt::ISODate));
235  item.setCurrentValue(AlkValue(currentValue, '.'));
236  item.setOpeningValue(AlkValue(openingValue, '.'));
237  item.setHighValue(AlkValue(highValue, '.'));
238  item.setLowValue(AlkValue(lowValue, '.'));
239  item.setClosingValue(AlkValue(closingValue, '.'));
240  item.setMarketCap(AlkValue(marketCap, '.'));
241  item.setVolume(AlkValue(volume, '.'));
242  item.setEarningsPerShare(AlkValue(earnings, '.'));
243  item.setChangeToday(AlkValue(change, '.'));
244  item.setEbitda(AlkValue(ebitda, '.'));
245  item.setRecordId(recordId);
246 
247  argument.endStructure();
248  return argument;
249 }
AlkQuoteItem::openingValue
const AlkValue & openingValue() const
Definition: alkquoteitem.cpp:84
AlkQuoteItem::setEarningsPerShare
void setEarningsPerShare(const AlkValue &value)
Definition: alkquoteitem.cpp:179
AlkQuoteItem::Private::m_changeToday
AlkValue m_changeToday
Definition: alkquoteitem.cpp:51
AlkQuoteItem::volume
const AlkValue & volume() const
Definition: alkquoteitem.cpp:104
AlkQuoteItem::setDateTime
void setDateTime(const QDateTime &datetime)
Definition: alkquoteitem.cpp:139
AlkQuoteItem::setClosingValue
void setClosingValue(const AlkValue &value)
Definition: alkquoteitem.cpp:164
AlkQuoteItem::setEbitda
void setEbitda(const AlkValue &value)
Definition: alkquoteitem.cpp:189
operator>>
const QDBusArgument & operator>>(const QDBusArgument &argument, AlkQuoteItem &item)
Definition: alkquoteitem.cpp:214
AlkQuoteItem::highValue
const AlkValue & highValue() const
Definition: alkquoteitem.cpp:89
AlkQuoteItem::Private::m_dateTime
QDateTime m_dateTime
Definition: alkquoteitem.cpp:43
AlkQuoteItem::marketCap
const AlkValue & marketCap() const
Definition: alkquoteitem.cpp:109
AlkQuoteItem::setChangeToday
void setChangeToday(const AlkValue &value)
Definition: alkquoteitem.cpp:184
AlkQuoteItem::AlkQuoteItem
AlkQuoteItem(QObject *parent=0)
Definition: alkquoteitem.cpp:40
AlkQuoteItem::Private::m_symbol
QString m_symbol
Definition: alkquoteitem.cpp:42
alkquoteitem.h
AlkQuoteItem::changeToday
const AlkValue & changeToday() const
Definition: alkquoteitem.cpp:119
AlkQuoteItem::setHighValue
void setHighValue(const AlkValue &value)
Definition: alkquoteitem.cpp:154
AlkQuoteItem::closingValue
const AlkValue & closingValue() const
Definition: alkquoteitem.cpp:99
AlkQuoteItem::currentValue
const AlkValue & currentValue() const
Definition: alkquoteitem.cpp:79
AlkQuoteItem::Private::m_closingValue
AlkValue m_closingValue
Definition: alkquoteitem.cpp:48
AlkQuoteItem::symbol
const QString & symbol() const
Definition: alkquoteitem.cpp:69
AlkQuoteItem::Private::m_openingValue
AlkValue m_openingValue
Definition: alkquoteitem.cpp:45
AlkQuoteItem::Private::m_lowValue
AlkValue m_lowValue
Definition: alkquoteitem.cpp:47
AlkQuoteItem::Private::m_volume
AlkValue m_volume
Definition: alkquoteitem.cpp:49
AlkQuoteItem::setLowValue
void setLowValue(const AlkValue &value)
Definition: alkquoteitem.cpp:159
operator<<
QDBusArgument & operator<<(QDBusArgument &argument, const AlkQuoteItem &item)
Definition: alkquoteitem.cpp:199
AlkQuoteItem::setSymbol
void setSymbol(const QString &symbol)
Definition: alkquoteitem.cpp:134
AlkQuoteItem::Private::m_highValue
AlkValue m_highValue
Definition: alkquoteitem.cpp:46
AlkQuoteItem::ebitda
const AlkValue & ebitda() const
Definition: alkquoteitem.cpp:124
AlkQuoteItem::setRecordId
void setRecordId(const QString &recordId)
Definition: alkquoteitem.cpp:194
AlkQuoteItem::setOpeningValue
void setOpeningValue(const AlkValue &value)
Definition: alkquoteitem.cpp:149
AlkQuoteItem::Private::m_ebitda
AlkValue m_ebitda
Definition: alkquoteitem.cpp:53
AlkQuoteItem::earningsPerShare
const AlkValue & earningsPerShare() const
Definition: alkquoteitem.cpp:114
AlkQuoteItem
Definition: alkquoteitem.h:36
AlkQuoteItem::~AlkQuoteItem
~AlkQuoteItem()
Definition: alkquoteitem.cpp:46
AlkQuoteItem::Private::m_id
QString m_id
Definition: alkquoteitem.cpp:54
AlkQuoteItem::setMarketCap
void setMarketCap(const AlkValue &value)
Definition: alkquoteitem.cpp:169
AlkQuoteItem::d
Private *const d
Definition: alkquoteitem.h:143
AlkQuoteItem::Private
Definition: alkquoteitem.cpp:23
AlkQuoteItem::lowValue
const AlkValue & lowValue() const
Definition: alkquoteitem.cpp:94
AlkQuoteItem::Private::m_marketCap
AlkValue m_marketCap
Definition: alkquoteitem.cpp:50
AlkQuoteItem::recordId
const QString & recordId() const
Definition: alkquoteitem.cpp:129
AlkQuoteItem::Private::m_currentValue
AlkValue m_currentValue
Definition: alkquoteitem.cpp:44
AlkQuoteItem::Private::m_earnings
AlkValue m_earnings
Definition: alkquoteitem.cpp:52
AlkValue
AlkQuoteItem::dateTime
const QDateTime & dateTime() const
Definition: alkquoteitem.cpp:74
AlkQuoteItem::setVolume
void setVolume(const AlkValue &value)
Definition: alkquoteitem.cpp:174
AlkQuoteItem::setCurrentValue
void setCurrentValue(const AlkValue &value)
Definition: alkquoteitem.cpp:144