diff -r dad72beb3ebe -r 16784291982f src/RelpipeChartMainWindow.cpp --- a/src/RelpipeChartMainWindow.cpp Sat Sep 29 14:14:00 2018 +0200 +++ b/src/RelpipeChartMainWindow.cpp Sun Sep 30 01:40:29 2018 +0200 @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "RelpipeChartMainWindow.h" @@ -40,17 +42,30 @@ } void RelpipeChartMainWindow::startRelation(string_t name, std::vector attributes) { - // TODO: chart and table + 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()); + currentTable->setHorizontalHeaderLabels(headers); + currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); + + // TODO: chart splitter->addWidget(new QPushButton("here will be the chart", splitter)); - splitter->addWidget(new QPushButton("here will be the table", splitter)); + splitter->addWidget(currentTable); int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet")); } void RelpipeChartMainWindow::attribute(const string_t& value) { - // TODO: fill table and draw chart + // TODO: draw chart + integer_t column = attributeCounter % currentTable->columnCount(); + integer_t row = attributeCounter / currentTable->columnCount(); + if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount()); + currentTable->setItem(row, column, new QTableWidgetItem(QString::fromWCharArray(value.c_str()))); + attributeCounter++; } void RelpipeChartMainWindow::endOfPipe() {