30 RelpipeChartMainWindow::~RelpipeChartMainWindow() { |
29 RelpipeChartMainWindow::~RelpipeChartMainWindow() { |
31 } |
30 } |
32 |
31 |
33 void RelpipeChartMainWindow::startRelation(const string_t name, std::vector<AttributeMetadata> attributes) { |
32 void RelpipeChartMainWindow::startRelation(const string_t name, std::vector<AttributeMetadata> attributes) { |
34 setStatusMessage(L"Reading relation: " + name); |
33 setStatusMessage(L"Reading relation: " + name); |
35 attributeCounter = 0; |
|
36 QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs); |
34 QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs); |
37 |
35 |
38 currentTable = new QTableWidget(0, attributes.size(), splitter); |
36 currentModel = new RelpipeTableModel(attributes, this); |
39 QStringList headers; |
37 QTableView* tableView = new QTableView(this); |
40 for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str()); |
38 tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
41 // for (AttributeMetadata a : attributes) headers << (QString::fromWCharArray(a.getAttributeName().c_str()) + " (" + QString::fromWCharArray(a.getTypeName().c_str()) + ")" ); |
39 tableView->setModel(currentModel); |
42 currentTable->setHorizontalHeaderLabels(headers); |
40 |
43 currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
|
44 |
|
45 // TODO: chart |
41 // TODO: chart |
46 splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
42 splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
47 splitter->addWidget(currentTable); |
43 splitter->addWidget(tableView); |
48 int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
44 int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
49 if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
45 if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
50 tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet")); |
46 tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet")); |
51 } |
47 } |
52 |
48 |
53 void RelpipeChartMainWindow::attribute(const string_t value) { |
49 void RelpipeChartMainWindow::attribute(const string_t value) { |
54 // TODO: draw chart |
50 currentModel->addAttribute(value); |
55 integer_t column = attributeCounter % currentTable->columnCount(); |
|
56 integer_t row = attributeCounter / currentTable->columnCount(); |
|
57 if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount()); |
|
58 QString name = QString::fromWCharArray(value.c_str()); |
|
59 currentTable->setItem(row, column, new QTableWidgetItem(name)); |
|
60 attributeCounter++; |
|
61 } |
51 } |
62 |
52 |
63 void RelpipeChartMainWindow::setStatusMessage(string_t message) { |
53 void RelpipeChartMainWindow::setStatusMessage(string_t message) { |
64 status->setText(QString::fromWCharArray(message.c_str())); |
54 status->setText(QString::fromWCharArray(message.c_str())); |
65 } |
55 } |