GncQuotes - rename fetch_all to be an overload of fetch

And add a third overload to fetch only a single quote
This commit is contained in:
Geert Janssens 2021-03-18 16:33:16 +01:00 committed by John Ralls
parent 7765e13704
commit 4c2863966b
5 changed files with 33 additions and 14 deletions

View File

@ -1795,7 +1795,7 @@ gnc_xfer_dialog_fetch (GtkButton *button, XferDialog *xferData)
}
gnc_set_busy_cursor (nullptr, TRUE);
quotes.fetch_all();
quotes.fetch();
gnc_unset_busy_cursor (nullptr);
/*the results should be in the price db now, but don't crash if not. */

View File

@ -569,7 +569,7 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data)
}
gnc_set_busy_cursor (NULL, TRUE);
quotes.fetch_all();
quotes.fetch();
gnc_unset_busy_cursor (NULL);
/* Without this, the summary bar on the accounts tab

View File

@ -356,7 +356,7 @@ Gnucash::add_quotes (const bo_str& uri)
std::cerr << bl::translate ("Error message:") << std::endl;
std::cerr << quotes.error_msg() << std::endl;
}
quotes.fetch_all ();
quotes.fetch ();
qof_session_save(session, NULL);
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR)

View File

@ -66,8 +66,9 @@ public:
GncQuotesImpl ();
GncQuotesImpl (QofBook *book);
void fetch_all ();
void fetch (const CommVec& commodities);
void fetch ();
void fetch (CommVec& commodities);
void fetch (gnc_commodity *comm);
const int cmd_result() noexcept { return m_cmd_result; }
const std::string& error_msg() noexcept { return m_error_msg; }
@ -148,9 +149,9 @@ GncQuotesImpl::sources_as_glist()
void
GncQuotesImpl::fetch (const CommVec& commodities)
GncQuotesImpl::fetch (CommVec& commodities)
{
m_comm_vec = commodities; // Store for later use
m_comm_vec = std::move (commodities); // Store for later use
bpt::ptree pt, pt_child;
pt.put ("defaultcurrency", gnc_commodity_get_mnemonic (m_dflt_curr));
@ -205,7 +206,7 @@ GncQuotesImpl::fetch (const CommVec& commodities)
void
GncQuotesImpl::fetch_all ()
GncQuotesImpl::fetch ()
{
auto commodities = gnc_quotes_get_quotable_commodities (
gnc_commodity_table_get_table (m_book));
@ -213,6 +214,15 @@ GncQuotesImpl::fetch_all ()
fetch (commodities);
}
void
GncQuotesImpl::fetch (gnc_commodity *comm)
{
auto commodities = CommVec {comm};
fetch (commodities);
}
static const std::vector <std::string>
format_quotes (const std::vector<gnc_commodity*>)
{
@ -529,16 +539,21 @@ GncQuotes::GncQuotes (QofBook *book)
}
void
GncQuotes::fetch_all ()
GncQuotes::fetch (void)
{
m_impl->fetch_all ();
m_impl->fetch ();
}
void GncQuotes::fetch (const CommVec& commodities)
void GncQuotes::fetch (CommVec& commodities)
{
m_impl->fetch (commodities);
}
void GncQuotes::fetch (gnc_commodity *comm)
{
m_impl->fetch (comm);
}
const int GncQuotes::cmd_result() noexcept
{
return m_impl->cmd_result ();

View File

@ -26,9 +26,9 @@
#include <string>
#include <vector>
#include <gnc-commodity.hpp> // For CommVec alias
#include <glib.h>
extern "C" {
#include <glib.h>
#include <qofbook.h>
}
@ -48,8 +48,12 @@ public:
GncQuotes (QofBook *book);
~GncQuotes ();
void fetch_all ();
void fetch (const CommVec& commodities);
// Fetch quotes for all commodities in our db that have a quote source set
void fetch (void);
// Only fetch quotes for the commodities passed that have a quote source set
void fetch (CommVec& commodities);
// Fetch quote for the commodity if it has a quote source set
void fetch (gnc_commodity *comm);
const int cmd_result() noexcept;
const std::string& error_msg() noexcept;