# HG changeset patch # User František Kučera # Date 1538264429 -7200 # Node ID 16784291982f837f4274262be0cd09d40d37014f # Parent dad72beb3ebeba4f285aaa7fb1c07b013b814df2 add QTableWidget with rows and collumns filled with attribute values diff -r dad72beb3ebe -r 16784291982f nbproject/configurations.xml --- a/nbproject/configurations.xml Sat Sep 29 14:14:00 2018 +0200 +++ b/nbproject/configurations.xml Sun Sep 30 01:40:29 2018 +0200 @@ -91,9 +91,6 @@ - - @@ -103,6 +100,27 @@ ${MAKE} -f Makefile ${MAKE} -f Makefile clean build/Debug/src/relpipe-out-chart + + + build/Debug/src + src + build/Debug/src/relpipe-out-chart_autogen/include + ../relpipe-lib-reader.cpp/include + ../relpipe-lib-cli.cpp/include + /usr/include/x86_64-linux-gnu/qt5 + /usr/include/x86_64-linux-gnu/qt5/QtWidgets + /usr/include/x86_64-linux-gnu/qt5/QtGui + /usr/include/x86_64-linux-gnu/qt5/QtCore + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ + /usr/include/x86_64-linux-gnu/qt5/QtCharts + + + QT_CHARTS_LIB + QT_CORE_LIB + QT_GUI_LIB + QT_WIDGETS_LIB + + build/Debug @@ -114,8 +132,6 @@ ex="false" tool="1" flavor2="11"> - - - + - - - - /usr/include/x86_64-linux-gnu/qt5/QtCore - - - QT_CHARTS_LIB - QT_CORE_LIB - QT_GUI_LIB - QT_WIDGETS_LIB - - - - build/Debug/src - src - build/Debug/src/relpipe-out-chart_autogen/include - ../relpipe-lib-reader.cpp/include - ../relpipe-lib-cli.cpp/include - /usr/include/x86_64-linux-gnu/qt5 - /usr/include/x86_64-linux-gnu/qt5/QtWidgets - /usr/include/x86_64-linux-gnu/qt5/QtGui - /usr/include/x86_64-linux-gnu/qt5/QtCore - /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ - /usr/include/x86_64-linux-gnu/qt5/QtCharts /usr/include - - QT_CHARTS_LIB - QT_CORE_LIB - QT_GUI_LIB - QT_WIDGETS_LIB - - - - - - - /usr/include/x86_64-linux-gnu/qt5/QtCore - ../relpipe-lib-reader.cpp/include/relpipe/reader/handlers - src - build/Debug/src/relpipe-out-chart_autogen/EWIEGA46WW - ../relpipe-lib-reader.cpp/include/relpipe/reader - /usr/include/x86_64-linux-gnu/qt5/QtGui - /usr/include/x86_64-linux-gnu/qt5/QtWidgets - build/Debug/src/relpipe-out-chart_autogen/include - build/Debug/src/relpipe-out-chart_autogen - /usr/include/x86_64-linux-gnu/qt5 - ../relpipe-lib-reader.cpp/include - build/Debug/src - - - /usr/include/x86_64-linux-gnu/qt5/QtCore - build/Debug/src - src - build/Debug/src/relpipe-out-chart_autogen/include - ../relpipe-lib-reader.cpp/include - ../relpipe-lib-cli.cpp/include - /usr/include/x86_64-linux-gnu/qt5 - /usr/include/x86_64-linux-gnu/qt5/QtWidgets - /usr/include/x86_64-linux-gnu/qt5/QtGui - /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ - /usr/include/x86_64-linux-gnu/qt5/QtCharts - - - build/Debug/src - src - build/Debug/src/relpipe-out-chart_autogen/include - ../relpipe-lib-reader.cpp/include - ../relpipe-lib-cli.cpp/include - /usr/include/x86_64-linux-gnu/qt5 - /usr/include/x86_64-linux-gnu/qt5/QtWidgets - /usr/include/x86_64-linux-gnu/qt5/QtGui - /usr/include/x86_64-linux-gnu/qt5/QtCore - /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ - /usr/include/x86_64-linux-gnu/qt5/QtCharts - diff -r dad72beb3ebe -r 16784291982f src/QtRelationalReaderStringHadler.h --- a/src/QtRelationalReaderStringHadler.h Sat Sep 29 14:14:00 2018 +0200 +++ b/src/QtRelationalReaderStringHadler.h Sun Sep 30 01:40:29 2018 +0200 @@ -56,6 +56,8 @@ private slots: + // FIXME: asynchronous signal-slot data passing between two threads + void slot_startRelation(string_t name, std::vector attributes) { target->startRelation(name, attributes); }; 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() { diff -r dad72beb3ebe -r 16784291982f src/RelpipeChartMainWindow.h --- a/src/RelpipeChartMainWindow.h Sat Sep 29 14:14:00 2018 +0200 +++ b/src/RelpipeChartMainWindow.h Sun Sep 30 01:40:29 2018 +0200 @@ -1,5 +1,7 @@ #pragma once +#include + #include "ui_RelpipeChartMainWindow.h" #include @@ -21,6 +23,8 @@ private: Ui::RelpipeChartMainWindow widget; QTabWidget* tabs = new QTabWidget(this); + QTableWidget* currentTable; + integer_t attributeCounter; public slots: void slot123(); signals: diff -r dad72beb3ebe -r 16784291982f src/relpipe-out-chart.cpp --- a/src/relpipe-out-chart.cpp Sat Sep 29 14:14:00 2018 +0200 +++ b/src/relpipe-out-chart.cpp Sun Sep 30 01:40:29 2018 +0200 @@ -42,8 +42,6 @@ // 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));