--- a/src/RelpipeChartMainWindow.cpp Sun Sep 30 01:40:29 2018 +0200
+++ b/src/RelpipeChartMainWindow.cpp Sun Sep 30 18:34:34 2018 +0200
@@ -16,38 +16,22 @@
int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options");
tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));
-
- statusBar()->addWidget(new QLabel("Loading relations...", widget.statusbar));
-
-
- // TODO: remove; just demo
- QPushButton* emitButton = new QPushButton("emit", widget.statusbar);
- statusBar()->addWidget(emitButton);
- QObject::connect(
- emitButton, &QPushButton::pressed,
- this, &RelpipeChartMainWindow::slot123
- );
- // ---
-
+ statusBar()->addWidget(status);
setCentralWidget(tabs);
-
}
RelpipeChartMainWindow::~RelpipeChartMainWindow() {
}
-void RelpipeChartMainWindow::slot123() {
- // TODO: remove; just demo
- statusBar()->addWidget(new QPushButton("slot123", widget.statusbar));
-}
-
void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) {
+ setStatusMessage(L"Reading relation: " + name);
attributeCounter = 0;
QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
currentTable = new QTableWidget(0, attributes.size(), splitter);
QStringList headers;
for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str());
+ // for (AttributeMetadata a : attributes) headers << (QString::fromWCharArray(a.getAttributeName().c_str()) + " (" + QString::fromWCharArray(a.getTypeName().c_str()) + ")" );
currentTable->setHorizontalHeaderLabels(headers);
currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
@@ -68,7 +52,10 @@
attributeCounter++;
}
+void RelpipeChartMainWindow::setStatusMessage(string_t message) {
+ status->setText(QString::fromWCharArray(message.c_str()));
+}
+
void RelpipeChartMainWindow::endOfPipe() {
- // TODO: just display a message
- statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar));
+ setStatusMessage(L"Reading successfully finished.");
}
--- a/src/RelpipeChartMainWindow.h Sun Sep 30 01:40:29 2018 +0200
+++ b/src/RelpipeChartMainWindow.h Sun Sep 30 18:34:34 2018 +0200
@@ -1,6 +1,7 @@
#pragma once
#include <QTableWidget>
+#include <QLabel>
#include "ui_RelpipeChartMainWindow.h"
@@ -20,13 +21,12 @@
virtual void startRelation(string_t name, std::vector<AttributeMetadata> attributes) override;
virtual void attribute(const string_t& value) override;
virtual void endOfPipe() override;
+public slots:
+ void setStatusMessage(string_t message);
private:
Ui::RelpipeChartMainWindow widget;
QTabWidget* tabs = new QTabWidget(this);
QTableWidget* currentTable;
+ QLabel* status = new QLabel();
integer_t attributeCounter;
-public slots:
- void slot123();
-signals:
- void signal123();
};
--- a/src/relpipe-out-chart.cpp Sun Sep 30 01:40:29 2018 +0200
+++ b/src/relpipe-out-chart.cpp Sun Sep 30 18:34:34 2018 +0200
@@ -43,15 +43,9 @@
QApplication app(argc, argv);
std::shared_ptr<RelationalReader> 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);
@@ -62,10 +56,13 @@
t.start();
// ---
- // window.signal123();
+ int qtResultCode = app.exec();
- app.exec();
- //return app.exec();
+ if (qtResultCode == 0) {
+ resultCode = CLI::EXIT_CODE_SUCCESS;
+ } else {
+ // TODO: report and log Qt errors if any
+ }
if (t.isRunning()) {
std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl;