[Weather] Weather data printer

* removed slots
* typo
This commit is contained in:
Klaus Basan
2020-04-15 20:19:40 +02:00
committed by Mat Sutcliffe
parent 4e45249142
commit 926684fb87
3 changed files with 11 additions and 13 deletions

View File

@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
CLineReader lineReader(&a); CLineReader lineReader(&a);
CWeatherDataPrinter printer(&a); CWeatherDataPrinter printer(&a);
QObject::connect(&lineReader, &CLineReader::weatherDataRequest, &printer, &CWeatherDataPrinter::fetchAndPrintWetherData); QObject::connect(&lineReader, &CLineReader::weatherDataRequest, &printer, &CWeatherDataPrinter::fetchAndPrintWeatherData);
QObject::connect(&lineReader, &CLineReader::wantsToQuit, &lineReader, &CLineReader::terminate); QObject::connect(&lineReader, &CLineReader::wantsToQuit, &lineReader, &CLineReader::terminate);
QObject::connect(&lineReader, &CLineReader::finished, &a, &QCoreApplication::quit); QObject::connect(&lineReader, &CLineReader::finished, &a, &QCoreApplication::quit);

View File

@@ -45,16 +45,16 @@ using namespace BlackCore;
CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent) CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent)
{ } { }
void CWeatherDataPrinter::fetchAndPrintWetherData(const CCoordinateGeodetic &position) void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
{ {
QTextStream qtout(stdout); QTextStream qtout(stdout);
qtout << "Fetching weather data. This may take a while..." << endl; qtout << "Fetching weather data. This may take a while..." << endl;
CWeatherGrid weatherGrid { { "", position } }; CWeatherGrid weatherGrid { { "", position } };
m_weatherManger.requestWeatherGrid(weatherGrid, { this, &CWeatherDataPrinter::ps_printWeatherData }); m_weatherManger.requestWeatherGrid(weatherGrid, { this, &CWeatherDataPrinter::printWeatherData });
} }
void CWeatherDataPrinter::ps_printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid) void CWeatherDataPrinter::printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid)
{ {
QTextStream qtout(stdout); QTextStream qtout(stdout);
qtout << "... finished." << endl; qtout << "... finished." << endl;

View File

@@ -29,15 +29,13 @@ public:
//! Constructor //! Constructor
CWeatherDataPrinter(QObject *parent = nullptr); CWeatherDataPrinter(QObject *parent = nullptr);
public slots:
//! Fetch new weather data for given position and print it once received //! Fetch new weather data for given position and print it once received
void fetchAndPrintWetherData(const BlackMisc::Geo::CCoordinateGeodetic &position); void fetchAndPrintWeatherData(const BlackMisc::Geo::CCoordinateGeodetic &position);
private slots:
//! Print weather data to stdout
void ps_printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
private: private:
//! Print weather data to stdout
void printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
BlackCore::CWeatherManager m_weatherManger { this }; BlackCore::CWeatherManager m_weatherManger { this };
}; };