diff -r a45d1cac365e -r c84042d014c9 src/relpipe-out-chart.cpp --- a/src/relpipe-out-chart.cpp Fri Sep 28 13:23:21 2018 +0200 +++ b/src/relpipe-out-chart.cpp Sat Sep 29 00:43:16 2018 +0200 @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -9,24 +10,60 @@ #include #include "RelpipeChartMainWindow.h" +#include "QtRelationalReaderStringHadler.h" using namespace relpipe::cli; using namespace relpipe::reader; +class WorkerThread : public QThread { +private: + std::shared_ptr reader; +public: + + // TODO: better background thread; lambda? + + WorkerThread(std::shared_ptr reader) : + reader(reader) { + } + + void run() { + try { + reader->process(); + } catch (RelpipeReaderException& e) { + // TODO: handle exception, show error dialog + } + } +}; + int main(int argc, char**argv) { CLI cli(argc, argv); // TODO: argument name collisions? Filter arguments? Use prefix for Qt? Qt: -title, -style, -geometry QApplication app(argc, argv); - + std::cout << "TODO: relpipe-out-chart..." << std::endl; - + std::shared_ptr reader(Factory::create(std::cin)); + int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; - + RelpipeChartMainWindow window; + + // TODO: remove; just demo + QObject::connect(&window, &RelpipeChartMainWindow::signal123, &window, &RelpipeChartMainWindow::slot123); + window.show(); - + + QtRelationalReaderStringHadler handler(&app, &window); + reader->addHandler(&handler); + + // Start background thread + WorkerThread t(reader); + t.start(); + // --- + + // window.signal123(); + app.exec(); //return app.exec();