author | František Kučera <franta-hg@frantovo.cz> |
Tue, 09 Oct 2018 23:02:11 +0200 | |
branch | v_0 |
changeset 23 | ff4a1c07a481 |
parent 22 | 0f0344e1ba61 |
child 28 | 04f1ac8a931b |
permissions | -rw-r--r-- |
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
1 |
#include <vector> |
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
2 |
|
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
3 |
#include <QPushButton> |
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
4 |
#include <QSplitter> |
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
5 |
#include <QTableView> |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
6 |
|
22
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
7 |
#include <QChart> |
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
8 |
#include <QChartView> |
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
9 |
#include <QStackedBarSeries> |
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
10 |
#include <QBarCategoryAxis> |
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
11 |
#include <QVBarModelMapper> |
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
12 |
|
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
#include "RelpipeChartMainWindow.h" |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
|
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
|
15 |
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
|
16 |
using namespace relpipe::reader::handlers; |
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
17 |
|
22
0f0344e1ba61
Qt Charts: includes and namespace
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
18 |
QT_CHARTS_USE_NAMESPACE |
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 |
|
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
RelpipeChartMainWindow::RelpipeChartMainWindow() { |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
widget.setupUi(this); |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
22 |
|
15 | 23 |
int optionsIndex = tabs->addTab(new QPushButton("here will be options", tabs), "Options"); |
24 |
tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure")); |
|
19
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
25 |
statusBar()->addWidget(status); |
12
a45d1cac365e
splitter and component placeholders
František Kučera <franta-hg@frantovo.cz>
parents:
6
diff
changeset
|
26 |
setCentralWidget(tabs); |
4
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
} |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
RelpipeChartMainWindow::~RelpipeChartMainWindow() { |
1622c087f3ea
add main window, compile Qt .ui file
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
} |
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
|
31 |
|
20
b13e7ed9eea3
better use of signal/slot mechanism, threads, Qt::ConnectionType::QueuedConnection
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
32 |
void RelpipeChartMainWindow::startRelation(const string_t name, std::vector<AttributeMetadata> attributes) { |
19
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
33 |
setStatusMessage(L"Reading relation: " + name); |
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
|
34 |
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
|
35 |
|
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
36 |
currentModel = new RelpipeTableModel(attributes, this); |
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
37 |
QTableView* tableView = new QTableView(this); |
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
38 |
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
39 |
tableView->setModel(currentModel); |
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
40 |
|
18
16784291982f
add QTableWidget with rows and collumns filled with attribute values
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
41 |
// 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
|
42 |
splitter->addWidget(new QPushButton("here will be the chart", splitter)); |
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
43 |
splitter->addWidget(tableView); |
15 | 44 |
int index = tabs->addTab(splitter, QString::fromWCharArray(name.c_str())); |
45 |
if (tabs->count() == 2) tabs->setCurrentIndex(index); // switch to the first relation (first tab is Options tab) |
|
46 |
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
|
47 |
} |
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
|
48 |
|
20
b13e7ed9eea3
better use of signal/slot mechanism, threads, Qt::ConnectionType::QueuedConnection
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
49 |
void RelpipeChartMainWindow::attribute(const string_t value) { |
23
ff4a1c07a481
use our own QAbstractTableModel and a QTableView instead of the QTableWidget
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
50 |
currentModel->addAttribute(value); |
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
|
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 |
|
19
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
53 |
void RelpipeChartMainWindow::setStatusMessage(string_t message) { |
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
54 |
status->setText(QString::fromWCharArray(message.c_str())); |
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
55 |
} |
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
56 |
|
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
|
57 |
void RelpipeChartMainWindow::endOfPipe() { |
19
ac70c7af6a9b
code clean-up, exit code
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
58 |
setStatusMessage(L"Reading successfully finished."); |
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
|
59 |
} |