38 // TODO: remove; just demo |
40 // TODO: remove; just demo |
39 statusBar()->addWidget(new QPushButton("slot123", widget.statusbar)); |
41 statusBar()->addWidget(new QPushButton("slot123", widget.statusbar)); |
40 } |
42 } |
41 |
43 |
42 void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) { |
44 void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) { |
43 // TODO: chart and table |
45 attributeCounter = 0; |
44 QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs); |
46 QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs); |
|
47 |
|
48 currentTable = new QTableWidget(0, attributes.size(), splitter); |
|
49 QStringList headers; |
|
50 for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str()); |
|
51 currentTable->setHorizontalHeaderLabels(headers); |
|
52 currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
|
53 |
|
54 // TODO: chart |
45 splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
55 splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
46 splitter->addWidget(new QPushButton("here will be the table", splitter)); |
56 splitter->addWidget(currentTable); |
47 int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
57 int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
48 if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
58 if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
49 tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet")); |
59 tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet")); |
50 } |
60 } |
51 |
61 |
52 void RelpipeChartMainWindow::attribute(const string_t& value) { |
62 void RelpipeChartMainWindow::attribute(const string_t& value) { |
53 // TODO: fill table and draw chart |
63 // TODO: draw chart |
|
64 integer_t column = attributeCounter % currentTable->columnCount(); |
|
65 integer_t row = attributeCounter / currentTable->columnCount(); |
|
66 if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount()); |
|
67 currentTable->setItem(row, column, new QTableWidgetItem(QString::fromWCharArray(value.c_str()))); |
|
68 attributeCounter++; |
54 } |
69 } |
55 |
70 |
56 void RelpipeChartMainWindow::endOfPipe() { |
71 void RelpipeChartMainWindow::endOfPipe() { |
57 // TODO: just display a message |
72 // TODO: just display a message |
58 statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar)); |
73 statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar)); |