Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kequitypriceupdatedlg.cpp
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | kequitypriceupdatedlg.cpp - description | 2 | kequitypriceupdatedlg.cpp - description | ||
3 | ------------------- | 3 | ------------------- | ||
4 | begin : Mon Sep 1 2003 | 4 | begin : Mon Sep 1 2003 | ||
5 | copyright : (C) 2000-2003 by Michael Edwardes | 5 | copyright : (C) 2000-2003 by Michael Edwardes | ||
6 | email : mte@users.sourceforge.net | 6 | email : mte@users.sourceforge.net | ||
7 | Javier Campos Morales <javi_c@users.sourceforge.net> | 7 | Javier Campos Morales <javi_c@users.sourceforge.net> | ||
8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | 8 | Felix Rodriguez <frodriguez@users.sourceforge.net> | ||
9 | John C <thetacoturtle@users.sourceforge.net> | 9 | John C <thetacoturtle@users.sourceforge.net> | ||
10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | 10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | ||
11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | 11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | ||
12 | Ace Jones <acejones@users.sourceforge.net> | 12 | Ace Jones <acejones@users.sourceforge.net> | ||
13 | 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
13 | ***************************************************************************/ | 14 | ***************************************************************************/ | ||
14 | 15 | | |||
15 | /*************************************************************************** | 16 | /*************************************************************************** | ||
16 | * * | 17 | * * | ||
17 | * This program is free software; you can redistribute it and/or modify * | 18 | * This program is free software; you can redistribute it and/or modify * | ||
18 | * it under the terms of the GNU General Public License as published by * | 19 | * it under the terms of the GNU General Public License as published by * | ||
19 | * the Free Software Foundation; either version 2 of the License, or * | 20 | * the Free Software Foundation; either version 2 of the License, or * | ||
20 | * (at your option) any later version. * | 21 | * (at your option) any later version. * | ||
Show All 23 Lines | |||||
44 | #include <KGuiItem> | 45 | #include <KGuiItem> | ||
45 | #include <KStandardGuiItem> | 46 | #include <KStandardGuiItem> | ||
46 | #include <KSharedConfig> | 47 | #include <KSharedConfig> | ||
47 | #include <KLocalizedString> | 48 | #include <KLocalizedString> | ||
48 | 49 | | |||
49 | // ---------------------------------------------------------------------------- | 50 | // ---------------------------------------------------------------------------- | ||
50 | // Project Includes | 51 | // Project Includes | ||
51 | 52 | | |||
53 | #include "kmymoney.h" | ||||
52 | #include "mymoneyfile.h" | 54 | #include "mymoneyfile.h" | ||
53 | #include "mymoneysecurity.h" | 55 | #include "mymoneysecurity.h" | ||
54 | #include "mymoneyprice.h" | 56 | #include "mymoneyprice.h" | ||
55 | #include "kmymoneyglobalsettings.h" | 57 | #include "kmymoneyglobalsettings.h" | ||
56 | 58 | | |||
57 | #define SYMBOL_COL 0 | 59 | #define SYMBOL_COL 0 | ||
58 | #define NAME_COL 1 | 60 | #define NAME_COL 1 | ||
59 | #define PRICE_COL 2 | 61 | #define PRICE_COL 2 | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 131 | if (lvEquityList->invisibleRootItem()->childCount() == 0) { | |||
130 | addPricePair(currencyIds, true); | 132 | addPricePair(currencyIds, true); | ||
131 | } | 133 | } | ||
132 | 134 | | |||
133 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); | 135 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); | ||
134 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | 136 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | ||
135 | connect(btnUpdateSelected, SIGNAL(clicked()), this, SLOT(slotUpdateSelectedClicked())); | 137 | connect(btnUpdateSelected, SIGNAL(clicked()), this, SLOT(slotUpdateSelectedClicked())); | ||
136 | connect(btnUpdateAll, SIGNAL(clicked()), this, SLOT(slotUpdateAllClicked())); | 138 | connect(btnUpdateAll, SIGNAL(clicked()), this, SLOT(slotUpdateAllClicked())); | ||
137 | 139 | | |||
140 | connect(m_fromDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | ||||
141 | connect(m_toDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | ||||
142 | | ||||
143 | connect(&m_webQuote, &WebPriceQuote::csvquote, | ||||
144 | this, &KEquityPriceUpdateDlg::slotReceivedCSVQuote); | ||||
138 | connect(&m_webQuote, SIGNAL(quote(QString,QString,QDate,double)), | 145 | connect(&m_webQuote, SIGNAL(quote(QString,QString,QDate,double)), | ||
139 | this, SLOT(slotReceivedQuote(QString,QString,QDate,double))); | 146 | this, SLOT(slotReceivedQuote(QString,QString,QDate,double))); | ||
140 | connect(&m_webQuote, SIGNAL(failed(QString,QString)), | 147 | connect(&m_webQuote, SIGNAL(failed(QString,QString)), | ||
141 | this, SLOT(slotQuoteFailed(QString,QString))); | 148 | this, SLOT(slotQuoteFailed(QString,QString))); | ||
142 | connect(&m_webQuote, SIGNAL(status(QString)), | 149 | connect(&m_webQuote, SIGNAL(status(QString)), | ||
143 | this, SLOT(logStatusMessage(QString))); | 150 | this, SLOT(logStatusMessage(QString))); | ||
144 | connect(&m_webQuote, SIGNAL(error(QString)), | 151 | connect(&m_webQuote, SIGNAL(error(QString)), | ||
145 | this, SLOT(logErrorMessage(QString))); | 152 | this, SLOT(logErrorMessage(QString))); | ||
146 | 153 | | |||
147 | connect(lvEquityList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateSelection())); | 154 | connect(lvEquityList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateSelection())); | ||
148 | 155 | | |||
149 | // Not implemented yet. | 156 | connect(btnConfigure, &QAbstractButton::clicked, this, &KEquityPriceUpdateDlg::slotConfigureClicked); | ||
150 | btnConfigure->hide(); | | |||
151 | //connect(btnConfigure, SIGNAL(clicked()), this, SLOT(slotConfigureClicked())); | | |||
152 | 157 | | |||
153 | if (!securityId.isEmpty()) { | 158 | if (!securityId.isEmpty()) { | ||
154 | btnUpdateSelected->hide(); | 159 | btnUpdateSelected->hide(); | ||
155 | btnUpdateAll->hide(); | 160 | btnUpdateAll->hide(); | ||
156 | // delete layout1; | 161 | // delete layout1; | ||
157 | 162 | | |||
158 | QTimer::singleShot(100, this, SLOT(slotUpdateAllClicked())); | 163 | QTimer::singleShot(100, this, SLOT(slotUpdateAllClicked())); | ||
159 | } | 164 | } | ||
160 | 165 | | |||
161 | // Hide OK button until we have received the first update | 166 | // Hide OK button until we have received the first update | ||
162 | buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); | 167 | buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); | ||
163 | 168 | | |||
164 | slotUpdateSelection(); | 169 | slotUpdateSelection(); | ||
165 | 170 | | |||
166 | // previous versions of this dialog allowed to store a "Don't ask again" switch. | 171 | // previous versions of this dialog allowed to store a "Don't ask again" switch. | ||
167 | // Since we don't support it anymore, we just get rid of it | 172 | // Since we don't support it anymore, we just get rid of it | ||
168 | KSharedConfigPtr config = KSharedConfig::openConfig(); | 173 | KSharedConfigPtr config = KSharedConfig::openConfig(); | ||
169 | KConfigGroup grp = config->group("Notification Messages"); | 174 | KConfigGroup grp = config->group("Notification Messages"); | ||
170 | grp.deleteEntry("KEquityPriceUpdateDlg::slotQuoteFailed::Price Update Failed"); | 175 | grp.deleteEntry("KEquityPriceUpdateDlg::slotQuoteFailed::Price Update Failed"); | ||
176 | grp.sync(); | ||||
177 | grp = config->group("Equity Price Update"); | ||||
178 | int policyValue = grp.readEntry("PriceUpdatingPolicy", QString().setNum(eUpdateMissingPrices)).toInt(); | ||||
179 | if (policyValue >= eUpdatingPricePolicyEnd || policyValue < eUpdateAllPrices) | ||||
180 | m_updatingPricePolicy = eUpdateMissingPrices; | ||||
181 | else | ||||
182 | m_updatingPricePolicy = static_cast<updatingPricePolicyE>(policyValue); | ||||
171 | } | 183 | } | ||
172 | 184 | | |||
173 | KEquityPriceUpdateDlg::~KEquityPriceUpdateDlg() | 185 | KEquityPriceUpdateDlg::~KEquityPriceUpdateDlg() | ||
174 | { | 186 | { | ||
175 | 187 | KSharedConfigPtr config = KSharedConfig::openConfig(); | |||
188 | KConfigGroup grp = config->group("Equity Price Update"); | ||||
189 | grp.writeEntry("PriceUpdatingPolicy", static_cast<int>(m_updatingPricePolicy)); | ||||
190 | grp.sync(); | ||||
176 | } | 191 | } | ||
177 | 192 | | |||
178 | void KEquityPriceUpdateDlg::addPricePair(const MyMoneySecurityPair& pair, bool dontCheckExistance) | 193 | void KEquityPriceUpdateDlg::addPricePair(const MyMoneySecurityPair& pair, bool dontCheckExistance) | ||
179 | { | 194 | { | ||
180 | MyMoneyFile* file = MyMoneyFile::instance(); | 195 | MyMoneyFile* file = MyMoneyFile::instance(); | ||
181 | 196 | | |||
182 | QString symbol = QString("%1 > %2").arg(pair.first, pair.second); | 197 | QString symbol = QString("%1 > %2").arg(pair.first, pair.second); | ||
183 | QString id = QString("%1 %2").arg(pair.first, pair.second); | 198 | QString id = QString("%1 %2").arg(pair.first, pair.second); | ||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 347 | try { | |||
364 | } | 379 | } | ||
365 | ft.commit(); | 380 | ft.commit(); | ||
366 | 381 | | |||
367 | } catch (const MyMoneyException &) { | 382 | } catch (const MyMoneyException &) { | ||
368 | qDebug("Unable to add price information for %s", qPrintable(name)); | 383 | qDebug("Unable to add price information for %s", qPrintable(name)); | ||
369 | } | 384 | } | ||
370 | } | 385 | } | ||
371 | 386 | | |||
387 | void KEquityPriceUpdateDlg::slotConfigureClicked() | ||||
388 | { | ||||
389 | EquityPriceUpdateConfDlg *dlg = new EquityPriceUpdateConfDlg(m_updatingPricePolicy); | ||||
390 | if (dlg->exec() == QDialog::Accepted) | ||||
391 | m_updatingPricePolicy = dlg->policy(); | ||||
392 | delete dlg; | ||||
393 | } | ||||
394 | | ||||
372 | void KEquityPriceUpdateDlg::slotUpdateSelection() | 395 | void KEquityPriceUpdateDlg::slotUpdateSelection() | ||
373 | { | 396 | { | ||
374 | // Only enable the update button if there is a selection | 397 | // Only enable the update button if there is a selection | ||
375 | btnUpdateSelected->setEnabled(false); | 398 | btnUpdateSelected->setEnabled(false); | ||
376 | 399 | | |||
377 | if (! lvEquityList->selectedItems().empty()) | 400 | if (! lvEquityList->selectedItems().empty()) | ||
378 | btnUpdateSelected->setEnabled(true); | 401 | btnUpdateSelected->setEnabled(true); | ||
379 | } | 402 | } | ||
380 | 403 | | |||
381 | void KEquityPriceUpdateDlg::slotUpdateSelectedClicked() | 404 | void KEquityPriceUpdateDlg::slotUpdateSelectedClicked() | ||
382 | { | 405 | { | ||
383 | // disable sorting while the update is running to maintain the current order of items on which | 406 | // disable sorting while the update is running to maintain the current order of items on which | ||
384 | // the update process depends and which could be changed with sorting enabled due to the updated values | 407 | // the update process depends and which could be changed with sorting enabled due to the updated values | ||
385 | lvEquityList->setSortingEnabled(false); | 408 | lvEquityList->setSortingEnabled(false); | ||
386 | QTreeWidgetItem* item = lvEquityList->invisibleRootItem()->child(0); | 409 | QTreeWidgetItem* item = lvEquityList->invisibleRootItem()->child(0); | ||
387 | int skipCnt = 1; | 410 | int skipCnt = 1; | ||
388 | while (item && !item->isSelected()) { | 411 | while (item && !item->isSelected()) { | ||
389 | item = lvEquityList->invisibleRootItem()->child(skipCnt); | 412 | item = lvEquityList->invisibleRootItem()->child(skipCnt); | ||
390 | ++skipCnt; | 413 | ++skipCnt; | ||
391 | } | 414 | } | ||
392 | 415 | m_webQuote.setDate(m_fromDate->date(), m_toDate->date()); | |||
393 | if (item) { | 416 | if (item) { | ||
394 | prgOnlineProgress->setMaximum(1 + lvEquityList->invisibleRootItem()->childCount()); | 417 | prgOnlineProgress->setMaximum(1 + lvEquityList->invisibleRootItem()->childCount()); | ||
395 | prgOnlineProgress->setValue(skipCnt); | 418 | prgOnlineProgress->setValue(skipCnt); | ||
396 | m_webQuote.launch(item->text(SYMBOL_COL), item->text(ID_COL), item->text(SOURCE_COL)); | 419 | m_webQuote.launch(item->text(SYMBOL_COL), item->text(ID_COL), item->text(SOURCE_COL)); | ||
420 | | ||||
397 | } else { | 421 | } else { | ||
398 | 422 | | |||
399 | logErrorMessage("No security selected."); | 423 | logErrorMessage("No security selected."); | ||
400 | } | 424 | } | ||
401 | } | 425 | } | ||
402 | 426 | | |||
403 | void KEquityPriceUpdateDlg::slotUpdateAllClicked() | 427 | void KEquityPriceUpdateDlg::slotUpdateAllClicked() | ||
404 | { | 428 | { | ||
405 | // disable sorting while the update is running to maintain the current order of items on which | 429 | // disable sorting while the update is running to maintain the current order of items on which | ||
406 | // the update process depends and which could be changed with sorting enabled due to the updated values | 430 | // the update process depends and which could be changed with sorting enabled due to the updated values | ||
407 | lvEquityList->setSortingEnabled(false); | 431 | lvEquityList->setSortingEnabled(false); | ||
408 | QTreeWidgetItem* item = lvEquityList->invisibleRootItem()->child(0); | 432 | QTreeWidgetItem* item = lvEquityList->invisibleRootItem()->child(0); | ||
409 | if (item) { | 433 | if (item) { | ||
410 | prgOnlineProgress->setMaximum(1 + lvEquityList->invisibleRootItem()->childCount()); | 434 | prgOnlineProgress->setMaximum(1 + lvEquityList->invisibleRootItem()->childCount()); | ||
411 | prgOnlineProgress->setValue(1); | 435 | prgOnlineProgress->setValue(1); | ||
412 | m_fUpdateAll = true; | 436 | m_fUpdateAll = true; | ||
413 | m_webQuote.launch(item->text(SYMBOL_COL), item->text(ID_COL), item->text(SOURCE_COL)); | 437 | m_webQuote.launch(item->text(SYMBOL_COL), item->text(ID_COL), item->text(SOURCE_COL)); | ||
414 | 438 | | |||
415 | } else { | 439 | } else { | ||
416 | logErrorMessage("Security list is empty."); | 440 | logErrorMessage("Security list is empty."); | ||
417 | } | 441 | } | ||
418 | } | 442 | } | ||
419 | 443 | | |||
444 | void KEquityPriceUpdateDlg::slotDateChanged() | ||||
445 | { | ||||
446 | m_fromDate->blockSignals(true); | ||||
447 | m_toDate->blockSignals(true); | ||||
448 | if (m_toDate->date() > QDate::currentDate()) | ||||
449 | m_toDate->setDate(QDate::currentDate()); | ||||
450 | if (m_toDate->date() < m_fromDate->date()) | ||||
451 | m_fromDate->setDate(m_toDate->date()); | ||||
452 | m_fromDate->blockSignals(false); | ||||
453 | m_toDate->blockSignals(false); | ||||
454 | } | ||||
455 | | ||||
420 | void KEquityPriceUpdateDlg::slotQuoteFailed(const QString& _id, const QString& _symbol) | 456 | void KEquityPriceUpdateDlg::slotQuoteFailed(const QString& _id, const QString& _symbol) | ||
421 | { | 457 | { | ||
422 | QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL); | 458 | QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL); | ||
423 | QTreeWidgetItem* item = 0; | 459 | QTreeWidgetItem* item = 0; | ||
424 | 460 | | |||
425 | if (! foundItems.empty()) | 461 | if (! foundItems.empty()) | ||
426 | item = foundItems.at(0); | 462 | item = foundItems.at(0); | ||
427 | 463 | | |||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 493 | if (result != KMessageBox::Cancel) { | |||
473 | } else { | 509 | } else { | ||
474 | finishUpdate(); | 510 | finishUpdate(); | ||
475 | } | 511 | } | ||
476 | } else { | 512 | } else { | ||
477 | finishUpdate(); | 513 | finishUpdate(); | ||
478 | } | 514 | } | ||
479 | } | 515 | } | ||
480 | 516 | | |||
517 | void KEquityPriceUpdateDlg::slotReceivedCSVQuote(const QString& _id, const QString& _symbol, MyMoneyStatement& st) | ||||
518 | { | ||||
519 | QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL); | ||||
520 | QTreeWidgetItem* item = 0; | ||||
521 | | ||||
522 | if (! foundItems.empty()) | ||||
523 | item = foundItems.at(0); | ||||
524 | | ||||
525 | QTreeWidgetItem* next = 0; | ||||
526 | | ||||
527 | if (item) { | ||||
528 | MyMoneyFile *file = MyMoneyFile::instance(); | ||||
529 | MyMoneySecurity fromCurrency, toCurrency; | ||||
530 | | ||||
531 | if (!_id.contains(QLatin1Char(' '))) { | ||||
532 | try { | ||||
533 | toCurrency = MyMoneyFile::instance()->security(_id); | ||||
534 | fromCurrency = MyMoneyFile::instance()->security(toCurrency.tradingCurrency()); | ||||
535 | } catch (const MyMoneyException &) { | ||||
536 | fromCurrency = toCurrency = MyMoneySecurity(); | ||||
537 | } | ||||
538 | | ||||
539 | } else { | ||||
540 | QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive); | ||||
541 | if (splitrx.indexIn(_id) != -1) { | ||||
542 | try { | ||||
543 | fromCurrency = MyMoneyFile::instance()->security(splitrx.cap(2).toUtf8()); | ||||
544 | toCurrency = MyMoneyFile::instance()->security(splitrx.cap(1).toUtf8()); | ||||
545 | } catch (const MyMoneyException &) { | ||||
546 | fromCurrency = toCurrency = MyMoneySecurity(); | ||||
547 | } | ||||
548 | } | ||||
549 | } | ||||
550 | | ||||
551 | if (m_updatingPricePolicy != eUpdateAllPrices) { | ||||
552 | QStringList qSources = WebPriceQuote::quoteSources(); | ||||
553 | for (auto it = st.m_listPrices.begin(); it != st.m_listPrices.end();) { | ||||
554 | MyMoneyPrice storedPrice = file->price(toCurrency.id(), fromCurrency.id(), (*it).m_date, true); | ||||
555 | bool priceValid = storedPrice.isValid(); | ||||
556 | if (!priceValid) | ||||
557 | ++it; | ||||
558 | else { | ||||
559 | switch(m_updatingPricePolicy) { | ||||
560 | case eUpdateMissingPrices: | ||||
561 | it = st.m_listPrices.erase(it); | ||||
562 | break; | ||||
563 | case eUpdateDownloadedPrices: | ||||
564 | if (!qSources.contains(storedPrice.source())) | ||||
565 | it = st.m_listPrices.erase(it); | ||||
566 | else | ||||
567 | ++it; | ||||
568 | break; | ||||
569 | case eUpdateSameSourcePrices: | ||||
570 | if (storedPrice.source().compare((*it).m_sourceName) != 0) | ||||
571 | it = st.m_listPrices.erase(it); | ||||
572 | else | ||||
573 | ++it; | ||||
574 | break; | ||||
575 | case eAsk: | ||||
576 | { | ||||
577 | int result = KMessageBox::questionYesNoCancel(this, | ||||
578 | i18n("For <b>%1</b> on <b>%2</b> price <b>%3</b> already exists.<br>" | ||||
579 | "Do you want to replace it with <b>%4</b>?", | ||||
580 | storedPrice.from(), storedPrice.date().toString(Qt::ISODate), | ||||
581 | QString().setNum(storedPrice.rate(storedPrice.to()).toDouble(), 'g', 10), | ||||
582 | QString().setNum((*it).m_amount.toDouble(), 'g', 10)), | ||||
583 | i18n("Price Already Exists")); | ||||
584 | switch(result) { | ||||
585 | case KStandardGuiItem::Yes: | ||||
586 | ++it; | ||||
587 | break; | ||||
588 | case KStandardGuiItem::No: | ||||
589 | it = st.m_listPrices.erase(it); | ||||
590 | break; | ||||
591 | default: | ||||
592 | case KStandardGuiItem::Cancel: | ||||
593 | finishUpdate(); | ||||
594 | return; | ||||
595 | break; | ||||
596 | } | ||||
597 | break; | ||||
598 | } | ||||
599 | default: | ||||
600 | ++it; | ||||
601 | break; | ||||
602 | } | ||||
603 | } | ||||
604 | } | ||||
605 | } | ||||
606 | | ||||
607 | if (!st.m_listPrices.isEmpty()) { | ||||
608 | kmymoney->slotStatementImport(st, true); | ||||
609 | | ||||
610 | MyMoneyStatement::Price priceClass; | ||||
611 | if (st.m_listPrices.first().m_date > st.m_listPrices.last().m_date) | ||||
612 | priceClass = st.m_listPrices.first(); | ||||
613 | else | ||||
614 | priceClass = st.m_listPrices.last(); | ||||
615 | | ||||
616 | QDate latestDate = QDate::fromString(item->text(DATE_COL),Qt::ISODate); | ||||
617 | if (latestDate <= priceClass.m_date && priceClass.m_amount.isPositive()) { | ||||
618 | item->setText(PRICE_COL, priceClass.m_amount.formatMoney(fromCurrency.tradingSymbol(), toCurrency.pricePrecision())); | ||||
619 | item->setText(DATE_COL, priceClass.m_date.toString(Qt::ISODate)); | ||||
620 | item->setText(SOURCE_COL, priceClass.m_sourceName); | ||||
621 | } | ||||
622 | logStatusMessage(i18n("Price for %1 updated (id %2)", _symbol, _id)); | ||||
623 | // make sure to make OK button available | ||||
624 | } | ||||
625 | buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); | ||||
626 | | ||||
627 | prgOnlineProgress->setValue(prgOnlineProgress->value() + 1); | ||||
628 | item->setSelected(false); | ||||
629 | | ||||
630 | // launch the NEXT one ... in case of m_fUpdateAll == false, we | ||||
631 | // need to parse the list to find the next selected one | ||||
632 | next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(item) + 1); | ||||
633 | if (!m_fUpdateAll) { | ||||
634 | while (next && !next->isSelected()) { | ||||
635 | prgOnlineProgress->setValue(prgOnlineProgress->value() + 1); | ||||
636 | next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(next) + 1); | ||||
637 | } | ||||
638 | } | ||||
639 | } else { | ||||
640 | logErrorMessage(i18n("Received a price for %1 (id %2), but this symbol is not on the list. Aborting entire update.", _symbol, _id)); | ||||
641 | } | ||||
642 | | ||||
643 | if (next) { | ||||
644 | m_webQuote.launch(next->text(SYMBOL_COL), next->text(ID_COL), next->text(SOURCE_COL)); | ||||
645 | } else { | ||||
646 | finishUpdate(); | ||||
647 | } | ||||
648 | } | ||||
649 | | ||||
481 | void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _id, const QString& _symbol, const QDate& _date, const double& _price) | 650 | void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _id, const QString& _symbol, const QDate& _date, const double& _price) | ||
482 | { | 651 | { | ||
483 | QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL); | 652 | QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL); | ||
484 | QTreeWidgetItem* item = 0; | 653 | QTreeWidgetItem* item = 0; | ||
485 | 654 | | |||
486 | if (! foundItems.empty()) | 655 | if (! foundItems.empty()) | ||
487 | item = foundItems.at(0); | 656 | item = foundItems.at(0); | ||
488 | 657 | | |||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |