src/RelpipeChartMainWindow.cpp
author František Kučera <franta-hg@frantovo.cz>
Sat, 29 Sep 2018 12:58:04 +0200
branchv_0
changeset 15 547a7c5681a5
parent 14 0a6a88e4e48f
child 18 16784291982f
permissions -rw-r--r--
tab icons

#include <QTabWidget>
#include <QPushButton>
#include <QLabel>
#include <QStatusBar>
#include <QSplitter>

#include "RelpipeChartMainWindow.h"

using namespace relpipe::reader;
using namespace relpipe::reader::handlers;

RelpipeChartMainWindow::RelpipeChartMainWindow() {
	widget.setupUi(this);

	int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options");
	tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));

	statusBar()->addWidget(new QLabel("Loading relations...", widget.statusbar));


	// TODO: remove; just demo
	QPushButton* emitButton = new QPushButton("emit", widget.statusbar);
	statusBar()->addWidget(emitButton);
	QObject::connect(
			emitButton, &QPushButton::pressed,
			this, &RelpipeChartMainWindow::slot123
			);
	// ---

	setCentralWidget(tabs);

}

RelpipeChartMainWindow::~RelpipeChartMainWindow() {
}

void RelpipeChartMainWindow::slot123() {
	// TODO: remove; just demo
	statusBar()->addWidget(new QPushButton("slot123", widget.statusbar));
}

void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) {
	// TODO: chart and table
	QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
	splitter->addWidget(new QPushButton("here will be the chart", splitter));
	splitter->addWidget(new QPushButton("here will be the table", splitter));
	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
}

void RelpipeChartMainWindow::endOfPipe() {
	// TODO: just display a message
	statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar));
}