#include <vector>
#include <QPushButton>
#include <QSplitter>
#include <QTableView>
#include <QChart>
#include <QChartView>
#include <QStackedBarSeries>
#include <QBarCategoryAxis>
#include <QVBarModelMapper>
#include "RelpipeChartMainWindow.h"
using namespace relpipe::reader;
using namespace relpipe::reader::handlers;
QT_CHARTS_USE_NAMESPACE
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(status);
setCentralWidget(tabs);
}
RelpipeChartMainWindow::~RelpipeChartMainWindow() {
}
void RelpipeChartMainWindow::startRelation(const string_t name, std::vector<AttributeMetadata> attributes) {
setStatusMessage(L"Reading relation: " + name);
QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
currentModel = new RelpipeTableModel(attributes, this);
QTableView* tableView = new QTableView(this);
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
tableView->setModel(currentModel);
// TODO: chart
splitter->addWidget(new QPushButton("here will be the chart", splitter));
splitter->addWidget(tableView);
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) {
currentModel->addAttribute(value);
}
void RelpipeChartMainWindow::setStatusMessage(string_t message) {
status->setText(QString::fromWCharArray(message.c_str()));
}
void RelpipeChartMainWindow::endOfPipe() {
setStatusMessage(L"Reading successfully finished.");
}