author | František Kučera <franta-hg@frantovo.cz> |
Sun, 30 Sep 2018 01:40:29 +0200 | |
branch | v_0 |
changeset 18 | 16784291982f |
parent 15 | 547a7c5681a5 |
child 19 | ac70c7af6a9b |
permissions | -rw-r--r-- |
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> |
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
6 |
#include <QScrollArea> |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
7 |
#include <QTableWidget> |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
8 |
|
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
#include "RelpipeChartMainWindow.h" |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
|
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
|
11 |
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
|
12 |
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
|
13 |
|
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
RelpipeChartMainWindow::RelpipeChartMainWindow() { |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
widget.setupUi(this); |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
16 |
|
15 | 17 |
int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options"); |
18 |
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
|
19 |
|
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
|
20 |
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
|
21 |
|
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
22 |
|
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
|
23 |
// 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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
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
|
29 |
); |
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
|
30 |
// --- |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
31 |
|
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
32 |
setCentralWidget(tabs); |
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
33 |
|
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
} |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
RelpipeChartMainWindow::~RelpipeChartMainWindow() { |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
} |
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
|
38 |
|
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 |
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
|
40 |
// 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
|
41 |
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
|
42 |
} |
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 |
|
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 |
void RelpipeChartMainWindow::startRelation(string_t name, std::vector<AttributeMetadata> attributes) { |
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
45 |
attributeCounter = 0; |
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
|
46 |
QSplitter* splitter = new QSplitter(Qt::Orientation::Vertical, tabs); |
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
47 |
|
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
48 |
currentTable = new QTableWidget(0, attributes.size(), splitter); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
49 |
QStringList headers; |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
50 |
for (AttributeMetadata a : attributes) headers << QString::fromWCharArray(a.getAttributeName().c_str()); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
51 |
currentTable->setHorizontalHeaderLabels(headers); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
52 |
currentTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
53 |
|
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
54 |
// TODO: chart |
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
|
55 |
splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
56 |
splitter->addWidget(currentTable); |
15 | 57 |
int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
58 |
if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
|
59 |
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
|
60 |
} |
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
|
61 |
|
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
|
62 |
void RelpipeChartMainWindow::attribute(const string_t& value) { |
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
63 |
// TODO: draw chart |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
64 |
integer_t column = attributeCounter % currentTable->columnCount(); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
65 |
integer_t row = attributeCounter / currentTable->columnCount(); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
66 |
if (row >= currentTable->rowCount()) currentTable->insertRow(currentTable->rowCount()); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
67 |
currentTable->setItem(row, column, new QTableWidgetItem(QString::fromWCharArray(value.c_str()))); |
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
68 |
attributeCounter++; |
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
|
69 |
} |
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
|
70 |
|
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
|
71 |
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
|
72 |
// 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
|
73 |
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
|
74 |
} |