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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     1
#include <QTabWidget>
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     2
#include <QPushButton>
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     3
#include <QLabel>
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     4
#include <QStatusBar>
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     5
#include <QSplitter>
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     6
4
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
#include "RelpipeChartMainWindow.h"
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
13
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
     9
using namespace relpipe::reader;
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    10
using namespace relpipe::reader::handlers;
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    11
4
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
RelpipeChartMainWindow::RelpipeChartMainWindow() {
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
	widget.setupUi(this);
12
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    14
15
547a7c5681a5 tab icons
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    15
	int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options");
547a7c5681a5 tab icons
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    16
	tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));
13
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    17
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    18
	statusBar()->addWidget(new QLabel("Loading relations...", widget.statusbar));
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    19
12
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    20
13
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    21
	// TODO: remove; just demo
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    22
	QPushButton* emitButton = new QPushButton("emit", widget.statusbar);
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    23
	statusBar()->addWidget(emitButton);
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    24
	QObject::connect(
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    25
			emitButton, &QPushButton::pressed,
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    26
			this, &RelpipeChartMainWindow::slot123
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    27
			);
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    28
	// ---
12
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    29
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    30
	setCentralWidget(tabs);
a45d1cac365e splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    31
4
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
}
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
RelpipeChartMainWindow::~RelpipeChartMainWindow() {
1622c087f3ea add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
}
13
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    36
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    37
void RelpipeChartMainWindow::slot123() {
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    38
	// TODO: remove; just demo
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    39
	statusBar()->addWidget(new QPushButton("slot123", widget.statusbar));
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    40
}
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    41
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    42
void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) {
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    43
	// TODO: chart and table
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    44
	QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs);
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    45
	splitter->addWidget(new QPushButton("here will be the chart", splitter));
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    46
	splitter->addWidget(new QPushButton("here will be the table", splitter));
15
547a7c5681a5 tab icons
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    47
	int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str()));
547a7c5681a5 tab icons
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    48
	if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab)
547a7c5681a5 tab icons
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    49
	tabs->setTabIcon(index, QIcon::fromTheme("application-vnd.oasis.opendocument.spreadsheet"));
13
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    50
}
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    51
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    52
void RelpipeChartMainWindow::attribute(const string_t& value) {
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    53
	// TODO: fill table and draw chart
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    54
}
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    55
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    56
void RelpipeChartMainWindow::endOfPipe() {
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    57
	// TODO: just display a message
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    58
	statusBar()->addWidget(new QPushButton("endOfPipe", widget.statusbar));
c84042d014c9 background thread for STDIN reading + proxy with signals/slots for passing data to the GUI thread
František Kučera <franta-hg@frantovo.cz>
parents: 12
diff changeset
    59
}