diff --git a/kmymoney/converter/CMakeLists.txt b/kmymoney/converter/CMakeLists.txt --- a/kmymoney/converter/CMakeLists.txt +++ b/kmymoney/converter/CMakeLists.txt @@ -5,13 +5,13 @@ mymoneyqifwriter.cpp mymoneystatementreader.cpp mymoneytemplate.cpp - webpricequote.cpp transactionmatchfinder.cpp existingtransactionmatchfinder.cpp scheduledtransactionmatchfinder.cpp ) kde4_add_library(converter STATIC ${libconverter_a_SOURCES}) +target_link_libraries(converter ${LIBALKIMIA_LIBRARIES}) # we rely on some dialogs to be generated add_dependencies(converter dialogs) @@ -23,9 +23,6 @@ ############## tests #################### if( KDE4_BUILD_TESTS ) - set( convertertest_SRCS convertertest.cpp ../reports/reportstestcommon.cpp ) - kde4_add_unit_test( convertertest TESTNAME kmymoney-convertertest ${convertertest_SRCS} ) - target_link_libraries( convertertest converter kmymoney_base kmymoney_common kmm_storage ${QT_AND_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY} ) set( matchfindertest_SRCS matchfindertest.cpp ) kde4_add_unit_test( matchfindertest TESTNAME kmymoney-matchfindertest ${matchfindertest_SRCS} ) diff --git a/kmymoney/converter/convertertest.h b/kmymoney/converter/convertertest.h deleted file mode 100644 --- a/kmymoney/converter/convertertest.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - convertertest.h - ------------------- - copyright : (C) 2002 by Thomas Baumgart - email : ipwizard@users.sourceforge.net - Ace Jones - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef CONVERTERTEST_H -#define CONVERTERTEST_H - -#include - -#include "mymoneyfile.h" -#include "storage/mymoneyseqaccessmgr.h" - -class ConverterTest : public QObject -{ - Q_OBJECT - -private: - MyMoneySeqAccessMgr* storage; - MyMoneyFile* file; - -private slots: - void init(); - void cleanup(); - void testWebQuotesDefault(); - void testWebQuotes_data(); - void testWebQuotes(); - void testDateFormat(); -}; - -#endif // CONVERTERTEST_H diff --git a/kmymoney/converter/convertertest.cpp b/kmymoney/converter/convertertest.cpp deleted file mode 100644 --- a/kmymoney/converter/convertertest.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*************************************************************************** - convertertest.cpp - ------------------- - copyright : (C) 2002 by Thomas Baumgart - email : ipwizard@users.sourceforge.net - Ace Jones - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "convertertest.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// uses helper functions from reports tests -#include "reportstestcommon.h" -using namespace test; - -#include "mymoneysecurity.h" -#include "mymoneyprice.h" -#include "mymoneyreport.h" -#include "mymoneystatement.h" -#include "storage/mymoneystoragexml.h" -#include "storage/mymoneystoragedump.h" -#include "webpricequote.h" - -QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME(ConverterTest, "kmymoney") - -using namespace convertertest; - -void ConverterTest::init() -{ - storage = new MyMoneySeqAccessMgr; - file = MyMoneyFile::instance(); - file->attachStorage(storage); - - MyMoneyFileTransaction ft; - - file->addCurrency(MyMoneySecurity("CAD", "Canadian Dollar", "C$")); - file->addCurrency(MyMoneySecurity("USD", "US Dollar", "$")); - file->addCurrency(MyMoneySecurity("JPY", "Japanese Yen", QChar(0x00A5), 100, 1)); - file->addCurrency(MyMoneySecurity("GBP", "British Pound", "#")); - file->setBaseCurrency(file->currency("USD")); - - MyMoneyPayee payeeTest("Test Payee"); - file->addPayee(payeeTest); - MyMoneyPayee payeeTest2("Thomas Baumgart"); - file->addPayee(payeeTest2); - - acAsset = (MyMoneyFile::instance()->asset().id()); - acLiability = (MyMoneyFile::instance()->liability().id()); - acExpense = (MyMoneyFile::instance()->expense().id()); - acIncome = (MyMoneyFile::instance()->income().id()); - acChecking = makeAccount("Checking Account", MyMoneyAccount::Checkings, moConverterCheckingOpen, QDate(2004, 5, 15), acAsset); - acCredit = makeAccount("Credit Card", MyMoneyAccount::CreditCard, moConverterCreditOpen, QDate(2004, 7, 15), acLiability); - acSolo = makeAccount("Solo", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acParent = makeAccount("Parent", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - acChild = makeAccount("Child", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 2, 11), acParent); - acForeign = makeAccount("Foreign", MyMoneyAccount::Expense, MyMoneyMoney(), QDate(2004, 1, 11), acExpense); - - MyMoneyInstitution i("Bank of the World", "", "", "", "", "", ""); - file->addInstitution(i); - inBank = i.id(); - ft.commit(); -} - -void ConverterTest::cleanup() -{ - file->detachStorage(storage); - delete storage; -} - -void ConverterTest::testWebQuotes_data() -{ - QTest::addColumn("symbol"); - QTest::addColumn("testname"); - QTest::addColumn("source"); - - QTest::newRow("Yahoo UK") << "VOD.L" << "test Yahoo UK" << "Yahoo UK"; - QTest::newRow("Yahoo Currency") << "EUR > USD" << "test Yahoo Currency" << "Yahoo Currency"; - QTest::newRow("Financial Express") << "0585239" << "test Financial Express" << "Financial Express"; - QTest::newRow("Yahoo France") << "EAD.PA" << "test Yahoo France" << "Yahoo France"; - QTest::newRow("Globe & Mail") << "50492" << "test Globe-Mail" << "Globe & Mail"; - QTest::newRow("MSN Canada") << "TDB647" << "test MSN.CA" << "MSN.CA"; - -// QTest::newRow("Finanztreff") << "BASF.SE" << "test Finanztreff" << "Finanztreff"; -// QTest::newRow("boerseonline") << "symbol" << "test boerseonline" << "boerseonline"; -// QTest::newRow("Wallstreet-Online.DE (Default)") << "symbol" << "test Wallstreet-Online.DE (Default)" << "Wallstreet-Online.DE (Default)"; -// QTest::newRow("Financial Times UK") << "DZGEAE" << "test Financial Times UK Funds" << "Financial Times UK Funds"); - - QTest::newRow("Yahoo Canada") << "UTS.TO" << "test Yahoo Canada" << "Yahoo Canada"; - -// QTest::newRow("Wallstreed-Online.DE (Hamburg)") << "TDB647" << "test Wallstreet-Online.DE (Hamburg)" << "Wallstreet-Online.DE (Hamburg)"; -// QTest::newRow("Gielda Papierow Wartosciowych (GPW)") << "TDB647" << "test Gielda Papierow Wartosciowych (GPW)" << "Gielda Papierow Wartosciowych (GPW)"; -// QTest::newRow("OMX Baltic") << "TDB647" << "test OMX Baltic funds" << "OMX Baltic funds"; - - QTest::newRow("Finance::Quote usa") << "DIS" << "test F::Q usa" << "Finance::Quote usa"; -//UNTESTED: Other F::Q sources, local files, user custom sources -} - -void ConverterTest::testWebQuotesDefault() -{ -#ifdef PERFORM_ONLINE_TESTS - try { - WebPriceQuote q; - QuoteReceiver qr(&q); - - q.launch("DIS", "test default"); -// kDebug(2) << "ConverterTest::testWebQuotes(): quote for " << q.m_symbol << " on " << qr.m_date.toString() << " is " << qr.m_price.toString() << " errors(" << qr.m_errors.count() << "): " << qr.m_errors.join(" /// "); - - // No errors allowed - QVERIFY(qr.m_errors.count() == 0); - - // Quote date should be within the last week, or something bad is going on. - QVERIFY(qr.m_date <= QDate::currentDate()); - QVERIFY(qr.m_date >= QDate::currentDate().addDays(-7)); - - // Quote value should at least be positive - QVERIFY(qr.m_price.isPositive()); - } catch (const MyMoneyException &e) { - QFAIL(qPrintable(e.what())); - } -#endif -} - -void ConverterTest::testWebQuotes() -{ -#ifdef PERFORM_ONLINE_TESTS - try { - WebPriceQuote q; - QuoteReceiver qr(&q); - - QFETCH(QString, symbol); - QFETCH(QString, testname); - QFETCH(QString, source); - - q.launch(symbol, testname, source); - QVERIFY(qr.m_errors.count() == 0); - QVERIFY(qr.m_date <= QDate::currentDate().addDays(1)); - QVERIFY(qr.m_date >= QDate::currentDate().addDays(-7)); - QVERIFY(qr.m_price.isPositive()); - - } catch (const MyMoneyException &e) { - QFAIL(qPrintable(e.what())); - } -#endif -} - -void ConverterTest::testDateFormat() -{ - try { - MyMoneyDateFormat format("%mm-%dd-%yyyy"); - - QVERIFY(format.convertString("1-5-2005") == QDate(2005, 1, 5)); - QVERIFY(format.convertString("jan-15-2005") == QDate(2005, 1, 15)); - QVERIFY(format.convertString("august-25-2005") == QDate(2005, 8, 25)); - - format = MyMoneyDateFormat("%mm/%dd/%yy"); - - QVERIFY(format.convertString("1/5/05") == QDate(2005, 1, 5)); - QVERIFY(format.convertString("jan/15/05") == QDate(2005, 1, 15)); - QVERIFY(format.convertString("august/25/05") == QDate(2005, 8, 25)); - - format = MyMoneyDateFormat("%d\\.%m\\.%yy"); - - QVERIFY(format.convertString("1.5.05") == QDate(2005, 5, 1)); - QVERIFY(format.convertString("15.jan.05") == QDate(2005, 1, 15)); - QVERIFY(format.convertString("25.august.05") == QDate(2005, 8, 25)); - - format = MyMoneyDateFormat("%yyyy\\\\%dddd\\\\%mmmmmmmmmmm"); - - QVERIFY(format.convertString("2005\\31\\12") == QDate(2005, 12, 31)); - QVERIFY(format.convertString("2005\\15\\jan") == QDate(2005, 1, 15)); - QVERIFY(format.convertString("2005\\25\\august") == QDate(2005, 8, 25)); - - format = MyMoneyDateFormat("%m %dd, %yyyy"); - - QVERIFY(format.convertString("jan 15, 2005") == QDate(2005, 1, 15)); - QVERIFY(format.convertString("august 25, 2005") == QDate(2005, 8, 25)); - QVERIFY(format.convertString("january 1st, 2005") == QDate(2005, 1, 1)); - - format = MyMoneyDateFormat("%m %d %y"); - - QVERIFY(format.convertString("12/31/50", false, 2000) == QDate(1950, 12, 31)); - QVERIFY(format.convertString("1/1/90", false, 2000) == QDate(1990, 1, 1)); - QVERIFY(format.convertString("december 31st, 5", false) == QDate(2005, 12, 31)); - } catch (const MyMoneyException &e) { - QFAIL(qPrintable(e.what())); - } -} diff --git a/kmymoney/converter/webpricequote.h b/kmymoney/converter/webpricequote.h deleted file mode 100644 --- a/kmymoney/converter/webpricequote.h +++ /dev/null @@ -1,239 +0,0 @@ -/*************************************************************************** - webpricequote.h - ------------------- - begin : Thu Dec 30 2004 - copyright : (C) 2004 by Ace Jones - email : Ace Jones - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef WEBPRICEQUOTE_H -#define WEBPRICEQUOTE_H - -// ---------------------------------------------------------------------------- -// QT Headers - -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -// KDE Headers - -#include -#include - -// ---------------------------------------------------------------------------- -// Project Headers - -#include "mymoneymoney.h" - -/** -Helper class to attend the process which is running the script, in the case -of a local script being used to fetch the quote. - -@author Thomas Baumgart & Ace Jones -*/ -class WebPriceQuoteProcess: public KProcess -{ - Q_OBJECT -public: - WebPriceQuoteProcess(); - inline void setSymbol(const QString& _symbol) { - m_symbol = _symbol; m_string.truncate(0); - } - -public slots: - void slotReceivedDataFromFilter(); - void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); - -signals: - void processExited(const QString&); - -private: - QString m_symbol; - QString m_string; -}; - -/** -Helper class to run the Finance::Quote process. This is used only for the purpose of obtaining -a list of valid sources. The actual price quotes are obtained thru WebPriceQuoteProcess. -The class also contains functions to convert between the rather cryptic source names used -by the Finance::Quote package, and more user-friendly names. - -@author Thomas Baumgart & Ace Jones , Tony B - */ -class FinanceQuoteProcess: public KProcess -{ - Q_OBJECT -public: - FinanceQuoteProcess(); - void launch(const QString& scriptPath); - bool isFinished() const { - return(m_isDone); - }; - const QStringList getSourceList() const; - const QString crypticName(const QString& niceName) const; - const QString niceName(const QString& crypticName) const; - -public slots: - void slotReceivedDataFromFilter(); - void slotProcessExited(); - -private: - bool m_isDone; - QString m_string; - typedef QMap fqNameMap; - fqNameMap m_fqNames; -}; - -/** - * @author Thomas Baumgart & Ace Jones - * - * This is a helper class to store information about an online source - * for stock prices or currency exchange rates. - */ -struct WebPriceQuoteSource { - WebPriceQuoteSource() : m_skipStripping(false) {} - explicit WebPriceQuoteSource(const QString& name); - WebPriceQuoteSource(const QString& name, const QString& url, const QString& sym, const QString& price, const QString& date, const QString& dateformat, bool skipStripping = false); - ~WebPriceQuoteSource() {} - - void write() const; - void rename(const QString& name); - void remove() const; - - QString m_name; - QString m_url; - QString m_sym; - QString m_price; - QString m_date; - QString m_dateformat; - bool m_skipStripping; -}; - -/** -Retrieves a price quote from a web-based quote source - -@author Ace Jones -*/ -class WebPriceQuote: public QObject -{ - Q_OBJECT -public: - explicit WebPriceQuote(QObject* = 0); - ~WebPriceQuote(); - - typedef enum _quoteSystemE { - Native = 0, - FinanceQuote - } quoteSystemE; - - /** - * This launches a web-based quote update for the given @p _symbol. - * When the quote is received back from the web source, it will be - * emitted on the 'quote' signal. - * - * @param _symbol the trading symbol of the stock to fetch a price for - * @param _id an arbitrary identifier, which will be emitted in the quote - * signal when a price is sent back. - * @param _source the source of the quote (must be a valid value returned - * by quoteSources(). Send QString() to use the default - * source. - * @return bool Whether the quote fetch process was launched successfully - */ - - bool launch(const QString& _symbol, const QString& _id, const QString& _source = QString()); - - /** - * This returns a list of the names of the quote sources - * currently defined. - * - * @param _system whether to return Native or Finance::Quote source list - * @return QStringList of quote source names - */ - static const QStringList quoteSources(const _quoteSystemE _system = Native); - -signals: - void quote(const QString&, const QString&, const QDate&, const double&); - void failed(const QString&, const QString&); - void status(const QString&); - void error(const QString&); - -protected slots: - void slotParseQuote(const QString&); - -protected: - static const QMap defaultQuoteSources(); - -private: - bool launchNative(const QString& _symbol, const QString& _id, const QString& _source = QString()); - bool launchFinanceQuote(const QString& _symbol, const QString& _id, const QString& _source = QString()); - void enter_loop(); - - static const QStringList quoteSourcesNative(); - static const QStringList quoteSourcesFinanceQuote(); - -private: - /// \internal d-pointer class. - class Private; - /// \internal d-pointer instance. - Private* const d; - - static QString m_financeQuoteScriptPath; - static QStringList m_financeQuoteSources; - -}; - -class MyMoneyDateFormat -{ -public: - explicit MyMoneyDateFormat(const QString& _format): m_format(_format) {} - const QString convertDate(const QDate& _in) const; - const QDate convertString(const QString& _in, bool _strict = true, unsigned _centurymidpoint = QDate::currentDate().year()) const; - const QString& format() const { - return m_format; - } -private: - QString m_format; -}; - -namespace convertertest -{ - -/** -Simple class to handle signals/slots for unit tests - -@author Ace Jones -*/ -class QuoteReceiver : public QObject -{ - Q_OBJECT -public: - explicit QuoteReceiver(WebPriceQuote* q, QObject *parent = 0); - ~QuoteReceiver(); -public slots: - void slotGetQuote(const QString&, const QString&, const QDate&, const double&); - void slotStatus(const QString&); - void slotError(const QString&); -public: - QStringList m_statuses; - QStringList m_errors; - MyMoneyMoney m_price; - QDate m_date; -}; - -} // end namespace convertertest - - -#endif // WEBPRICEQUOTE_H diff --git a/kmymoney/converter/webpricequote.cpp b/kmymoney/converter/webpricequote.cpp deleted file mode 100644 --- a/kmymoney/converter/webpricequote.cpp +++ /dev/null @@ -1,942 +0,0 @@ -/*************************************************************************** - webpricequote.cpp - ------------------- - begin : Thu Dec 30 2004 - copyright : (C) 2004 by Ace Jones - email : Ace Jones - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "webpricequote.h" - -// ---------------------------------------------------------------------------- -// QT Headers - -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -// KDE Headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -// Project Headers - -#include "mymoneyexception.h" -#include "mymoneyqifprofile.h" - -// define static members -QString WebPriceQuote::m_financeQuoteScriptPath; -QStringList WebPriceQuote::m_financeQuoteSources; - -class WebPriceQuote::Private -{ -public: - WebPriceQuoteProcess m_filter; - QString m_quoteData; - QString m_symbol; - QString m_id; - QDate m_date; - double m_price; - WebPriceQuoteSource m_source; - - static int dbgArea() { - static int s_area = KDebug::registerArea("KMyMoney (WebPriceQuote)"); - return s_area; - } -}; - -WebPriceQuote::WebPriceQuote(QObject* _parent): - QObject(_parent), - d(new Private) -{ - // only do this once (I know, it is not thread safe, but it should - // always yield the same result so we don't do any semaphore foo here) - if (m_financeQuoteScriptPath.isEmpty()) { - m_financeQuoteScriptPath = KGlobal::dirs()->findResource("appdata", - QString("misc/financequote.pl")); - } - connect(&d->m_filter, SIGNAL(processExited(QString)), this, SLOT(slotParseQuote(QString))); -} - -WebPriceQuote::~WebPriceQuote() -{ - delete d; -} - -bool WebPriceQuote::launch(const QString& _symbol, const QString& _id, const QString& _sourcename) -{ - if (_sourcename.contains("Finance::Quote")) - return (launchFinanceQuote(_symbol, _id, _sourcename)); - else - return (launchNative(_symbol, _id, _sourcename)); -} - -bool WebPriceQuote::launchNative(const QString& _symbol, const QString& _id, const QString& _sourcename) -{ - bool result = true; - d->m_symbol = _symbol; - d->m_id = _id; - -// emit status(QString("(Debug) symbol=%1 id=%2...").arg(_symbol,_id)); - - // Get sources from the config file - QString sourcename = _sourcename; - if (sourcename.isEmpty()) - sourcename = "KMyMoney Currency"; - - if (quoteSources().contains(sourcename)) - d->m_source = WebPriceQuoteSource(sourcename); - else - emit error(i18n("Source %1 does not exist.", sourcename)); - - KUrl url; - - // if the source has room for TWO symbols.. - if (d->m_source.m_url.contains("%2")) { - // this is a two-symbol quote. split the symbol into two. valid symbol - // characters are: 0-9, A-Z and the dot. anything else is a separator - QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive); - // if we've truly found 2 symbols delimited this way... - if (splitrx.indexIn(d->m_symbol) != -1) - url = KUrl(d->m_source.m_url.arg(splitrx.cap(1), splitrx.cap(2))); - else - kDebug(Private::dbgArea()) << "WebPriceQuote::launch() did not find 2 symbols"; - } else - // a regular one-symbol quote - url = KUrl(d->m_source.m_url.arg(d->m_symbol)); - - if (url.isLocalFile()) { - emit status(i18nc("The process x is executing", "Executing %1...", url.toLocalFile())); - - d->m_filter.clearProgram(); - d->m_filter << url.toLocalFile().split(' ', QString::SkipEmptyParts); - d->m_filter.setSymbol(d->m_symbol); - - d->m_filter.setOutputChannelMode(KProcess::MergedChannels); - d->m_filter.start(); - - if (d->m_filter.waitForStarted()) { - result = true; - } else { - emit error(i18n("Unable to launch: %1", url.toLocalFile())); - slotParseQuote(QString()); - } - } else { - emit status(i18n("Fetching URL %1...", url.prettyUrl())); - - QString tmpFile; - if (KIO::NetAccess::download(url, tmpFile, 0)) { - // kDebug(Private::dbgArea()) << "Downloaded " << tmpFile; - kDebug(Private::dbgArea()) << "Downloaded" << tmpFile << "from" << url; - QFile f(tmpFile); - if (f.open(QIODevice::ReadOnly)) { - result = true; - // Find out the page encoding and convert it to unicode - QByteArray page = f.readAll(); - KEncodingProber prober(KEncodingProber::Universal); - prober.feed(page); - QTextCodec* codec = QTextCodec::codecForName(prober.encoding()); - if (!codec) - codec = QTextCodec::codecForLocale(); - QString quote = codec->toUnicode(page); - f.close(); - slotParseQuote(quote); - } else { - emit error(i18n("Failed to open downloaded file")); - slotParseQuote(QString()); - } - KIO::NetAccess::removeTempFile(tmpFile); - } else { - emit error(KIO::NetAccess::lastErrorString()); - slotParseQuote(QString()); - } - } - return result; -} - -bool WebPriceQuote::launchFinanceQuote(const QString& _symbol, const QString& _id, - const QString& _sourcename) -{ - bool result = true; - d->m_symbol = _symbol; - d->m_id = _id; - QString FQSource = _sourcename.section(' ', 1); - d->m_source = WebPriceQuoteSource(_sourcename, m_financeQuoteScriptPath, - "\"([^,\"]*)\",.*", // symbol regexp - "[^,]*,[^,]*,\"([^\"]*)\"", // price regexp - "[^,]*,([^,]*),.*", // date regexp - "%y-%m-%d"); // date format - - //emit status(QString("(Debug) symbol=%1 id=%2...").arg(_symbol,_id)); - - d->m_filter.clearProgram(); - d->m_filter << "perl" << m_financeQuoteScriptPath << FQSource << KShell::quoteArg(_symbol); - d->m_filter.setSymbol(d->m_symbol); - emit status(i18nc("Executing 'script' 'online source' 'investment symbol' ", "Executing %1 %2 %3...", m_financeQuoteScriptPath, FQSource, _symbol)); - - d->m_filter.setOutputChannelMode(KProcess::MergedChannels); - d->m_filter.start(); - - // This seems to work best if we just block until done. - if (d->m_filter.waitForFinished()) { - result = true; - } else { - emit error(i18n("Unable to launch: %1", m_financeQuoteScriptPath)); - slotParseQuote(QString()); - } - - return result; -} - -void WebPriceQuote::slotParseQuote(const QString& _quotedata) -{ - QString quotedata = _quotedata; - d->m_quoteData = quotedata; - bool gotprice = false; - bool gotdate = false; - - kDebug(Private::dbgArea()) << "quotedata" << _quotedata; - - if (! quotedata.isEmpty()) { - if (!d->m_source.m_skipStripping) { - // - // First, remove extranous non-data elements - // - - // HTML tags - quotedata.remove(QRegExp("<[^>]*>")); - - // &...;'s - quotedata.replace(QRegExp("&\\w+;"), " "); - - // Extra white space - quotedata = quotedata.simplified(); - kDebug(Private::dbgArea()) << "stripped text" << quotedata; - } - - QRegExp symbolRegExp(d->m_source.m_sym); - QRegExp dateRegExp(d->m_source.m_date); - QRegExp priceRegExp(d->m_source.m_price); - - if (symbolRegExp.indexIn(quotedata) > -1) { - kDebug(Private::dbgArea()) << "Symbol" << symbolRegExp.cap(1); - emit status(i18n("Symbol found: '%1'", symbolRegExp.cap(1))); - } - - if (priceRegExp.indexIn(quotedata) > -1) { - gotprice = true; - - // Deal with european quotes that come back as X.XXX,XX or XX,XXX - // - // We will make the assumption that ALL prices have a decimal separator. - // So "1,000" always means 1.0, not 1000.0. - // - // Remove all non-digits from the price string except the last one, and - // set the last one to a period. - QString pricestr = priceRegExp.cap(1); - - int pos = pricestr.lastIndexOf(QRegExp("\\D")); - if (pos > 0) { - pricestr[pos] = '.'; - pos = pricestr.lastIndexOf(QRegExp("\\D"), pos - 1); - } - while (pos > 0) { - pricestr.remove(pos, 1); - pos = pricestr.lastIndexOf(QRegExp("\\D"), pos); - } - - d->m_price = pricestr.toDouble(); - kDebug(Private::dbgArea()) << "Price" << pricestr; - emit status(i18n("Price found: '%1' (%2)", pricestr, d->m_price)); - } - - if (dateRegExp.indexIn(quotedata) > -1) { - QString datestr = dateRegExp.cap(1); - - MyMoneyDateFormat dateparse(d->m_source.m_dateformat); - try { - d->m_date = dateparse.convertString(datestr, false /*strict*/); - gotdate = true; - kDebug(Private::dbgArea()) << "Date" << datestr; - emit status(i18n("Date found: '%1'", d->m_date.toString()));; - } catch (const MyMoneyException &) { - // emit error(i18n("Unable to parse date %1 using format %2: %3").arg(datestr,dateparse.format(),e.what())); - d->m_date = QDate::currentDate(); - gotdate = true; - } - } - - if (gotprice && gotdate) { - emit quote(d->m_id, d->m_symbol, d->m_date, d->m_price); - } else { - emit error(i18n("Unable to update price for %1 (no price or no date)", d->m_symbol)); - emit failed(d->m_id, d->m_symbol); - } - } else { - emit error(i18n("Unable to update price for %1 (empty quote data)", d->m_symbol)); - emit failed(d->m_id, d->m_symbol); - } -} - -const QMap WebPriceQuote::defaultQuoteSources() -{ - QMap result; - - // Use fx-rate.net as the standard currency exchange rate source until - // we have the capability to use more than one source. Use a neutral - // name for the source. - result["KMyMoney Currency"] = WebPriceQuoteSource("KMyMoney Currency", - "https://fx-rate.net/%1/%2", - QString(), // symbolregexp - "1[ a-zA-Z]+=\\s*([,\\d+\\.]+)", - "updated\\s\\d+:\\d+:\\d+\\(\\w+\\)\\s+(\\d{1,2}/\\d{2}/\\d{4})", - "%d/%m/%y", - true // skip HTML stripping - ); - - result["Globe & Mail"] = WebPriceQuoteSource("Globe & Mail", - "http://globefunddb.theglobeandmail.com/gishome/plsql/gis.price_history?pi_fund_id=%1", - QString(), // symbolregexp - "Reinvestment Price \\w+ \\d+, \\d+ (\\d+\\.\\d+)", // priceregexp - "Reinvestment Price (\\w+ \\d+, \\d+)", // dateregexp - "%m %d %y" // dateformat - ); - - result["MSN.CA"] = WebPriceQuoteSource("MSN.CA", - "http://ca.moneycentral.msn.com/investor/quotes/quotes.asp?symbol=%1", - QString(), // symbolregexp - "(\\d+\\.\\d+) [+-]\\d+.\\d+", // priceregexp - "Time of last trade (\\d+/\\d+/\\d+)", //dateregexp - "%d %m %y" // dateformat - ); - // Finanztreff (replaces VWD.DE) and boerseonline supplied by Micahel Zimmerman - result["Finanztreff"] = WebPriceQuoteSource("Finanztreff", - "http://finanztreff.de/kurse_einzelkurs_detail.htn?u=100&i=%1", - QString(), // symbolregexp - "([0-9]+,\\d+).+Gattung:Fonds", // priceregexp - "\\).(\\d+\\D+\\d+\\D+\\d+)", // dateregexp (doesn't work; date in chart - "%d.%m.%y" // dateformat - ); - - result["boerseonline"] = WebPriceQuoteSource("boerseonline", - "http://www.boerse-online.de/tools/boerse/einzelkurs_kurse.htm?&s=%1", - QString(), // symbolregexp - "Akt\\. Kurs.([\\d\\.]+,\\d\\d)", // priceregexp - "Datum.(\\d+\\.\\d+\\.\\d+)", // dateregexp (doesn't work; date in chart - "%d.%m.%y" // dateformat - ); - - // The following two price sources were contributed by - // Marc Zahnlecker - - result["Wallstreet-Online.DE (Default)"] = WebPriceQuoteSource("Wallstreet-Online.DE (Default)", - "http://www.wallstreet-online.de/si/?k=%1&spid=ws", - "Symbol:(\\w+)", // symbolregexp - "Letzter Kurs: ([0-9.]+,\\d+)", // priceregexp - ", (\\d+\\D+\\d+\\D+\\d+)", // dateregexp - "%d %m %y" // dateformat - ); - // This quote source provided by e-mail and should replace the previous one: - // From: David Houlden - // To: kmymoney@kde.org - // Date: Sat, 6 Apr 2013 13:22:45 +0100 - result["Financial Times UK Funds"] = WebPriceQuoteSource("Financial Times UK Funds", - "http://funds.ft.com/uk/Tearsheet/Summary?s=%1", - "data-display-symbol=\"(.*):", // symbol regexp - "class=\"text first\">([\\d,]*\\d+\\.\\d+)", // price regexp - "As of market close\\ (.*)\\.", // date regexp - "%m %d %y", // date format - true // skip HTML stripping - ); - - // (tf2k) The "mpid" is I think the market place id. In this case five - // stands for Hamburg. - // - // Here the id for several market places: 2 Frankfurt, 3 Berlin, 4 - // Düsseldorf, 5 Hamburg, 6 München/Munich, 7 Hannover, 9 Stuttgart, 10 - // Xetra, 32 NASDAQ, 36 NYSE - - result["Wallstreet-Online.DE (Hamburg)"] = WebPriceQuoteSource("Wallstreet-Online.DE (Hamburg)", - "http://fonds.wallstreet-online.de/si/?k=%1&spid=ws&mpid=5", - "Symbol:(\\w+)", // symbolregexp - "Fonds \\(EUR\\) ([0-9.]+,\\d+)", // priceregexp - ", (\\d+\\D+\\d+\\D+\\d+)", // dateregexp - "%d %m %y" // dateformat - ); - - // The following price quote was contributed by - // Piotr Adacha - - // I would like to post new Online Query Settings for KMyMoney. This set is - // suitable to query stooq.com service, providing quotes for stocks, futures, - // mutual funds and other financial instruments from Polish Gielda Papierow - // Wartosciowych (GPW). Unfortunately, none of well-known international - // services provide quotes for this market (biggest one in central and eastern - // Europe), thus, I think it could be helpful for Polish users of KMyMoney (and - // I am one of them for almost a year). - - result["Gielda Papierow Wartosciowych (GPW)"] = WebPriceQuoteSource("Gielda Papierow Wartosciowych (GPW)", - "http://stooq.com/q/?s=%1", - QString(), // symbol regexp - "Last.*(\\d+\\.\\d+).*Date", // price regexp - "(\\d{4,4}-\\d{2,2}-\\d{2,2})", // date regexp - "%y %m %d" // date format - ); - - // The following price quote is for getting prices of different funds - // at OMX Baltic market. - result["OMX Baltic funds"] = WebPriceQuoteSource("OMX Baltic funds", - "http://www.baltic.omxgroup.com/market/?pg=nontradeddetails¤cy=0&instrument=%1", - QString(), // symbolregexp - "NAV (\\d+,\\d+)", // priceregexp - "Kpv (\\d+.\\d+.\\d+)", // dateregexp - "%d.%m.%y" // dateformat - ); - - // The following price quote was contributed by - // Peter Hargreaves - // The original posting can be found here: - // http://sourceforge.net/mailarchive/message.php?msg_name=200806060854.11682.pete.h%40pdh-online.info - - // I have PEP and ISA accounts which I invest in Funds with Barclays - // Stockbrokers. They give me Fund data via Financial Express: - // - // https://webfund6.financialexpress.net/Clients/Barclays/default.aspx - // - // A typical Fund Factsheet is: - // - // https://webfund6.financialexpress.net/Clients/Barclays/search_factsheet_summary.aspx?code=0585239 - // - // On the Factsheet to identify the fund you can see ISIN Code GB0005852396. - // In the url, this code is shortened by loosing the first four and last - // characters. - // - // Update: - // - // Nick Elliot has contributed a modified regular expression to cope with values presented - // in pounds as well as those presented in pence. The source can be found here: - // http://forum.kde.org/update-stock-and-currency-prices-t-32049.html - - result["Financial Express"] = WebPriceQuoteSource("Financial Express", - "https://webfund6.financialexpress.net/Clients/Barclays/search_factsheet_summary.aspx?code=%1", - "ISIN Code[^G]*(GB..........).*", // symbolregexp - "Current Market Information[^0-9]*([0-9,\\.]+).*", // priceregexp - "Price Date[^0-9]*(../../....).*", // dateregexp - "%d/%m/%y" // dateformat - ); - - - // I suggest to include www.cash.ch as one of the pre-populated online - // quote sources. - - // Rationale - // It features Swiss funds that are otherwise hard to find. A typical - // example: Swiss private pension accounts (in German termed 'Säule 3a') - // may usually only invest in dedicated funds that are otherwise (almost) - // not traded; the UBS Vitainvest series - // (http://www.ubs.com/1/e/ubs_ch/private/insurance/fisca/securities/part_wealth.html) - // is such a series of funds. - - result["Cash CH"] = WebPriceQuoteSource("Cash CH", - "http://www.cash.ch/boerse/fonds/fondsguide/kursinfo/fullquote/%1", - "", // symbolregexp - "([1-9][0-9]*\\.[0-9][0-9])", // priceregexp - "([0-3][0-9]\\.[0-1][0-9]\\.[1-2][0-9][0-9][0-9])", // dateregexp - "%d.%m.%y", // dateformat - true // skip stripping - ); - - return result; -} - -const QStringList WebPriceQuote::quoteSources(const _quoteSystemE _system) -{ - if (_system == Native) - return (quoteSourcesNative()); - else - return (quoteSourcesFinanceQuote()); -} - -const QStringList WebPriceQuote::quoteSourcesNative() -{ - KSharedConfigPtr kconfig = KGlobal::config(); - QStringList groups = kconfig->groupList(); - - QStringList::Iterator it; - QRegExp onlineQuoteSource(QString("^Online-Quote-Source-(.*)$")); - - // get rid of all 'non online quote source' entries - for (it = groups.begin(); it != groups.end(); it = groups.erase(it)) { - if (onlineQuoteSource.indexIn(*it) >= 0) { - // Insert the name part - it = groups.insert(it, onlineQuoteSource.cap(1)); - ++it; - } - } - - // if the user has the OLD quote source defined, now is the - // time to remove that entry and convert it to the new system. - if (! groups.count() && kconfig->hasGroup("Online Quotes Options")) { - KConfigGroup grp = kconfig->group("Online Quotes Options"); - QString url(grp.readEntry("URL", "http://finance.yahoo.com/d/quotes.csv?s=%1&f=sl1d1")); - QString symbolRegExp(grp.readEntry("SymbolRegex", "\"([^,\"]*)\",.*")); - QString priceRegExp(grp.readEntry("PriceRegex", "[^,]*,([^,]*),.*")); - QString dateRegExp(grp.readEntry("DateRegex", "[^,]*,[^,]*,\"([^\"]*)\"")); - kconfig->deleteGroup("Online Quotes Options"); - - groups += "Old Source"; - grp = kconfig->group(QString("Online-Quote-Source-%1").arg("Old Source")); - grp.writeEntry("URL", url); - grp.writeEntry("SymbolRegex", symbolRegExp); - grp.writeEntry("PriceRegex", priceRegExp); - grp.writeEntry("DateRegex", dateRegExp); - grp.writeEntry("DateFormatRegex", "%m %d %y"); - grp.sync(); - } - - // Set up each of the default sources. These are done piecemeal so that - // when we add a new source, it's automatically picked up. And any changes - // are also picked up. - QMap defaults = defaultQuoteSources(); - QMap::const_iterator it_source = defaults.constBegin(); - while (it_source != defaults.constEnd()) { - if (! groups.contains((*it_source).m_name)) { - groups += (*it_source).m_name; - (*it_source).write(); - kconfig->sync(); - } - ++it_source; - } - - return groups; -} - -const QStringList WebPriceQuote::quoteSourcesFinanceQuote() -{ - if (m_financeQuoteSources.empty()) { // run the process one time only - // since this is a static function it can be called without constructing an object - // so we need to make sure that m_financeQuoteScriptPath is properly initialized - if (m_financeQuoteScriptPath.isEmpty()) { - m_financeQuoteScriptPath = KGlobal::dirs()->findResource("appdata", - QString("misc/financequote.pl")); - } - FinanceQuoteProcess getList; - getList.launch(m_financeQuoteScriptPath); - while (!getList.isFinished()) { - kapp->processEvents(); - } - m_financeQuoteSources = getList.getSourceList(); - } - return (m_financeQuoteSources); -} - -// -// Helper class to load/save an individual source -// - -WebPriceQuoteSource::WebPriceQuoteSource(const QString& name, const QString& url, const QString& sym, const QString& price, const QString& date, const QString& dateformat, bool skipStripping): - m_name(name), - m_url(url), - m_sym(sym), - m_price(price), - m_date(date), - m_dateformat(dateformat), - m_skipStripping(skipStripping) -{ } - -WebPriceQuoteSource::WebPriceQuoteSource(const QString& name) -{ - m_name = name; - KSharedConfigPtr kconfig = KGlobal::config(); - KConfigGroup grp = kconfig->group(QString("Online-Quote-Source-%1").arg(m_name)); - m_sym = grp.readEntry("SymbolRegex"); - m_date = grp.readEntry("DateRegex"); - m_dateformat = grp.readEntry("DateFormatRegex", "%m %d %y"); - m_price = grp.readEntry("PriceRegex"); - m_url = grp.readEntry("URL"); - m_skipStripping = grp.readEntry("SkipStripping", false); -} - -void WebPriceQuoteSource::write() const -{ - KSharedConfigPtr kconfig = KGlobal::config(); - KConfigGroup grp = kconfig->group(QString("Online-Quote-Source-%1").arg(m_name)); - grp.writeEntry("URL", m_url); - grp.writeEntry("PriceRegex", m_price); - grp.writeEntry("DateRegex", m_date); - grp.writeEntry("DateFormatRegex", m_dateformat); - grp.writeEntry("SymbolRegex", m_sym); - if (m_skipStripping) - grp.writeEntry("SkipStripping", m_skipStripping); - else - grp.deleteEntry("SkipStripping"); -} - -void WebPriceQuoteSource::rename(const QString& name) -{ - remove(); - m_name = name; - write(); -} - -void WebPriceQuoteSource::remove() const -{ - KSharedConfigPtr kconfig = KGlobal::config(); - kconfig->deleteGroup(QString("Online-Quote-Source-%1").arg(m_name)); -} - -// -// Helper class to babysit the KProcess used for running the local script in that case -// - -WebPriceQuoteProcess::WebPriceQuoteProcess() -{ - connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReceivedDataFromFilter())); - connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcessExited(int,QProcess::ExitStatus))); -} - -void WebPriceQuoteProcess::slotReceivedDataFromFilter() -{ -// kDebug(2) << "WebPriceQuoteProcess::slotReceivedDataFromFilter(): " << QString(data); - m_string += QString(readAllStandardOutput()); -} - -void WebPriceQuoteProcess::slotProcessExited(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) -{ -// kDebug(2) << "WebPriceQuoteProcess::slotProcessExited()"; - emit processExited(m_string); - m_string.truncate(0); -} - -// -// Helper class to babysit the KProcess used for running the Finance Quote sources script -// - -FinanceQuoteProcess::FinanceQuoteProcess() -{ - m_isDone = false; - m_string = ""; - m_fqNames["aex"] = "AEX"; - m_fqNames["aex_futures"] = "AEX Futures"; - m_fqNames["aex_options"] = "AEX Options"; - m_fqNames["amfiindia"] = "AMFI India"; - m_fqNames["asegr"] = "ASE"; - m_fqNames["asia"] = "Asia (Yahoo, ...)"; - m_fqNames["asx"] = "ASX"; - m_fqNames["australia"] = "Australia (ASX, Yahoo, ...)"; - m_fqNames["bmonesbittburns"] = "BMO NesbittBurns"; - m_fqNames["brasil"] = "Brasil (Yahoo, ...)"; - m_fqNames["canada"] = "Canada (Yahoo, ...)"; - m_fqNames["canadamutual"] = "Canada Mutual (Fund Library, ...)"; - m_fqNames["deka"] = "Deka Investments"; - m_fqNames["dutch"] = "Dutch (AEX, ...)"; - m_fqNames["dwsfunds"] = "DWS"; - m_fqNames["europe"] = "Europe (Yahoo, ...)"; - m_fqNames["fidelity"] = "Fidelity (Fidelity, ...)"; - m_fqNames["fidelity_direct"] = "Fidelity Direct"; - m_fqNames["financecanada"] = "Finance Canada"; - m_fqNames["ftportfolios"] = "First Trust (First Trust, ...)"; - m_fqNames["ftportfolios_direct"] = "First Trust Portfolios"; - m_fqNames["fundlibrary"] = "Fund Library"; - m_fqNames["greece"] = "Greece (ASE, ...)"; - m_fqNames["indiamutual"] = "India Mutual (AMFI, ...)"; - m_fqNames["maninv"] = "Man Investments"; - m_fqNames["fool"] = "Motley Fool"; - m_fqNames["nasdaq"] = "Nasdaq (Yahoo, ...)"; - m_fqNames["nz"] = "New Zealand (Yahoo, ...)"; - m_fqNames["nyse"] = "NYSE (Yahoo, ...)"; - m_fqNames["nzx"] = "NZX"; - m_fqNames["platinum"] = "Platinum Asset Management"; - m_fqNames["seb_funds"] = "SEB"; - m_fqNames["sharenet"] = "Sharenet"; - m_fqNames["za"] = "South Africa (Sharenet, ...)"; - m_fqNames["troweprice_direct"] = "T. Rowe Price"; - m_fqNames["troweprice"] = "T. Rowe Price"; - m_fqNames["tdefunds"] = "TD Efunds"; - m_fqNames["tdwaterhouse"] = "TD Waterhouse Canada"; - m_fqNames["tiaacref"] = "TIAA-CREF"; - m_fqNames["trustnet"] = "Trustnet"; - m_fqNames["uk_unit_trusts"] = "U.K. Unit Trusts"; - m_fqNames["unionfunds"] = "Union Investments"; - m_fqNames["tsp"] = "US Govt. Thrift Savings Plan"; - m_fqNames["usfedbonds"] = "US Treasury Bonds"; - m_fqNames["usa"] = "USA (Yahoo, Fool ...)"; - m_fqNames["vanguard"] = "Vanguard"; - m_fqNames["vwd"] = "VWD"; - m_fqNames["yahoo"] = "Yahoo"; - m_fqNames["yahoo_asia"] = "Yahoo Asia"; - m_fqNames["yahoo_australia"] = "Yahoo Australia"; - m_fqNames["yahoo_brasil"] = "Yahoo Brasil"; - m_fqNames["yahoo_europe"] = "Yahoo Europe"; - m_fqNames["yahoo_nz"] = "Yahoo New Zealand"; - m_fqNames["zifunds"] = "Zuerich Investments"; - connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReceivedDataFromFilter())); - connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcessExited())); - connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotProcessExited())); -} - -void FinanceQuoteProcess::slotReceivedDataFromFilter() -{ - QByteArray data(readAllStandardOutput()); - -// kDebug(2) << "WebPriceQuoteProcess::slotReceivedDataFromFilter(): " << QString(data); - m_string += QString(data); -} - -void FinanceQuoteProcess::slotProcessExited() -{ -// kDebug(2) << "WebPriceQuoteProcess::slotProcessExited()"; - m_isDone = true; -} - -void FinanceQuoteProcess::launch(const QString& scriptPath) -{ - clearProgram(); - - *this << "perl" << scriptPath << "-l"; - setOutputChannelMode(KProcess::OnlyStdoutChannel); - start(); - if (! waitForStarted()) qWarning("Unable to start FQ script"); - return; -} - -const QStringList FinanceQuoteProcess::getSourceList() const -{ - QStringList raw = m_string.split(0x0A, QString::SkipEmptyParts); - QStringList sources; - QStringList::iterator it; - for (it = raw.begin(); it != raw.end(); ++it) { - if (m_fqNames[*it].isEmpty()) sources.append(*it); - else sources.append(m_fqNames[*it]); - } - sources.sort(); - return (sources); -} - -const QString FinanceQuoteProcess::crypticName(const QString& niceName) const -{ - QString ret(niceName); - fqNameMap::const_iterator it; - for (it = m_fqNames.begin(); it != m_fqNames.end(); ++it) { - if (niceName == it.value()) { - ret = it.key(); - break; - } - } - return (ret); -} - -const QString FinanceQuoteProcess::niceName(const QString& crypticName) const -{ - QString ret(m_fqNames[crypticName]); - if (ret.isEmpty()) ret = crypticName; - return (ret); -} -// -// Universal date converter -// - -// In 'strict' mode, this is designed to be compatable with the QIF profile date -// converter. However, that converter deals with the concept of an apostrophe -// format in a way I don't understand. So for the moment, they are 99% -// compatable, waiting on that issue. (acejones) - -const QDate MyMoneyDateFormat::convertString(const QString& _in, bool _strict, unsigned _centurymidpoint) const -{ - // - // Break date format string into component parts - // - - QRegExp formatrex("%([mdy]+)(\\W+)%([mdy]+)(\\W+)%([mdy]+)", Qt::CaseInsensitive); - if (formatrex.indexIn(m_format) == -1) { - throw MYMONEYEXCEPTION("Invalid format string"); - } - - QStringList formatParts; - formatParts += formatrex.cap(1); - formatParts += formatrex.cap(3); - formatParts += formatrex.cap(5); - - QStringList formatDelimiters; - formatDelimiters += formatrex.cap(2); - formatDelimiters += formatrex.cap(4); - - // - // Break input string up into component parts, - // using the delimiters found in the format string - // - - QRegExp inputrex; - inputrex.setCaseSensitivity(Qt::CaseInsensitive); - - // strict mode means we must enforce the delimiters as specified in the - // format. non-strict allows any delimiters - if (_strict) - inputrex.setPattern(QString("(\\w+)%1(\\w+)%2(\\w+)").arg(formatDelimiters[0], formatDelimiters[1])); - else - inputrex.setPattern("(\\w+)\\W+(\\w+)\\W+(\\w+)"); - - if (inputrex.indexIn(_in) == -1) { - throw MYMONEYEXCEPTION("Invalid input string"); - } - - QStringList scannedParts; - scannedParts += inputrex.cap(1).toLower(); - scannedParts += inputrex.cap(2).toLower(); - scannedParts += inputrex.cap(3).toLower(); - - // - // Convert the scanned parts into actual date components - // - unsigned day = 0, month = 0, year = 0; - bool ok; - QRegExp digitrex("(\\d+)"); - QStringList::const_iterator it_scanned = scannedParts.constBegin(); - QStringList::const_iterator it_format = formatParts.constBegin(); - while (it_scanned != scannedParts.constEnd()) { - // decide upon the first character of the part - switch ((*it_format).at(0).cell()) { - case 'd': - // remove any extraneous non-digits (e.g. read "3rd" as 3) - ok = false; - if (digitrex.indexIn(*it_scanned) != -1) - day = digitrex.cap(1).toUInt(&ok); - if (!ok || day > 31) - throw MYMONEYEXCEPTION(QString("Invalid day entry: %1").arg(*it_scanned)); - break; - case 'm': - month = (*it_scanned).toUInt(&ok); - if (!ok) { - // maybe it's a textual date - unsigned i = 1; - while (i <= 12) { - if (KGlobal::locale()->calendar()->monthName(i, 2000).toLower() == *it_scanned - || KGlobal::locale()->calendar()->monthName(i, 2000, KCalendarSystem::ShortName).toLower() == *it_scanned) - month = i; - ++i; - } - } - - if (month < 1 || month > 12) - throw MYMONEYEXCEPTION(QString("Invalid month entry: %1").arg(*it_scanned)); - - break; - case 'y': - if (_strict && (*it_scanned).length() != (*it_format).length()) - throw MYMONEYEXCEPTION(QString("Length of year (%1) does not match expected length (%2).") - .arg(*it_scanned, *it_format)); - - year = (*it_scanned).toUInt(&ok); - - if (!ok) - throw MYMONEYEXCEPTION(QString("Invalid year entry: %1").arg(*it_scanned)); - - // - // 2-digit year case - // - // this algorithm will pick a year within +/- 50 years of the - // centurymidpoint parameter. i.e. if the midpoint is 2000, - // then 0-49 will become 2000-2049, and 50-99 will become 1950-1999 - if (year < 100) { - unsigned centuryend = _centurymidpoint + 50; - unsigned centurybegin = _centurymidpoint - 50; - - if (year < centuryend % 100) - year += 100; - year += centurybegin - centurybegin % 100; - } - - if (year < 1900) - throw MYMONEYEXCEPTION(QString("Invalid year (%1)").arg(year)); - - break; - default: - throw MYMONEYEXCEPTION("Invalid format character"); - } - - ++it_scanned; - ++it_format; - } - QDate result(year, month, day); - if (! result.isValid()) - throw MYMONEYEXCEPTION(QString("Invalid date (yr%1 mo%2 dy%3)").arg(year).arg(month).arg(day)); - - return result; -} - -// -// Unit test helpers -// - -convertertest::QuoteReceiver::QuoteReceiver(WebPriceQuote* q, QObject* parent) : - QObject(parent) -{ - connect(q, SIGNAL(quote(QString,QString,QDate,double)), - this, SLOT(slotGetQuote(QString,QString,QDate,double))); - connect(q, SIGNAL(status(QString)), - this, SLOT(slotStatus(QString))); - connect(q, SIGNAL(error(QString)), - this, SLOT(slotError(QString))); -} - -convertertest::QuoteReceiver::~QuoteReceiver() -{ -} - -void convertertest::QuoteReceiver::slotGetQuote(const QString&, const QString&, const QDate& d, const double& m) -{ -// kDebug(2) << "test::QuoteReceiver::slotGetQuote( , " << d << " , " << m.toString() << " )"; - - m_price = MyMoneyMoney(m); - m_date = d; -} - -void convertertest::QuoteReceiver::slotStatus(const QString& msg) -{ -// kDebug(2) << "test::QuoteReceiver::slotStatus( " << msg << " )"; - - m_statuses += msg; -} - -void convertertest::QuoteReceiver::slotError(const QString& msg) -{ -// kDebug(2) << "test::QuoteReceiver::slotError( " << msg << " )"; - - m_errors += msg; -} - -// leave this moc until we will have resolved our dependency issues -// now 'converter' depends on 'kmymoney' a pointer to the application -// defined in main.cpp, which makes this static library unusable without -// the --as-needed linker flag; -// otherwise the 'moc' methods of this object will be linked into the automoc -// object file which contains methods from all the other objects from this -// library, thus even if the --as-needed option is used all objects will be -// pulled in while linking 'convertertest' which only needs the WebPriceQuote -// object - spent a whole day investigating this -#include "moc_webpricequote.cpp" diff --git a/kmymoney/dialogs/CMakeLists.txt b/kmymoney/dialogs/CMakeLists.txt --- a/kmymoney/dialogs/CMakeLists.txt +++ b/kmymoney/dialogs/CMakeLists.txt @@ -82,6 +82,7 @@ add_custom_target(generate_dialogs_ui_srcs DEPENDS ${dialogs_ui_srcs}) kde4_add_library(dialogs STATIC ${libdialogs_a_SOURCES} ${dialogs_ui_srcs}) +target_link_libraries(dialogs ${LIBALKIMIA_LIBRARIES}) # we rely on the widgets to be generated add_dependencies(dialogs widgets) diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.h b/kmymoney/dialogs/kequitypriceupdatedlg.h --- a/kmymoney/dialogs/kequitypriceupdatedlg.h +++ b/kmymoney/dialogs/kequitypriceupdatedlg.h @@ -36,7 +36,7 @@ // ---------------------------------------------------------------------------- // Project Includes -#include "webpricequote.h" +#include #include "mymoneysecurity.h" #include "mymoneyprice.h" #include "ui_kequitypriceupdatedlgdecl.h" @@ -78,7 +78,7 @@ private: bool m_fUpdateAll; - WebPriceQuote m_webQuote; + AlkOnlineQuote m_webQuote; }; #endif // KEQUITYPRICEUPDATEDLG_H diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.cpp b/kmymoney/dialogs/kequitypriceupdatedlg.cpp --- a/kmymoney/dialogs/kequitypriceupdatedlg.cpp +++ b/kmymoney/dialogs/kequitypriceupdatedlg.cpp @@ -94,7 +94,7 @@ // // send in securityId == "XXX YYY" to get a single-shot update for XXX to YYY. - // for consistency reasons, this accepts the same delimiters as WebPriceQuote::launch() + // for consistency reasons, this accepts the same delimiters as AlkOnlineQuote::launch() QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive); MyMoneySecurityPair currencyIds; if (splitrx.indexIn(securityId) != -1) { diff --git a/kmymoney/dialogs/kgncpricesourcedlg.cpp b/kmymoney/dialogs/kgncpricesourcedlg.cpp --- a/kmymoney/dialogs/kgncpricesourcedlg.cpp +++ b/kmymoney/dialogs/kgncpricesourcedlg.cpp @@ -34,7 +34,7 @@ // ---------------------------------------------------------------------------- // Project Includes -#include "webpricequote.h" +#include #include "ui_kgncpricesourcedlgdecl.h" @@ -69,7 +69,7 @@ d->widget->textStockName->setText(i18n("Investment: %1", stockName)); d->widget->textGncSource->setText(i18n("Quote source: %1", gncSource)); d->widget->listKnownSource->clear(); - d->widget->listKnownSource->insertItems(0, WebPriceQuote::quoteSources()); + d->widget->listKnownSource->insertItems(0, AlkOnlineQuotesProfileManager::instance().profile("kmymoney")->quoteSources()); d->widget->lineUserSource->setText(gncSource); d->widget->checkAlwaysUse->setChecked(true); d->widget->buttonsSource->setId(d->widget->buttonNoSource, 0); diff --git a/kmymoney/dialogs/settings/CMakeLists.txt b/kmymoney/dialogs/settings/CMakeLists.txt --- a/kmymoney/dialogs/settings/CMakeLists.txt +++ b/kmymoney/dialogs/settings/CMakeLists.txt @@ -5,7 +5,6 @@ ksettingsgeneral.cpp ksettingsgpg.cpp ksettingshome.cpp - ksettingsonlinequotes.cpp ksettingsregister.cpp ksettingsschedules.cpp ksettingsplugins.cpp @@ -15,13 +14,15 @@ set (libsettings_a_UI ksettingscolorsdecl.ui ksettingsfontsdecl.ui ksettingsforecastdecl.ui ksettingsgeneraldecl.ui ksettingsgpgdecl.ui - ksettingshomedecl.ui ksettingsonlinequotesdecl.ui - ksettingsregisterdecl.ui ksettingsschedulesdecl.ui + ksettingshomedecl.ui + ksettingsregisterdecl.ui + ksettingsschedulesdecl.ui ksettingsreportsdecl.ui ) kde4_add_ui_files(libsettings_a_SOURCES ${libsettings_a_UI} ) kde4_add_library(settings STATIC ${libsettings_a_SOURCES}) +target_link_libraries(settings ${LIBALKIMIA_LIBRARIES}) add_dependencies(settings widgets kmm_settings) diff --git a/kmymoney/dialogs/settings/ksettingsonlinequotes.h b/kmymoney/dialogs/settings/ksettingsonlinequotes.h deleted file mode 100644 --- a/kmymoney/dialogs/settings/ksettingsonlinequotes.h +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - ksettingsonlinequotes.h - ------------------- - begin : Thu Dec 30 2004 - copyright : (C) 2004 by Thomas Baumgart - email : Thomas Baumgart - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KSETTINGSONLINEQUOTES_H -#define KSETTINGSONLINEQUOTES_H - -// ---------------------------------------------------------------------------- -// QT Includes - -#include - -// ---------------------------------------------------------------------------- -// KDE Includes - -// ---------------------------------------------------------------------------- -// Project Includes - -#include "ui_ksettingsonlinequotesdecl.h" -#include "kmymoney/converter/webpricequote.h" - - -class KSettingsOnlineQuotesDecl : public QWidget, public Ui::KSettingsOnlineQuotesDecl -{ -public: - KSettingsOnlineQuotesDecl(QWidget *parent) : QWidget(parent) { - setupUi(this); - } -}; - -class KSettingsOnlineQuotes : public KSettingsOnlineQuotesDecl -{ - Q_OBJECT -public: - KSettingsOnlineQuotes(QWidget* parent = 0); - virtual ~KSettingsOnlineQuotes() {} - - void writeConfig() {} - void readConfig() {} - void resetConfig(); - -protected slots: - void slotUpdateEntry(); - void slotLoadWidgets(); - void slotEntryChanged(); - void slotNewEntry(); - void slotEntryRenamed(QListWidgetItem* item); - void slotStartRename(QListWidgetItem* item); - -protected: - void loadList(const bool updateResetList = false); - -private: - QList m_resetList; - WebPriceQuoteSource m_currentItem; - bool m_quoteInEditing; -}; - -#endif diff --git a/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp b/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp deleted file mode 100644 --- a/kmymoney/dialogs/settings/ksettingsonlinequotes.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/*************************************************************************** - ksettingsonlinequotes.cpp - ------------------- - begin : Thu Dec 30 2004 - copyright : (C) 2004 by Thomas Baumgart - email : Thomas Baumgart - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "ksettingsonlinequotes.h" - -// ---------------------------------------------------------------------------- -// QT Includes - -#include -#include - -// ---------------------------------------------------------------------------- -// KDE Includes - -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -// Project Includes - -#include "kmymoney/converter/webpricequote.h" - -KSettingsOnlineQuotes::KSettingsOnlineQuotes(QWidget *parent) - : KSettingsOnlineQuotesDecl(parent), - m_quoteInEditing(false) -{ - QStringList groups = WebPriceQuote::quoteSources(); - - loadList(true /*updateResetList*/); - - m_updateButton->setEnabled(false); - - KGuiItem updateButtenItem(i18nc("Accepts the entered data and stores it", "&Update"), - KIcon("dialog-ok"), - i18n("Accepts the entered data and stores it"), - i18n("Use this to accept the modified data.")); - m_updateButton->setGuiItem(updateButtenItem); - - KGuiItem deleteButtenItem(i18n("&Delete"), - KIcon("edit-delete"), - i18n("Delete the selected source entry"), - i18n("Use this to delete the selected online source entry")); - m_deleteButton->setGuiItem(deleteButtenItem); - - KGuiItem newButtenItem(i18nc("Create a new source entry for online quotes", "&New..."), - KIcon("document-new"), - i18n("Create a new source entry for online quotes"), - i18n("Use this to create a new entry for online quotes")); - m_newButton->setGuiItem(newButtenItem); - - connect(m_updateButton, SIGNAL(clicked()), this, SLOT(slotUpdateEntry())); - connect(m_newButton, SIGNAL(clicked()), this, SLOT(slotNewEntry())); - - connect(m_quoteSourceList, SIGNAL(itemSelectionChanged()), this, SLOT(slotLoadWidgets())); - connect(m_quoteSourceList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotEntryRenamed(QListWidgetItem*))); - connect(m_quoteSourceList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotStartRename(QListWidgetItem*))); - - connect(m_editURL, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged())); - connect(m_editSymbol, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged())); - connect(m_editDate, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged())); - connect(m_editDateFormat, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged())); - connect(m_editPrice, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged())); - connect(m_skipStripping, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); - - // FIXME deleting a source is not yet implemented - m_deleteButton->setEnabled(false); -} - -void KSettingsOnlineQuotes::loadList(const bool updateResetList) -{ - //disconnect the slot while items are being loaded and reconnect at the end - disconnect(m_quoteSourceList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotEntryRenamed(QListWidgetItem*))); - m_quoteInEditing = false; - QStringList groups = WebPriceQuote::quoteSources(); - - if (updateResetList) - m_resetList.clear(); - m_quoteSourceList->clear(); - QStringList::Iterator it; - for (it = groups.begin(); it != groups.end(); ++it) { - QListWidgetItem* item = new QListWidgetItem(*it); - item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); - m_quoteSourceList->addItem(item); - if (updateResetList) - m_resetList += WebPriceQuoteSource(*it); - } - m_quoteSourceList->sortItems(); - - QListWidgetItem* first = m_quoteSourceList->item(0); - if (first) - m_quoteSourceList->setCurrentItem(first); - slotLoadWidgets(); - - m_newButton->setEnabled((m_quoteSourceList->findItems(i18n("New Quote Source"), Qt::MatchExactly)).count() == 0); - connect(m_quoteSourceList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotEntryRenamed(QListWidgetItem*))); -} - -void KSettingsOnlineQuotes::resetConfig() -{ - QStringList::ConstIterator it; - QStringList groups = WebPriceQuote::quoteSources(); - - // delete all currently defined entries - for (it = groups.constBegin(); it != groups.constEnd(); ++it) { - WebPriceQuoteSource(*it).remove(); - } - - // and write back the one's from the reset list - QList::ConstIterator itr; - for (itr = m_resetList.constBegin(); itr != m_resetList.constEnd(); ++itr) { - (*itr).write(); - } - - loadList(); -} - -void KSettingsOnlineQuotes::slotLoadWidgets() -{ - m_quoteInEditing = false; - QListWidgetItem* item = m_quoteSourceList->currentItem(); - - m_editURL->setEnabled(true); - m_editSymbol->setEnabled(true); - m_editPrice->setEnabled(true); - m_editDate->setEnabled(true); - m_editDateFormat->setEnabled(true); - m_skipStripping->setEnabled(true); - m_editURL->setText(QString()); - m_editSymbol->setText(QString()); - m_editPrice->setText(QString()); - m_editDate->setText(QString()); - m_editDateFormat->setText(QString()); - - if (item) { - m_currentItem = WebPriceQuoteSource(item->text()); - m_editURL->setText(m_currentItem.m_url); - m_editSymbol->setText(m_currentItem.m_sym); - m_editPrice->setText(m_currentItem.m_price); - m_editDate->setText(m_currentItem.m_date); - m_editDateFormat->setText(m_currentItem.m_dateformat); - m_skipStripping->setChecked(m_currentItem.m_skipStripping); - } else { - m_editURL->setEnabled(false); - m_editSymbol->setEnabled(false); - m_editPrice->setEnabled(false); - m_editDate->setEnabled(false); - m_editDateFormat->setEnabled(false); - m_skipStripping->setEnabled(false); - } - - m_updateButton->setEnabled(false); - -} - -void KSettingsOnlineQuotes::slotEntryChanged() -{ - bool modified = m_editURL->text() != m_currentItem.m_url - || m_editSymbol->text() != m_currentItem.m_sym - || m_editDate->text() != m_currentItem.m_date - || m_editDateFormat->text() != m_currentItem.m_dateformat - || m_editPrice->text() != m_currentItem.m_price - || m_skipStripping->isChecked() != m_currentItem.m_skipStripping; - - m_updateButton->setEnabled(modified); -} - -void KSettingsOnlineQuotes::slotUpdateEntry() -{ - m_currentItem.m_url = m_editURL->text(); - m_currentItem.m_sym = m_editSymbol->text(); - m_currentItem.m_date = m_editDate->text(); - m_currentItem.m_dateformat = m_editDateFormat->text(); - m_currentItem.m_price = m_editPrice->text(); - m_currentItem.m_skipStripping = m_skipStripping->isChecked(); - m_currentItem.write(); - slotEntryChanged(); -} - -void KSettingsOnlineQuotes::slotNewEntry() -{ - WebPriceQuoteSource newSource(i18n("New Quote Source")); - newSource.write(); - loadList(); - QListWidgetItem* item = m_quoteSourceList->findItems(i18n("New Quote Source"), Qt::MatchExactly).at(0); - if (item) { - m_quoteSourceList->setCurrentItem(item); - slotLoadWidgets(); - } -} - -void KSettingsOnlineQuotes::slotStartRename(QListWidgetItem* item) -{ - m_quoteInEditing = true; - m_quoteSourceList->editItem(item); -} - -void KSettingsOnlineQuotes::slotEntryRenamed(QListWidgetItem* item) -{ - //if there is no current item selected, exit - if (m_quoteInEditing == false || !m_quoteSourceList->currentItem() || item != m_quoteSourceList->currentItem()) - return; - - m_quoteInEditing = false; - QString text = item->text(); - int nameCount = 0; - for (int i = 0; i < m_quoteSourceList->count(); ++i) { - if (m_quoteSourceList->item(i)->text() == text) - ++nameCount; - } - - // Make sure we get a non-empty and unique name - if (text.length() > 0 && nameCount == 1) { - m_currentItem.rename(text); - } else { - item->setText(m_currentItem.m_name); - } - m_quoteSourceList->sortItems(); - m_newButton->setEnabled(m_quoteSourceList->findItems(i18n("New Quote Source"), Qt::MatchExactly).count() == 0); -} diff --git a/kmymoney/dialogs/settings/ksettingsonlinequotesdecl.ui b/kmymoney/dialogs/settings/ksettingsonlinequotesdecl.ui deleted file mode 100644 --- a/kmymoney/dialogs/settings/ksettingsonlinequotesdecl.ui +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - KSettingsOnlineQuotesDecl - - - - 0 - 0 - 512 - 442 - - - - - 0 - 0 - - - - Online Quotes - - - - - - - 7 - 3 - 0 - 0 - - - - - Name - - - true - - - true - - - - - - - - Details - - - <i>Enter regular expressions which can be used to parse the data returned from the URL entered above. The symbol, price, and date must be found in the quote data to be usable. You may also try the KMyMoney user's mailinglist at <a href="mailto:kmymoney@kde.org">kmymoney@kde.org</a> to find what settings work for other users in your country.</i> - - - - - - Date - - - false - - - - - - - Symbol - - - false - - - - - - - Regular Expression to extract the symbol from the downloaded data - - - - - - - Regular Expression to extract the price from the downloaded data - - - - - - - URL to be used to download the quote - - - Enter the URL from which stock quotes will be fetched. <b>%1</b> will be replaced with the symbol for the security being quoted. For currency conversions, <b>%2</b> will be replaced with the currency to be quoted and <b>%1</b> with the currency the quote is based on. - - - - - - - Price - - - false - - - - - - - Regular Expression to extract the date from the downloaded data - - - - - - - Date Format - - - false - - - - - - - URL - - - false - - - - - - - Regular Expression to extract the date from the downloaded data - - - - - - - Skip HTML stripping - - - <p>For easier processing of the data returned by the online source, KMyMoney usually strips unused parts before it is parsed with the regular expressions. If matching of the fields relies on those items, then use this option to turn stripping off.</p> - -<p>The following items are usually removed by stripping: - -<ul> -<li>HTML tags such as <b>&lt;tag&gt;</b></li> -<li>& encoded characters such as <b>&amp;nbsp;</b></li> -<li>duplicate whitespace</li> -</ul> -</p> - - - - - - - - - - - - New - - - - - - - Delete - - - - - - - - 240 - 20 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - Update - - - - - - - - - - - KListWidget - QListWidget -
klistwidget.h
-
-
-
diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -93,6 +93,9 @@ #include #endif +#include +#include + // ---------------------------------------------------------------------------- // Project Includes @@ -105,7 +108,6 @@ #include "dialogs/settings/ksettingscolors.h" #include "dialogs/settings/ksettingsfonts.h" #include "dialogs/settings/ksettingsschedules.h" -#include "dialogs/settings/ksettingsonlinequotes.h" #include "dialogs/settings/ksettingshome.h" #include "dialogs/settings/ksettingsforecast.h" #include "dialogs/settings/ksettingsplugins.h" @@ -381,6 +383,8 @@ KXmlGuiWindow(parent), d(new Private(this)) { + AlkOnlineQuotesProfileManager::instance().addProfile(new AlkOnlineQuotesProfile("kmymoney", AlkOnlineQuotesProfile::Type::KMyMoney, "kmymoney-quotes.knsrc")); + new KmymoneyAdaptor(this); QDBusConnection::sessionBus().registerObject("/KMymoney", this); QDBusConnection::sessionBus().interface()->registerService( @@ -2522,7 +2526,7 @@ KSettingsGpg* encryptionPage = new KSettingsGpg(); KSettingsColors* colorsPage = new KSettingsColors(); KSettingsFonts* fontsPage = new KSettingsFonts(); - KSettingsOnlineQuotes* onlineQuotesPage = new KSettingsOnlineQuotes(); + AlkOnlineQuotesWidget *onlineQuotesPage = new AlkOnlineQuotesWidget; KSettingsForecast* forecastPage = new KSettingsForecast(); KSettingsPlugins* pluginsPage = new KSettingsPlugins(); KSettingsReports* reportsPage = new KSettingsReports(); diff --git a/kmymoney/mymoney/storage/CMakeLists.txt b/kmymoney/mymoney/storage/CMakeLists.txt --- a/kmymoney/mymoney/storage/CMakeLists.txt +++ b/kmymoney/mymoney/storage/CMakeLists.txt @@ -18,6 +18,7 @@ # This library is actually not needed. It is built just for # convenience, and then linked into kmm_mymoney. kde4_add_library( kmm_storage STATIC ${storage_a_SOURCES} ) +target_link_libraries( kmm_storage ${LIBALKIMIA_LIBRARIES} ) ########### install files ############### diff --git a/kmymoney/plugins/onlinetasks/interfaces/CMakeLists.txt b/kmymoney/plugins/onlinetasks/interfaces/CMakeLists.txt --- a/kmymoney/plugins/onlinetasks/interfaces/CMakeLists.txt +++ b/kmymoney/plugins/onlinetasks/interfaces/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries( onlinetask_interfaces kmm_payeeidentifier ${QT_QTCORE_LIBRARIES} + ${ALKIMIA_LIBRARIES} ) install(FILES ${onlinetask_interfaces_HEADER} diff --git a/kmymoney/wizards/newinvestmentwizard/CMakeLists.txt b/kmymoney/wizards/newinvestmentwizard/CMakeLists.txt --- a/kmymoney/wizards/newinvestmentwizard/CMakeLists.txt +++ b/kmymoney/wizards/newinvestmentwizard/CMakeLists.txt @@ -17,6 +17,7 @@ kde4_add_ui_files(libnewinvestmentwizard_a_SOURCES ${libnewinvestmentwizard_a_UI} ) kde4_add_library(newinvestmentwizard STATIC ${libnewinvestmentwizard_a_SOURCES}) +target_link_libraries(newinvestmentwizard ${LIBALKIMIA_LIBRARIES}) # we rely on some widgets to be generated add_dependencies(newinvestmentwizard widgets) diff --git a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp --- a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp +++ b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp @@ -43,7 +43,7 @@ #include "mymoneyfile.h" #include "ktoolinvocation.h" #include "kmymoneycurrencyselector.h" -#include "webpricequote.h" +#include #include "kmymoneyutils.h" KNewInvestmentWizard::KNewInvestmentWizard(QWidget *parent) : @@ -190,7 +190,7 @@ if (!field("onlineSourceCombo").toString().isEmpty()) { if (field("useFinanceQuote").toBool()) { - FinanceQuoteProcess p; + AlkFinanceQuoteProcess p; newSecurity.setValue("kmm-online-quote-system", "Finance::Quote"); newSecurity.setValue("kmm-online-source", p.crypticName(field("onlineSourceCombo").toString())); } else { diff --git a/kmymoney/wizards/newinvestmentwizard/konlineupdatewizardpage.cpp b/kmymoney/wizards/newinvestmentwizard/konlineupdatewizardpage.cpp --- a/kmymoney/wizards/newinvestmentwizard/konlineupdatewizardpage.cpp +++ b/kmymoney/wizards/newinvestmentwizard/konlineupdatewizardpage.cpp @@ -24,12 +24,11 @@ // ---------------------------------------------------------------------------- // KDE Includes - // ---------------------------------------------------------------------------- // Project Includes - #include "mymoneymoney.h" -#include "webpricequote.h" + +#include KOnlineUpdateWizardPage::KOnlineUpdateWizardPage(QWidget *parent) : KOnlineUpdateWizardPageDecl(parent) @@ -70,9 +69,9 @@ { int idx; if (security.value("kmm-online-quote-system") == "Finance::Quote") { - FinanceQuoteProcess p; - m_useFinanceQuote->setChecked(true); - idx = m_onlineSourceCombo->findText(p.niceName(security.value("kmm-online-source"))); +// AlkFinanceQuoteProcess p; +// m_useFinanceQuote->setChecked(true); +// idx = m_onlineSourceCombo->findText(p.niceName(security.value("kmm-online-source"))); } else { idx = m_onlineSourceCombo->findText(security.value("kmm-online-source")); } @@ -109,10 +108,6 @@ { m_onlineSourceCombo->clear(); m_onlineSourceCombo->insertItem(0, QString()); - if (useFQ) { - m_onlineSourceCombo->addItems(WebPriceQuote::quoteSources(WebPriceQuote::FinanceQuote)); - } else { - m_onlineSourceCombo->addItems(WebPriceQuote::quoteSources()); - } + m_onlineSourceCombo->addItems(AlkOnlineQuotesProfileManager::instance().profile("kmymoney")->quoteSources()); m_onlineSourceCombo->model()->sort(0); }