tablewidget.cpp
468 lines
| 19.1 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r830 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Marek Rosa
|
r519 | #include "tablewidget.h" | ||
#include <QGridLayout> | ||||
#include <QTableView> | ||||
Marek Rosa
|
r1056 | #include <QChart> | ||
Marek Rosa
|
r519 | #include <QStyledItemDelegate> | ||
Marek Rosa
|
r849 | #include <QLineSeries> | ||
#include <QSplineSeries> | ||||
#include <QScatterSeries> | ||||
Marek Rosa
|
r1164 | #include <QXYModelMapper> | ||
Marek Rosa
|
r519 | #include "customtablemodel.h" | ||
Marek Rosa
|
r849 | #include <QPieSeries> | ||
Marek Rosa
|
r1164 | #include <QPieModelMapper> | ||
Marek Rosa
|
r849 | #include <QPieSlice> | ||
#include <QAreaSeries> | ||||
#include <QBarSeries> | ||||
Marek Rosa
|
r1171 | #include <QGroupedBarSeries> | ||
Marek Rosa
|
r849 | #include <QBarSet> | ||
Marek Rosa
|
r1170 | #include <QBarModelMapper> | ||
Marek Rosa
|
r545 | #include <QPushButton> | ||
#include <QRadioButton> | ||||
Marek Rosa
|
r878 | #include <QLabel> | ||
Marek Rosa
|
r735 | #include <QSpinBox> | ||
Marek Rosa
|
r630 | #include <QTime> | ||
Marek Rosa
|
r1097 | #include <QHeaderView> | ||
Marek Rosa
|
r519 | |||
TableWidget::TableWidget(QWidget *parent) | ||||
Marek Rosa
|
r1063 | : QWidget(parent) | ||
Marek Rosa
|
r1090 | // specialPie(0) | ||
Marek Rosa
|
r519 | { | ||
Marek Rosa
|
r1056 | setGeometry(1900, 100, 1000, 600); | ||
Marek Rosa
|
r630 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | ||
Marek Rosa
|
r519 | // create simple model for storing data | ||
// user's table data model | ||||
Marek Rosa
|
r545 | m_model = new CustomTableModel; | ||
Marek Rosa
|
r833 | m_tableView = new QTableView; | ||
m_tableView->setModel(m_model); | ||||
Marek Rosa
|
r1164 | // m_tableView->setMinimumHeight(300); | ||
Marek Rosa
|
r1097 | m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | ||
m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); | ||||
Marek Rosa
|
r833 | m_chart = new QChart; | ||
Marek Rosa
|
r1012 | m_chart->legend()->setVisible(true); | ||
Marek Rosa
|
r1164 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | ||
Marek Rosa
|
r833 | m_chartView = new QChartView(m_chart); | ||
m_chartView->setRenderHint(QPainter::Antialiasing); | ||||
m_chartView->setMinimumSize(640, 480); | ||||
Marek Rosa
|
r519 | |||
Marek Rosa
|
r545 | // add, remove data buttons | ||
Marek Rosa
|
r546 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); | ||
connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); | ||||
QPushButton* addRowBelowButton = new QPushButton("Add row below"); | ||||
connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); | ||||
Marek Rosa
|
r545 | |||
QPushButton* removeRowButton = new QPushButton("Remove row"); | ||||
connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); | ||||
Marek Rosa
|
r1090 | QPushButton* addColumnRightButton = new QPushButton("Add column to the right"); | ||
Marek Rosa
|
r1081 | connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight())); | ||
QPushButton* removeColumnButton = new QPushButton("Remove column"); | ||||
connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn())); | ||||
Marek Rosa
|
r1056 | QPushButton* specialPieButton = new QPushButton("Test pie"); | ||
connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie())); | ||||
Marek Rosa
|
r1164 | // QLabel *spinBoxLabel = new QLabel("Rows affected:"); | ||
Marek Rosa
|
r878 | |||
Marek Rosa
|
r877 | // spin box for setting number of affected items (add, remove) | ||
Marek Rosa
|
r833 | m_linesCountSpinBox = new QSpinBox; | ||
m_linesCountSpinBox->setRange(1, 10); | ||||
m_linesCountSpinBox->setValue(1); | ||||
Marek Rosa
|
r735 | |||
Marek Rosa
|
r545 | // buttons layout | ||
QVBoxLayout* buttonsLayout = new QVBoxLayout; | ||||
Marek Rosa
|
r1164 | // buttonsLayout->addWidget(spinBoxLabel); | ||
// buttonsLayout->addWidget(m_linesCountSpinBox); | ||||
// buttonsLayout->addWidget(addRowAboveButton); | ||||
Marek Rosa
|
r546 | buttonsLayout->addWidget(addRowBelowButton); | ||
Marek Rosa
|
r545 | buttonsLayout->addWidget(removeRowButton); | ||
Marek Rosa
|
r1164 | // buttonsLayout->addWidget(addColumnRightButton); | ||
// buttonsLayout->addWidget(removeColumnButton); | ||||
buttonsLayout->addWidget(specialPieButton); | ||||
Marek Rosa
|
r545 | buttonsLayout->addStretch(); | ||
// chart type radio buttons | ||||
Marek Rosa
|
r833 | m_lineRadioButton = new QRadioButton("Line"); | ||
m_splineRadioButton = new QRadioButton("Spline"); | ||||
m_scatterRadioButton = new QRadioButton("Scatter"); | ||||
m_pieRadioButton = new QRadioButton("Pie"); | ||||
m_areaRadioButton = new QRadioButton("Area"); | ||||
m_barRadioButton = new QRadioButton("Bar"); | ||||
Marek Rosa
|
r878 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||
connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||||
connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||||
connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||||
connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||||
connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | ||||
Marek Rosa
|
r1164 | m_lineRadioButton->setChecked(true); | ||
Marek Rosa
|
r545 | |||
// radio buttons layout | ||||
Marek Rosa
|
r630 | QVBoxLayout* radioLayout = new QVBoxLayout; | ||
Marek Rosa
|
r833 | radioLayout->addWidget(m_lineRadioButton); | ||
Marek Rosa
|
r1164 | radioLayout->addWidget(m_splineRadioButton); | ||
// radioLayout->addWidget(m_scatterRadioButton); | ||||
Marek Rosa
|
r833 | radioLayout->addWidget(m_pieRadioButton); | ||
Marek Rosa
|
r1164 | // radioLayout->addWidget(m_areaRadioButton); | ||
Marek Rosa
|
r833 | radioLayout->addWidget(m_barRadioButton); | ||
Marek Rosa
|
r630 | radioLayout->addStretch(); | ||
Marek Rosa
|
r519 | |||
// create main layout | ||||
QGridLayout* mainLayout = new QGridLayout; | ||||
Marek Rosa
|
r1097 | mainLayout->addLayout(buttonsLayout, 2, 0); | ||
Marek Rosa
|
r1164 | mainLayout->addLayout(radioLayout, 3, 0); | ||
Marek Rosa
|
r833 | mainLayout->addWidget(m_tableView, 1, 0); | ||
Marek Rosa
|
r1097 | mainLayout->addWidget(m_chartView, 1, 1, 2, 1); | ||
Marek Rosa
|
r849 | setLayout(mainLayout); | ||
Marek Rosa
|
r833 | m_lineRadioButton->setFocus(); | ||
Marek Rosa
|
r545 | } | ||
Marek Rosa
|
r546 | void TableWidget::addRowAbove() | ||
{ | ||||
Marek Rosa
|
r833 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); | ||
Marek Rosa
|
r546 | |||
} | ||||
void TableWidget::addRowBelow() | ||||
Marek Rosa
|
r545 | { | ||
Marek Rosa
|
r833 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); | ||
Marek Rosa
|
r545 | |||
} | ||||
void TableWidget::removeRow() | ||||
{ | ||||
Marek Rosa
|
r833 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); | ||
Marek Rosa
|
r545 | } | ||
Marek Rosa
|
r1081 | void TableWidget::addColumnRight() | ||
{ | ||||
m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value()); | ||||
} | ||||
void TableWidget::removeColumn() | ||||
{ | ||||
m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value())); | ||||
} | ||||
Marek Rosa
|
r878 | void TableWidget::updateChartType(bool toggle) | ||
Marek Rosa
|
r545 | { | ||
Marek Rosa
|
r878 | // this if is needed, so that the function is only called once. | ||
// For the radioButton that was enabled. | ||||
if (toggle) { | ||||
Marek Rosa
|
r1090 | // specialPie = 0; | ||
Marek Rosa
|
r1056 | m_chart->removeAllSeries(); | ||
Marek Rosa
|
r1012 | m_chart->axisX()->setNiceNumbersEnabled(false); | ||
m_chart->axisY()->setNiceNumbersEnabled(false); | ||||
Marek Rosa
|
r878 | |||
// renable axes of the chart (pie hides them) | ||||
// x axis | ||||
Michal Klocek
|
r1006 | QAxis *axis = m_chart->axisX(); | ||
Marek Rosa
|
r878 | axis->setAxisVisible(true); | ||
axis->setGridLineVisible(true); | ||||
axis->setLabelsVisible(true); | ||||
// y axis | ||||
axis = m_chart->axisY(); | ||||
axis->setAxisVisible(true); | ||||
axis->setGridLineVisible(true); | ||||
axis->setLabelsVisible(true); | ||||
m_model->clearMapping(); | ||||
QString seriesColorHex = "#000000"; | ||||
QPen pen; | ||||
pen.setWidth(2); | ||||
if (m_lineRadioButton->isChecked()) | ||||
{ | ||||
Marek Rosa
|
r1091 | m_chart->setAnimationOptions(QChart::NoAnimation); | ||
Marek Rosa
|
r878 | // series 1 | ||
m_series = new QLineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1164 | |||
QXYModelMapper *mapper = new QXYModelMapper; | ||||
mapper->setMapX(0); | ||||
mapper->setMapY(1); | ||||
mapper->setFirst(3); | ||||
mapper->setCount(4); | ||||
m_series->setModelMapper(mapper); | ||||
// m_series->setModelMapping(0,1, Qt::Vertical); | ||||
// m_series->setModelMappingRange(3, 4); | ||||
Marek Rosa
|
r878 | m_chart->addSeries(m_series); | ||
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||||
Marek Rosa
|
r1090 | m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4)); | ||
Marek Rosa
|
r878 | |||
// series 2 | ||||
m_series = new QLineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1164 | |||
mapper = new QXYModelMapper; | ||||
mapper->setMapX(3); | ||||
mapper->setMapY(4); | ||||
// mapper->setFirst(3); | ||||
// mapper->setCount(4); | ||||
m_series->setModelMapper(mapper); | ||||
// m_series->setModelMapping(2,3, Qt::Vertical); | ||||
Marek Rosa
|
r878 | m_chart->addSeries(m_series); | ||
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||||
Marek Rosa
|
r1164 | m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000)); | ||
Marek Rosa
|
r878 | |||
// series 3 | ||||
m_series = new QLineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1164 | |||
mapper = new QXYModelMapper; | ||||
mapper->setMapX(5); | ||||
mapper->setMapY(6); | ||||
mapper->setFirst(2); | ||||
mapper->setCount(-1); | ||||
m_series->setModelMapper(mapper); | ||||
// m_series->setModelMapping(4,5, Qt::Vertical); | ||||
// m_series->setModelMappingRange(2, -1); | ||||
Marek Rosa
|
r878 | m_chart->addSeries(m_series); | ||
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||||
Marek Rosa
|
r1164 | m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000)); | ||
Marek Rosa
|
r878 | } | ||
else if (m_splineRadioButton->isChecked()) | ||||
{ | ||||
Marek Rosa
|
r1091 | m_chart->setAnimationOptions(QChart::NoAnimation); | ||
Marek Rosa
|
r878 | // series 1 | ||
m_series = new QSplineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1164 | |||
QXYModelMapper *mapper = new QXYModelMapper; | ||||
mapper->setMapX(0); | ||||
mapper->setMapY(1); | ||||
mapper->setFirst(0); | ||||
mapper->setCount(-1); | ||||
m_series->setModelMapper(mapper); | ||||
Marek Rosa
|
r878 | m_chart->addSeries(m_series); | ||
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||||
Marek Rosa
|
r1090 | m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); | ||
Marek Rosa
|
r878 | |||
// series 2 | ||||
m_series = new QSplineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1164 | |||
mapper = new QXYModelMapper; | ||||
mapper->setMapX(2); | ||||
mapper->setMapY(3); | ||||
mapper->setFirst(2); | ||||
mapper->setCount(4); | ||||
m_series->setModelMapper(mapper); | ||||
Marek Rosa
|
r878 | m_chart->addSeries(m_series); | ||
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||||
Marek Rosa
|
r1090 | m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4)); | ||
Marek Rosa
|
r878 | |||
// series 3 | ||||
m_series = new QSplineSeries; | ||||
m_series->setModel(m_model); | ||||
Marek Rosa
|
r1091 | |||
Marek Rosa
|
r1164 | mapper = new QXYModelMapper; | ||
mapper->setMapX(4); | ||||
mapper->setMapY(5); | ||||
mapper->setFirst(2); | ||||
mapper->setCount(-1); | ||||
Marek Rosa
|
r878 | |||
Marek Rosa
|
r1164 | m_series->setModelMapper(mapper); | ||
Marek Rosa
|
r878 | |||
m_chart->addSeries(m_series); | ||||
Marek Rosa
|
r1164 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | ||
m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); | ||||
Marek Rosa
|
r1085 | } | ||
Marek Rosa
|
r1164 | // else if (m_scatterRadioButton->isChecked()) | ||
// { | ||||
// m_chart->setAnimationOptions(QChart::NoAnimation); | ||||
// // series 1 | ||||
// m_series = new QScatterSeries; | ||||
// m_series->setModel(m_model); | ||||
// m_series->setModelMapping(0,1, Qt::Vertical); | ||||
// // m_series->setModelMappingRange(2, 0); | ||||
// // series->setModelMapping(0,1, Qt::Horizontal); | ||||
// m_chart->addSeries(m_series); | ||||
// seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); | ||||
// // series 2 | ||||
// m_series = new QScatterSeries; | ||||
// m_series->setModel(m_model); | ||||
// m_series->setModelMapping(2,3, Qt::Vertical); | ||||
// // m_series->setModelMappingRange(1, 6); | ||||
// // series->setModelMapping(2,3, Qt::Horizontal); | ||||
// m_chart->addSeries(m_series); | ||||
// seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); | ||||
// // series 3 | ||||
// m_series = new QScatterSeries; | ||||
// m_series->setModel(m_model); | ||||
// m_series->setModelMapping(4,5, Qt::Vertical); | ||||
// // series->setModelMapping(4,5, Qt::Horizontal); | ||||
// m_chart->addSeries(m_series); | ||||
// seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); | ||||
// } | ||||
else if (m_pieRadioButton->isChecked()) | ||||
{ | ||||
m_chart->setAnimationOptions(QChart::SeriesAnimations); | ||||
// pie 1 | ||||
QPieSeries* pieSeries = new QPieSeries; | ||||
pieSeries->setModel(m_model); | ||||
QPieModelMapper *mapper = new QPieModelMapper; | ||||
mapper->setMapValues(1); | ||||
mapper->setMapLabels(1); | ||||
mapper->setFirst(2); | ||||
mapper->setCount(5); | ||||
pieSeries->setModelMapper(mapper); | ||||
pieSeries->setLabelsVisible(true); | ||||
pieSeries->setPieSize(0.75); | ||||
// pieSeries->setHorizontalPosition(0.2); | ||||
// pieSeries->setVerticalPosition(0.3); | ||||
m_chart->addSeries(pieSeries); | ||||
seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | ||||
m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5)); | ||||
// // pie 2 | ||||
// pieSeries = new QPieSeries; | ||||
// pieSeries->setModel(m_model); | ||||
// pieSeries->setModelMapping(1,1, Qt::Vertical); | ||||
// pieSeries->setModelMappingRange(2, -1); | ||||
// pieSeries->setLabelsVisible(true); | ||||
// pieSeries->setPieSize(0.35); | ||||
// pieSeries->setHorizontalPosition(0.8); | ||||
// pieSeries->setVerticalPosition(0.3); | ||||
// m_chart->addSeries(pieSeries); | ||||
// seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000)); | ||||
// // pie 3 | ||||
// pieSeries = new QPieSeries; | ||||
// pieSeries->setModel(m_model); | ||||
// pieSeries->setModelMapping(2,2, Qt::Vertical); | ||||
// pieSeries->setLabelsVisible(true); | ||||
// pieSeries->setPieSize(0.35); | ||||
// pieSeries->setHorizontalPosition(0.5); | ||||
// pieSeries->setVerticalPosition(0.75); | ||||
// m_chart->addSeries(pieSeries); | ||||
// seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); | ||||
// // special pie | ||||
// specialPie = new QPieSeries; | ||||
// specialPie->append(17, "1"); | ||||
// specialPie->append(45, "2"); | ||||
// specialPie->append(77, "3"); | ||||
// specialPie->append(37, "4"); | ||||
// specialPie->append(27, "5"); | ||||
// specialPie->append(47, "6"); | ||||
// specialPie->setPieSize(0.35); | ||||
// specialPie->setHorizontalPosition(0.8); | ||||
// specialPie->setVerticalPosition(0.75); | ||||
// specialPie->setLabelsVisible(true); | ||||
// m_chart->addSeries(specialPie); | ||||
} | ||||
// else if (m_areaRadioButton->isChecked()) | ||||
// { | ||||
// m_chart->setAnimationOptions(QChart::NoAnimation); | ||||
// QLineSeries* upperLineSeries = new QLineSeries; | ||||
// upperLineSeries->setModel(m_model); | ||||
// upperLineSeries->setModelMapping(0, 1, Qt::Vertical); | ||||
// // upperLineSeries->setModelMappingRange(1, 5); | ||||
// QLineSeries* lowerLineSeries = new QLineSeries; | ||||
// lowerLineSeries->setModel(m_model); | ||||
// lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); | ||||
// QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); | ||||
// m_chart->addSeries(areaSeries); | ||||
// seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); | ||||
// m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); | ||||
// m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); | ||||
// } | ||||
Marek Rosa
|
r1170 | else if (m_barRadioButton->isChecked()) | ||
{ | ||||
m_chart->setAnimationOptions(QChart::SeriesAnimations); | ||||
Marek Rosa
|
r1164 | |||
Marek Rosa
|
r1171 | QGroupedBarSeries* barSeries = new QGroupedBarSeries(); | ||
Marek Rosa
|
r1170 | barSeries->setCategories(QStringList()); | ||
barSeries->setModel(m_model); | ||||
// barSeries->setModelMappingRange(2, 5); | ||||
// barSeries->setModelMapping(5, 2, 4, Qt::Vertical); | ||||
QBarModelMapper *mapper = new QBarModelMapper; | ||||
mapper->setMapCategories(5); | ||||
mapper->setMapBarBottom(2); | ||||
mapper->setMapBarTop(4); | ||||
barSeries->setModelMapper(mapper); | ||||
m_chart->addSeries(barSeries); | ||||
QList<QBarSet*> barsets = barSeries->barSets(); | ||||
for (int i = 0; i < barsets.count(); i++) { | ||||
seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); | ||||
m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); | ||||
} | ||||
} | ||||
Marek Rosa
|
r1164 | |||
Marek Rosa
|
r1170 | |||
if (!m_barRadioButton->isChecked()) { | ||||
m_chart->axisX()->setRange(0, 500); | ||||
m_chart->axisY()->setRange(0, 220); | ||||
} | ||||
Marek Rosa
|
r1012 | m_chart->legend()->setVisible(true); | ||
Marek Rosa
|
r861 | |||
Marek Rosa
|
r878 | // repaint table view colors | ||
m_tableView->repaint(); | ||||
m_tableView->setFocus(); | ||||
} | ||||
Marek Rosa
|
r519 | } | ||
Marek Rosa
|
r1056 | void TableWidget::testPie() | ||
{ | ||||
Marek Rosa
|
r1164 | m_series->modelMapper()->setMapX(4); | ||
// m_tableView->setColumnWidth(10, 250); | ||||
Marek Rosa
|
r1090 | // if (specialPie) { | ||
// specialPie->remove(specialPie->slices().at(2)); | ||||
// // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2)); | ||||
// specialPie->append(4, "heloo"); | ||||
// } | ||||
Marek Rosa
|
r1056 | } | ||
Marek Rosa
|
r519 | TableWidget::~TableWidget() | ||
{ | ||||
Michal Klocek
|
r1006 | |||
Marek Rosa
|
r519 | } | ||