[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;
@@ -65,7 +65,7 @@ void CWeatherDataPrinter::ps_printWeatherData(const BlackMisc::Weather::CWeather
qtout << " MSL Pressure: " << gridPoint.getPressureAtMsl().toQString() << endl; qtout << " MSL Pressure: " << gridPoint.getPressureAtMsl().toQString() << endl;
CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers(); CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers();
temperatureLayers.sort([](const CTemperatureLayer &a, const CTemperatureLayer &b) { return a.getLevel() < b.getLevel(); }); temperatureLayers.sort([](const CTemperatureLayer & a, const CTemperatureLayer & b) { return a.getLevel() < b.getLevel(); });
qtout << " Temperature Layers: " << endl; qtout << " Temperature Layers: " << endl;
for (const auto &temperatureLayer : as_const(temperatureLayers)) for (const auto &temperatureLayer : as_const(temperatureLayers))
{ {
@@ -76,7 +76,7 @@ void CWeatherDataPrinter::ps_printWeatherData(const BlackMisc::Weather::CWeather
qtout << endl; qtout << endl;
CWindLayerList windLayers = gridPoint.getWindLayers(); CWindLayerList windLayers = gridPoint.getWindLayers();
windLayers.sort([](const CWindLayer &a, const CWindLayer &b) { return a.getLevel() < b.getLevel(); }); windLayers.sort([](const CWindLayer & a, const CWindLayer & b) { return a.getLevel() < b.getLevel(); });
qtout << " Wind Layers: " << endl; qtout << " Wind Layers: " << endl;
for (const auto &windLayer : as_const(windLayers)) for (const auto &windLayer : as_const(windLayers))
{ {
@@ -87,7 +87,7 @@ void CWeatherDataPrinter::ps_printWeatherData(const BlackMisc::Weather::CWeather
qtout << " Cloud Layers: " << endl; qtout << " Cloud Layers: " << endl;
CCloudLayerList cloudLayers = gridPoint.getCloudLayers(); CCloudLayerList cloudLayers = gridPoint.getCloudLayers();
cloudLayers.sort([](const CCloudLayer &a, const CCloudLayer &b) { return a.getBase() < b.getBase(); }); cloudLayers.sort([](const CCloudLayer & a, const CCloudLayer & b) { return a.getBase() < b.getBase(); });
for (int i = 0; i < cloudLayers.size(); i++) for (int i = 0; i < cloudLayers.size(); i++)
{ {
const CCloudLayer &cloudLayer = cloudLayers[i]; const CCloudLayer &cloudLayer = cloudLayers[i];

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 };
}; };