File indexing completed on 2024-07-14 04:55:02

0001 /*
0002     SPDX-FileCopyrightText: 2011 Alvaro Soliverez asoliverez @kde.org
0003 
0004     This file is part of libalkimia.
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #include "alkquoteitem.h"
0010 
0011 class AlkQuoteItem::Private
0012 {
0013 public:
0014     QString m_symbol;
0015     QDateTime m_dateTime;
0016     AlkValue m_currentValue;
0017     AlkValue m_openingValue;
0018     AlkValue m_highValue;
0019     AlkValue m_lowValue;
0020     AlkValue m_closingValue;
0021     AlkValue m_volume;
0022     AlkValue m_marketCap;
0023     AlkValue m_changeToday;
0024     AlkValue m_earnings;
0025     AlkValue m_ebitda;
0026     QString m_id;
0027 };
0028 
0029 AlkQuoteItem::AlkQuoteItem(QObject *parent)
0030     : QObject(parent)
0031     , d(new Private)
0032 {
0033 }
0034 
0035 AlkQuoteItem::~AlkQuoteItem()
0036 {
0037 }
0038 
0039 AlkQuoteItem::AlkQuoteItem(const AlkQuoteItem &item, QObject *parent)
0040     : QObject(parent)
0041     , d(new Private)
0042 {
0043     setSymbol(item.symbol());
0044     setDateTime(item.dateTime());
0045     setCurrentValue(item.currentValue());
0046     setOpeningValue(item.openingValue());
0047     setHighValue(item.highValue());
0048     setLowValue(item.lowValue());
0049     setClosingValue(item.closingValue());
0050     setVolume(item.volume());
0051     setMarketCap(item.marketCap());
0052     setEarningsPerShare(item.earningsPerShare());
0053     setChangeToday(item.changeToday());
0054     setEbitda(item.ebitda());
0055     setRecordId(item.recordId());
0056 }
0057 
0058 const QString &AlkQuoteItem::symbol() const
0059 {
0060     return d->m_symbol;
0061 }
0062 
0063 const QDateTime &AlkQuoteItem::dateTime() const
0064 {
0065     return d->m_dateTime;
0066 }
0067 
0068 const AlkValue &AlkQuoteItem::currentValue() const
0069 {
0070     return d->m_currentValue;
0071 }
0072 
0073 const AlkValue &AlkQuoteItem::openingValue() const
0074 {
0075     return d->m_openingValue;
0076 }
0077 
0078 const AlkValue &AlkQuoteItem::highValue() const
0079 {
0080     return d->m_highValue;
0081 }
0082 
0083 const AlkValue &AlkQuoteItem::lowValue() const
0084 {
0085     return d->m_lowValue;
0086 }
0087 
0088 const AlkValue &AlkQuoteItem::closingValue() const
0089 {
0090     return d->m_closingValue;
0091 }
0092 
0093 const AlkValue &AlkQuoteItem::volume() const
0094 {
0095     return d->m_volume;
0096 }
0097 
0098 const AlkValue &AlkQuoteItem::marketCap() const
0099 {
0100     return d->m_marketCap;
0101 }
0102 
0103 const AlkValue &AlkQuoteItem::earningsPerShare() const
0104 {
0105     return d->m_earnings;
0106 }
0107 
0108 const AlkValue &AlkQuoteItem::changeToday() const
0109 {
0110     return d->m_changeToday;
0111 }
0112 
0113 const AlkValue &AlkQuoteItem::ebitda() const
0114 {
0115     return d->m_ebitda;
0116 }
0117 
0118 const QString &AlkQuoteItem::recordId() const
0119 {
0120     return d->m_id;
0121 }
0122 
0123 void AlkQuoteItem::setSymbol(const QString &symbol)
0124 {
0125     d->m_symbol = symbol;
0126 }
0127 
0128 void AlkQuoteItem::setDateTime(const QDateTime &dateTime)
0129 {
0130     d->m_dateTime = dateTime;
0131 }
0132 
0133 void AlkQuoteItem::setCurrentValue(const AlkValue &value)
0134 {
0135     d->m_currentValue = value;
0136 }
0137 
0138 void AlkQuoteItem::setOpeningValue(const AlkValue &value)
0139 {
0140     d->m_openingValue = value;
0141 }
0142 
0143 void AlkQuoteItem::setHighValue(const AlkValue &value)
0144 {
0145     d->m_highValue = value;
0146 }
0147 
0148 void AlkQuoteItem::setLowValue(const AlkValue &value)
0149 {
0150     d->m_lowValue = value;
0151 }
0152 
0153 void AlkQuoteItem::setClosingValue(const AlkValue &value)
0154 {
0155     d->m_closingValue = value;
0156 }
0157 
0158 void AlkQuoteItem::setMarketCap(const AlkValue &value)
0159 {
0160     d->m_marketCap = value;
0161 }
0162 
0163 void AlkQuoteItem::setVolume(const AlkValue &value)
0164 {
0165     d->m_volume = value;
0166 }
0167 
0168 void AlkQuoteItem::setEarningsPerShare(const AlkValue &value)
0169 {
0170     d->m_earnings = value;
0171 }
0172 
0173 void AlkQuoteItem::setChangeToday(const AlkValue &value)
0174 {
0175     d->m_changeToday = value;
0176 }
0177 
0178 void AlkQuoteItem::setEbitda(const AlkValue &value)
0179 {
0180     d->m_ebitda = value;
0181 }
0182 
0183 void AlkQuoteItem::setRecordId(const QString &recordId)
0184 {
0185     d->m_id = recordId;
0186 }
0187 
0188 QDBusArgument &operator<<(QDBusArgument &argument, const AlkQuoteItem &item)
0189 {
0190     argument.beginStructure();
0191     argument << item.symbol() << item.dateTime().toString(Qt::ISODate)
0192              << item.currentValue().toString()
0193              << item.openingValue().toString()
0194              << item.highValue().toString() << item.lowValue().toString()
0195              << item.closingValue().toString()
0196              << item.marketCap().toString() << item.volume().toString()
0197              << item.earningsPerShare().toString()
0198              << item.changeToday().toString() << item.ebitda().toString() << item.recordId();
0199     argument.endStructure();
0200     return argument;
0201 }
0202 
0203 const QDBusArgument &operator>>(const QDBusArgument &argument, AlkQuoteItem &item)
0204 {
0205     argument.beginStructure();
0206     QString symbol;
0207     QString dateTime;
0208     QString currentValue;
0209     QString openingValue;
0210     QString highValue;
0211     QString lowValue;
0212     QString closingValue;
0213     QString marketCap;
0214     QString volume;
0215     QString earnings;
0216     QString change;
0217     QString ebitda;
0218     QString recordId;
0219 
0220     argument >> symbol >> dateTime >> currentValue >> openingValue >> highValue >> lowValue
0221     >> closingValue >> marketCap >> volume >> earnings >> change >> ebitda >> recordId;
0222     item.setSymbol(symbol);
0223     item.setDateTime(QDateTime::fromString(dateTime, Qt::ISODate));
0224     item.setCurrentValue(AlkValue(currentValue, '.'));
0225     item.setOpeningValue(AlkValue(openingValue, '.'));
0226     item.setHighValue(AlkValue(highValue, '.'));
0227     item.setLowValue(AlkValue(lowValue, '.'));
0228     item.setClosingValue(AlkValue(closingValue, '.'));
0229     item.setMarketCap(AlkValue(marketCap, '.'));
0230     item.setVolume(AlkValue(volume, '.'));
0231     item.setEarningsPerShare(AlkValue(earnings, '.'));
0232     item.setChangeToday(AlkValue(change, '.'));
0233     item.setEbitda(AlkValue(ebitda, '.'));
0234     item.setRecordId(recordId);
0235 
0236     argument.endStructure();
0237     return argument;
0238 }