src/RelpipeChartMainWindow.cpp
branchv_0
changeset 19 ac70c7af6a9b
parent 18 16784291982f
child 20 b13e7ed9eea3
equal deleted inserted replaced
18:16784291982f 19:ac70c7af6a9b
    14 RelpipeChartMainWindow::RelpipeChartMainWindow() {
    14 RelpipeChartMainWindow::RelpipeChartMainWindow() {
    15 	widget.setupUi(this);
    15 	widget.setupUi(this);
    16 
    16 
    17 	int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options");
    17 	int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options");
    18 	tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));
    18 	tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));
    19 
    19 	statusBar()->addWidget(status);
    20 	statusBar()->addWidget(new QLabel("Loading relations...", widget.statusbar));
       
    21 
       
    22 
       
    23 	// TODO: remove; just demo
       
    24 	QPushButton* emitButton = new QPushButton("emit", widget.statusbar);
       
    25 	statusBar()->addWidget(emitButton);
       
    26 	QObject::connect(
       
    27 			emitButton, &QPushButton::pressed,
       
    28 			this, &RelpipeChartMainWindow::slot123
       
    29 			);
       
    30 	// ---
       
    31 
       
    32 	setCentralWidget(tabs);
    20 	setCentralWidget(tabs);
    33 
       
    34 }
    21 }
    35 
    22 
    36 RelpipeChartMainWindow::~RelpipeChartMainWindow() {
    23 RelpipeChartMainWindow::~RelpipeChartMainWindow() {
    37 }
    24 }
    38 
    25 
    39 void RelpipeChartMainWindow::slot123() {
       
    40 	// TODO: remove; just demo
       
    41 	statusBar()->addWidget(new QPushButton("slot123", widget.statusbar));
       
    42 }
       
    43 
       
    44 void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) {
    26 void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) {
       
    27 	setStatusMessage(L"Reading relation: " + name);
    45 	attributeCounter = 0;
    28 	attributeCounter = 0;
    46 	QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
    29 	QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
    47 
    30 
    48 	currentTable = new QTableWidget(0, attributes.size(), splitter);
    31 	currentTable = new QTableWidget(0, attributes.size(), splitter);
    49 	QStringList headers;
    32 	QStringList headers;
    50 	for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str());
    33 	for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str());
       
    34 	// for (AttributeMetadata a : attributes) headers << (QString::fromWCharArray(a.getAttributeName().c_str()) + " (" + QString::fromWCharArray(a.getTypeName().c_str()) + ")" );
    51 	currentTable->setHorizontalHeaderLabels(headers);
    35 	currentTable->setHorizontalHeaderLabels(headers);
    52 	currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
    36 	currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
    53 
    37 
    54 	// TODO: chart
    38 	// TODO: chart
    55 	splitter->addWidget(new QPushButton("here will be the chart", splitter));
    39 	splitter->addWidget(new QPushButton("here will be the chart", splitter));
    66 	if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount());
    50 	if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount());
    67 	currentTable->setItem(row, column, new QTableWidgetItem(QString::fromWCharArray(value.c_str())));
    51 	currentTable->setItem(row, column, new QTableWidgetItem(QString::fromWCharArray(value.c_str())));
    68 	attributeCounter++;
    52 	attributeCounter++;
    69 }
    53 }
    70 
    54 
       
    55 void RelpipeChartMainWindow::setStatusMessage(string_t message) {
       
    56 	status->setText(QString::fromWCharArray(message.c_str()));
       
    57 }
       
    58 
    71 void RelpipeChartMainWindow::endOfPipe() {
    59 void RelpipeChartMainWindow::endOfPipe() {
    72 	// TODO: just display a message
    60 	setStatusMessage(L"Reading successfully finished.");
    73 	statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar));
       
    74 }
    61 }