src/RelpipeChartMainWindow.cpp
branchv_0
changeset 18 16784291982f
parent 15 547a7c5681a5
child 19 ac70c7af6a9b
equal deleted inserted replaced
17:dad72beb3ebe 18:16784291982f
     1 #include <QTabWidget>
     1 #include <QTabWidget>
     2 #include <QPushButton>
     2 #include <QPushButton>
     3 #include <QLabel>
     3 #include <QLabel>
     4 #include <QStatusBar>
     4 #include <QStatusBar>
     5 #include <QSplitter>
     5 #include <QSplitter>
       
     6 #include <QScrollArea>
       
     7 #include <QTableWidget>
     6 
     8 
     7 #include "RelpipeChartMainWindow.h"
     9 #include "RelpipeChartMainWindow.h"
     8 
    10 
     9 using namespace relpipe::reader;
    11 using namespace relpipe::reader;
    10 using namespace relpipe::reader::handlers;
    12 using namespace relpipe::reader::handlers;
    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));