##// END OF EJS Templates
make piechartdrilldown compile again
make piechartdrilldown compile again

File last commit:

r782:55ca9199fd76
r798:2c85b9e659bd
Show More
qchartview.cpp
233 lines | 7.4 KiB | text/x-c | CppLexer
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 /****************************************************************************
**
** 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$
**
****************************************************************************/
Michal Klocek
Adds rubberband for zooming...
r58 #include "qchartview.h"
Michal Klocek
Polishing qchart class
r742 #include "qchart_p.h"
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 #include "qchartview_p.h"
Michal Klocek
Adds rubberband for zooming...
r58 #include <QGraphicsScene>
#include <QRubberBand>
Michal Klocek
adds QChartView PIMPL, refactor public API
r746
Michal Klocek
Adds rubberband for zooming...
r58
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
\enum QChartView::RubberBandPolicy
This enum describes the different types of rubber bands that can be used for zoom rect selection
\value NoRubberBand
\value VerticalRubberBand
\value HorizonalRubberBand
\value RectangleRubberBand
*/
Marek Rosa
Small fixes and QDoc comment in qchartview.cpp added
r233 /*!
\class QChartView
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 \brief Standalone charting widget.
Marek Rosa
Added some documentation to QChart and QChartView
r274
Tero Ahola
More examples on QChartView qdoc
r321 QChartView is a standalone widget that can display charts. It does not require separate
QGraphicsScene to work. It manages the graphical representation of different types of
QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
display a chart in your existing QGraphicsScene, you can use the QChart class instead.
Marek Rosa
Added some documentation to QChart and QChartView
r274
\sa QChart
Marek Rosa
Small fixes and QDoc comment in qchartview.cpp added
r233 */
Michal Klocek
Adds rubberband for zooming...
r58 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Constructs a chartView object which is a child of a\a parent.
*/
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QChartView::QChartView(QChart *chart,QWidget *parent) :
Tero Ahola
New theme with light colors, chartview background
r584 QGraphicsView(parent),
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr(new QChartViewPrivate())
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_scene = new QGraphicsScene(this);
d_ptr->m_chart = chart;
d_ptr->m_presenter = chart->d_ptr->m_presenter;
Tero Ahola
Removed the visible frame around chart view
r700 setFrameShape(QFrame::NoFrame);
Tero Ahola
Use window's palette for chart view by default
r664 setBackgroundRole(QPalette::Window);
Michal Klocek
Adds more axis handling...
r176 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Michal Klocek
Adds rubberband for zooming...
r58 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 setScene(d_ptr->m_scene);
d_ptr->m_scene->addItem(chart);
Michal Klocek
Adds rubberband for zooming...
r58 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
Marek Rosa
Added some more documentation to QChart and QChartView
r277
/*!
Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
*/
Michal Klocek
Adds rubberband for zooming...
r58 QChartView::~QChartView()
{
}
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QChart* QChartView::chart() const
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 return d_ptr->m_chart;
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 }
Michal Klocek
Removes QChartWidget...
r136
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Sets the RubberBandPlicy to \a policy. Selected policy determines the way zooming is performed.
*/
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 void QChartView::setRubberBand(const RubberBands& rubberBand)
Michal Klocek
Removes QChartWidget...
r136 {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_rubberBandFlags=rubberBand;
if (!d_ptr->m_rubberBandFlags) {
delete d_ptr->m_rubberBand;
d_ptr->m_rubberBand=0;
Michal Klocek
Adds more axis handling...
r176 return;
Michal Klocek
Removes QChartWidget...
r136 }
Michal Klocek
adds QChartView PIMPL, refactor public API
r746
if (!d_ptr->m_rubberBand) {
d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
d_ptr->m_rubberBand->setEnabled(true);
Michal Klocek
minor. memoryleak fix
r138 }
Michal Klocek
Removes QChartWidget...
r136 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Returns the RubberBandPolicy that is currently being used by the widget.
*/
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QChartView::RubberBands QChartView::rubberBand() const
Michal Klocek
Removes QChartWidget...
r136 {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 return d_ptr->m_rubberBandFlags;
Michal Klocek
Removes QChartWidget...
r136 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
Marek Rosa
Small description update
r328 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 */
Michal Klocek
Removes QChartWidget...
r136 void QChartView::mousePressEvent(QMouseEvent *event)
{
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
Michal Klocek
Removes QChartWidget...
r136
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 int padding = d_ptr->m_presenter->padding();
Michal Klocek
Changes background item...
r639 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
Michal Klocek
Removes QChartWidget...
r136
if (rect.contains(event->pos())) {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_rubberBandOrigin = event->pos();
d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
d_ptr->m_rubberBand->show();
Michal Klocek
Removes QChartWidget...
r136 event->accept();
}
}
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 else {
QGraphicsView::mousePressEvent(event);
}
Michal Klocek
Removes QChartWidget...
r136 }
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
*/
Michal Klocek
Removes QChartWidget...
r136 void QChartView::mouseMoveEvent(QMouseEvent *event)
{
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
int padding = d_ptr->m_presenter->padding();
Michal Klocek
Changes background item...
r639 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x();
int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y();
if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) {
d_ptr->m_rubberBandOrigin.setY(rect.top());
Michal Klocek
Removes QChartWidget...
r136 height = rect.height();
}
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) {
d_ptr->m_rubberBandOrigin.setX(rect.left());
Michal Klocek
Removes QChartWidget...
r136 width= rect.width();
}
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized());
Michal Klocek
Adds more axis handling...
r176 }
else {
Michal Klocek
Removes QChartWidget...
r136 QGraphicsView::mouseMoveEvent(event);
}
}
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
*/
Michal Klocek
Removes QChartWidget...
r136 void QChartView::mouseReleaseEvent(QMouseEvent *event)
{
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 if(d_ptr->m_rubberBand) {
if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
d_ptr->m_rubberBand->hide();
QRect rect = d_ptr->m_rubberBand->geometry();
d_ptr->m_chart->zoomIn(rect);
Michal Klocek
Adds more axis handling...
r176 event->accept();
}
Michal Klocek
Removes QChartWidget...
r136
Michal Klocek
Adds loosenumber algorithm...
r678 if(event->button()==Qt::RightButton){
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_chart->zoomOut();
Michal Klocek
Adds loosenumber algorithm...
r678 event->accept();
}
Michal Klocek
Adds more axis handling...
r176 }
else {
Michal Klocek
Removes QChartWidget...
r136 QGraphicsView::mouseReleaseEvent(event);
}
}
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Pressing + and - keys performs zoomIn() and zoomOut() respectivly.
In other \a event is passed to the QGraphicsView::keyPressEvent() implementation
*/
Michal Klocek
Removes QChartWidget...
r136 void QChartView::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
Michal Klocek
Adds more axis handling...
r176 case Qt::Key_Plus:
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_chart->zoomIn();
Michal Klocek
Removes QChartWidget...
r136 break;
Michal Klocek
Adds more axis handling...
r176 case Qt::Key_Minus:
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 d_ptr->m_chart->zoomOut();
Michal Klocek
Removes QChartWidget...
r136 break;
Michal Klocek
Adds more axis handling...
r176 default:
Michal Klocek
Removes QChartWidget...
r136 QGraphicsView::keyPressEvent(event);
break;
}
}
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 Resizes and updates the chart area using the \a event data
Michal Klocek
Adds animation settings handling
r298 */
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 void QChartView::resizeEvent(QResizeEvent *event)
Michal Klocek
Adds animation settings handling
r298 {
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QGraphicsView::resizeEvent(event);
Michal Klocek
Add stub from minimum size
r782 d_ptr->m_chart->resize(size());
setSceneRect(d_ptr->m_chart->geometry());
Michal Klocek
Adds animation settings handling
r298 }
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Michal Klocek
Adds animation settings handling
r298
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QChartViewPrivate::QChartViewPrivate():
m_scene(0),
m_chart(0),
m_presenter(0),
m_rubberBand(0),
m_rubberBandFlags(QChartView::NoRubberBand)
Michal Klocek
Adds scroll support...
r531 {
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 }
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 QChartViewPrivate::~QChartViewPrivate()
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 {
}
Tero Ahola
New theme with light colors, chartview background
r584 #include "moc_qchartview.cpp"
Michal Klocek
Adds rubberband for zooming...
r58 QTCOMMERCIALCHART_END_NAMESPACE