add QTableWidget with rows and collumns filled with attribute values v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 30 Sep 2018 01:40:29 +0200
branchv_0
changeset 18 16784291982f
parent 17 dad72beb3ebe
child 19 ac70c7af6a9b
add QTableWidget with rows and collumns filled with attribute values
nbproject/configurations.xml
src/QtRelationalReaderStringHadler.h
src/RelpipeChartMainWindow.cpp
src/RelpipeChartMainWindow.h
src/relpipe-out-chart.cpp
--- 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 @@
       </toolsSet>
       <flagsDictionary>
         <element flagsID="0" commonFlags="-fsanitize=address -fPIC -std=gnu++11"/>
-        <element flagsID="1"
-                 commonFlags="-mtune=generic -march=x86-64 -std=gnu++11 -fsanitize=address -fPIC -fstack-protector-strong"/>
-        <element flagsID="2" commonFlags="-std=c++14"/>
       </flagsDictionary>
       <codeAssistance>
       </codeAssistance>
@@ -103,6 +100,27 @@
           <buildCommand>${MAKE} -f Makefile</buildCommand>
           <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
           <executablePath>build/Debug/src/relpipe-out-chart</executablePath>
+          <ccTool>
+            <incDir>
+              <pElem>build/Debug/src</pElem>
+              <pElem>src</pElem>
+              <pElem>build/Debug/src/relpipe-out-chart_autogen/include</pElem>
+              <pElem>../relpipe-lib-reader.cpp/include</pElem>
+              <pElem>../relpipe-lib-cli.cpp/include</pElem>
+              <pElem>/usr/include/x86_64-linux-gnu/qt5</pElem>
+              <pElem>/usr/include/x86_64-linux-gnu/qt5/QtWidgets</pElem>
+              <pElem>/usr/include/x86_64-linux-gnu/qt5/QtGui</pElem>
+              <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
+              <pElem>/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++</pElem>
+              <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCharts</pElem>
+            </incDir>
+            <preprocessorList>
+              <Elem>QT_CHARTS_LIB</Elem>
+              <Elem>QT_CORE_LIB</Elem>
+              <Elem>QT_GUI_LIB</Elem>
+              <Elem>QT_WIDGETS_LIB</Elem>
+            </preprocessorList>
+          </ccTool>
         </makeTool>
         <preBuild>
           <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
@@ -114,8 +132,6 @@
             ex="false"
             tool="1"
             flavor2="11">
-        <ccTool flags="2">
-        </ccTool>
       </item>
       <item path="build/Debug/src/relpipe-out-chart_autogen/EWIEGA46WW/moc_QtRelationalReaderStringHadler.cpp"
             ex="true"
@@ -131,96 +147,22 @@
             ex="false"
             tool="1"
             flavor2="8">
-        <ccTool flags="1">
+        <ccTool flags="0">
         </ccTool>
       </item>
-      <folder path="0">
-        <ccTool>
-          <incDir>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
-          </incDir>
-          <preprocessorList>
-            <Elem>QT_CHARTS_LIB</Elem>
-            <Elem>QT_CORE_LIB</Elem>
-            <Elem>QT_GUI_LIB</Elem>
-            <Elem>QT_WIDGETS_LIB</Elem>
-          </preprocessorList>
-        </ccTool>
-      </folder>
       <folder path="Modules">
         <ccTool>
           <incDir>
-            <pElem>build/Debug/src</pElem>
-            <pElem>src</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen/include</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include</pElem>
-            <pElem>../relpipe-lib-cli.cpp/include</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtWidgets</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtGui</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
-            <pElem>/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCharts</pElem>
             <pElem>/usr/include</pElem>
           </incDir>
-          <preprocessorList>
-            <Elem>QT_CHARTS_LIB</Elem>
-            <Elem>QT_CORE_LIB</Elem>
-            <Elem>QT_GUI_LIB</Elem>
-            <Elem>QT_WIDGETS_LIB</Elem>
-          </preprocessorList>
-        </ccTool>
-      </folder>
-      <folder path="relpipe-out-chart_autogen">
-        <ccTool>
-          <incDir>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include/relpipe/reader/handlers</pElem>
-            <pElem>src</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen/EWIEGA46WW</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include/relpipe/reader</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtGui</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtWidgets</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen/include</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include</pElem>
-            <pElem>build/Debug/src</pElem>
-          </incDir>
         </ccTool>
       </folder>
       <item path="src/RelpipeChartMainWindow.cpp" ex="false" tool="1" flavor2="8">
         <ccTool flags="0">
-          <incDir>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
-            <pElem>build/Debug/src</pElem>
-            <pElem>src</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen/include</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include</pElem>
-            <pElem>../relpipe-lib-cli.cpp/include</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtWidgets</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtGui</pElem>
-            <pElem>/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCharts</pElem>
-          </incDir>
         </ccTool>
       </item>
       <item path="src/relpipe-out-chart.cpp" ex="false" tool="1" flavor2="8">
         <ccTool flags="0">
-          <incDir>
-            <pElem>build/Debug/src</pElem>
-            <pElem>src</pElem>
-            <pElem>build/Debug/src/relpipe-out-chart_autogen/include</pElem>
-            <pElem>../relpipe-lib-reader.cpp/include</pElem>
-            <pElem>../relpipe-lib-cli.cpp/include</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtWidgets</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtGui</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCore</pElem>
-            <pElem>/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++</pElem>
-            <pElem>/usr/include/x86_64-linux-gnu/qt5/QtCharts</pElem>
-          </incDir>
         </ccTool>
       </item>
     </conf>
--- 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<AttributeMetadata> attributes) {
 		target->startRelation(name, attributes);
 	};
--- 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 <QLabel>
 #include <QStatusBar>
 #include <QSplitter>
+#include <QScrollArea>
+#include <QTableWidget>
 
 #include "RelpipeChartMainWindow.h"
 
@@ -40,17 +42,30 @@
 }
 
 void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> 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() {
--- 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 <QTableWidget>
+
 #include "ui_RelpipeChartMainWindow.h"
 
 #include <relpipe/reader/typedefs.h>
@@ -21,6 +23,8 @@
 private:
 	Ui::RelpipeChartMainWindow widget;
 	QTabWidget* tabs = new QTabWidget(this);
+	QTableWidget* currentTable;
+	integer_t attributeCounter;
 public slots:
 	void slot123();
 signals:
--- 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<RelationalReader> reader(Factory::create(std::cin));