##// END OF EJS Templates
barchart pimpl part 1
barchart pimpl part 1

File last commit:

r934:284eb2f28726
r934:284eb2f28726
Show More
qbarset.cpp
467 lines | 8.8 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** 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$
**
****************************************************************************/
sauimone
proof of concept implementation for barset and barcategory
r169 #include "qbarset.h"
sauimone
barchart pimpl part 1
r934 #include "qbarsetprivate_p.h"
//#include <QDebug>
sauimone
tooltip for barcharts
r283 #include <QToolTip>
sauimone
proof of concept implementation for barset and barcategory
r169
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
barchart pimpl part 1
r934
QBarSetPrivate::QBarSetPrivate(QString name, QBarSet *parent) : QObject(parent),
q_ptr(parent),
m_name(name),
m_labelsVisible(false)
{
}
QBarSetPrivate::~QBarSetPrivate()
{
}
void QBarSetPrivate::setName(QString name)
{
m_name = name;
}
QString QBarSetPrivate::name() const
{
return m_name;
}
QBarSetPrivate& QBarSetPrivate::operator << (const qreal &value)
{
m_values.append(value);
emit structureChanged();
return *this;
}
void QBarSetPrivate::insertValue(int i, qreal value)
{
m_values.insert(i, value);
}
void QBarSetPrivate::removeValue(int i)
{
m_values.removeAt(i);
}
int QBarSetPrivate::count() const
{
return m_values.count();
}
qreal QBarSetPrivate::valueAt(int index) const
{
return m_values.at(index);
}
void QBarSetPrivate::setValue(int index, qreal value)
{
m_values.replace(index,value);
emit valueChanged();
}
qreal QBarSetPrivate::sum() const
{
qreal sum(0);
for (int i=0; i < m_values.count(); i++) {
sum += m_values.at(i);
}
return sum;
}
void QBarSetPrivate::setPen(const QPen &pen)
{
m_pen = pen;
emit valueChanged();
}
QPen QBarSetPrivate::pen() const
{
return m_pen;
}
void QBarSetPrivate::setBrush(const QBrush &brush)
{
m_brush = brush;
emit valueChanged();
}
QBrush QBarSetPrivate::brush() const
{
return m_brush;
}
void QBarSetPrivate::setLabelPen(const QPen &pen)
{
m_labelPen = pen;
emit valueChanged();
}
QPen QBarSetPrivate::labelPen() const
{
return m_labelPen;
}
void QBarSetPrivate::setLabelBrush(const QBrush &brush)
{
m_labelBrush = brush;
emit valueChanged();
}
QBrush QBarSetPrivate::labelBrush() const
{
return m_labelBrush;
}
void QBarSetPrivate::setLabelFont(const QFont &font)
{
m_labelFont = font;
emit valueChanged();
}
QFont QBarSetPrivate::labelFont() const
{
return m_labelFont;
}
void QBarSetPrivate::setLabelsVisible(bool visible)
{
m_labelsVisible = visible;
emit labelsVisibleChanged(visible);
}
bool QBarSetPrivate::labelsVisible() const
{
return m_labelsVisible;
}
void QBarSetPrivate::barHoverEnterEvent(QPoint pos)
{
emit showToolTip(pos, m_name);
emit hoverEnter(pos);
}
void QBarSetPrivate::barHoverLeaveEvent()
{
// Emit signal to user of charts
emit hoverLeave();
}
sauimone
Documentation for bar charts
r313 /*!
\class QBarSet
\brief part of QtCommercial chart API.
QBarSet represents one set of bars. Set of bars contains one data value for each category.
First value of set is assumed to belong to first category, second to second category and so on.
If set has fewer values than there are categories, then the missing values are assumed to be
at the end of set. For missing values in middle of a set, numerical value of zero is used.
sauimone
updated documentation and examples for barcharts
r325 \mainclass
sauimone
replaced qbarcategory with qstringlist
r377 \sa QBarSeries, QStackedBarSeries, QPercentBarSeries
sauimone
Documentation for bar charts
r313 */
/*!
sauimone
combined clicked and rightclicked signals in barchart
r812 \fn void QBarSet::clicked(QString category, Qt::MouseButtons button)
sauimone
Documentation for bar charts
r313 \brief signals that set has been clicked
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 Parameter \a category describes on which category was clicked
sauimone
combined clicked and rightclicked signals in barchart
r812 Parameter \a button mouse button
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 */
sauimone
Documentation for bar charts
r313 /*!
\fn void QBarSet::hoverEnter(QPoint pos)
\brief signals that mouse has entered over the set at position \a pos.
*/
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425
sauimone
Documentation for bar charts
r313 /*!
\fn void QBarSet::hoverLeave()
\brief signals that mouse has left from the set.
*/
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425
sauimone
Documentation for bar charts
r313 /*!
\fn void QBarSet::showToolTip(QPoint pos, QString tip)
sauimone
Updated barchart documentation
r319 \brief \internal \a pos \a tip
sauimone
Documentation for bar charts
r313 */
/*!
Constructs QBarSet with a name of \a name and with parent of \a parent
*/
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280 QBarSet::QBarSet(QString name, QObject *parent)
sauimone
updated barchart examples. minor fixes
r276 : QObject(parent)
sauimone
barchart pimpl part 1
r934 ,d_ptr(new QBarSetPrivate(name,this))
// ,m_name(name)
// ,m_labelsVisible(false)
sauimone
proof of concept implementation for barset and barcategory
r169 {
}
sauimone
Documentation for bar charts
r313 /*!
Sets new \a name for set.
*/
sauimone
proof of concept implementation for barset and barcategory
r169 void QBarSet::setName(QString name)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setName(name);
sauimone
proof of concept implementation for barset and barcategory
r169 }
sauimone
Documentation for bar charts
r313
/*!
Returns name of the set.
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 QString QBarSet::name() const
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->name();
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
proof of concept implementation for barset and barcategory
r169
sauimone
Documentation for bar charts
r313 /*!
Appends new value \a value to the end of set.
*/
sauimone
proof of concept implementation for barset and barcategory
r169 QBarSet& QBarSet::operator << (const qreal &value)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->operator <<(value);
sauimone
proof of concept implementation for barset and barcategory
r169 return *this;
sauimone
barchart pimpl part 1
r934
// m_values.append(value);
// emit structureChanged();
// return *this;
sauimone
proof of concept implementation for barset and barcategory
r169 }
Marek Rosa
Updated spline chart example documentation and added some more docs to barseries
r901 /*!
Inserts new \a value on the \a i position.
The value that is currently at this postion is moved to postion i + 1
\sa removeValue()
*/
Marek Rosa
Adding data to BarSet through model added
r662 void QBarSet::insertValue(int i, qreal value)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->insertValue(i,value);
// m_values.insert(i, value);
Marek Rosa
Adding data to BarSet through model added
r662 }
Marek Rosa
Updated spline chart example documentation and added some more docs to barseries
r901 /*!
Removes the value specified by \a i
\sa insertValue()
*/
Marek Rosa
Removing data from BarSeries through model added
r663 void QBarSet::removeValue(int i)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->removeValue(i);
// m_values.removeAt(i);
Marek Rosa
Removing data from BarSeries through model added
r663 }
sauimone
Documentation for bar charts
r313 /*!
Returns count of values in set.
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 int QBarSet::count() const
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->count();
// return m_values.count();
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
Documentation for bar charts
r313 /*!
Returns value of set indexed by \a index
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 qreal QBarSet::valueAt(int index) const
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->valueAt(index);
// return m_values.at(index);
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
Documentation for bar charts
r313 /*!
Sets a new value \a value to set, indexed by \a index
*/
sauimone
brush support for bargroups
r183 void QBarSet::setValue(int index, qreal value)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setValue(index,value);
// m_values.replace(index,value);
// emit valueChanged();
sauimone
brush support for bargroups
r183 }
sauimone
fixed example paths in barchart documentation
r492 /*!
sauimone
barchart pimpl part 1
r934 Returns sum of all values in barset.
sauimone
fixed example paths in barchart documentation
r492 */
sauimone
barchart pimpl part 1
r934 qreal QBarSet::sum() const
sauimone
updating drilldown example. Needs some more thinking
r438 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->sum();
/*
sauimone
updating drilldown example. Needs some more thinking
r438 qreal total(0);
sauimone
minor code review fixes, part n
r763 for (int i=0; i < m_values.count(); i++) {
total += m_values.at(i);
sauimone
updating drilldown example. Needs some more thinking
r438 }
return total;
sauimone
barchart pimpl part 1
r934 */
sauimone
updating drilldown example. Needs some more thinking
r438 }
sauimone
Documentation for bar charts
r313 /*!
Sets pen for set. Bars of this set are drawn using \a pen
*/
sauimone
minor code review fixes, part n
r763 void QBarSet::setPen(const QPen &pen)
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setPen(pen);
// m_pen = pen;
// emit valueChanged();
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
Documentation for bar charts
r313 /*!
Returns pen of the set.
*/
sauimone
Fixed layout for barcharts
r473 QPen QBarSet::pen() const
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->pen();
// return m_pen;
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
Documentation for bar charts
r313 /*!
Sets brush for the set. Bars of this set are drawn using \a brush
*/
sauimone
minor code review fixes, part n
r763 void QBarSet::setBrush(const QBrush &brush)
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setBrush(brush);
// m_brush = brush;
// emit valueChanged();
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
Documentation for bar charts
r313 /*!
Returns brush of the set.
*/
sauimone
Fixed layout for barcharts
r473 QBrush QBarSet::brush() const
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->brush();
// return m_brush;
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
better use of gradients in barcharts
r512 /*!
sauimone
fixed clipping in barcharts
r839 Sets \a pen of the values that are drawn on top of this barset
sauimone
better use of gradients in barcharts
r512 */
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 void QBarSet::setLabelPen(const QPen &pen)
sauimone
better use of gradients in barcharts
r512 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setLabelPen(pen);
// m_labelPen = pen;
// emit valueChanged();
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 }
/*!
Returns pen of the values that are drawn on top of this barset
*/
QPen QBarSet::labelPen() const
{
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->labelPen();
// return m_labelPen;
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 }
/*!
sauimone
fixed clipping in barcharts
r839 Sets \a brush of the values that are drawn on top of this barset
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 */
void QBarSet::setLabelBrush(const QBrush &brush)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setLabelBrush(brush);
// m_labelBrush = brush;
// emit valueChanged();
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 }
/*!
Returns brush of the values that are drawn on top of this barset
*/
QBrush QBarSet::labelBrush() const
{
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->labelBrush();
// return m_labelBrush;
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 }
/*!
sauimone
fixed clipping in barcharts
r839 Sets the \a font for values that are drawn on top of this barset
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 */
void QBarSet::setLabelFont(const QFont &font)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setLabelFont(font);
// m_labelFont = font;
// emit valueChanged();
sauimone
better use of gradients in barcharts
r512 }
/*!
sauimone
Barchart value layout fix
r817 Returns the pen for values that are drawn on top of this set
sauimone
better use of gradients in barcharts
r512 */
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 QFont QBarSet::labelFont() const
sauimone
better use of gradients in barcharts
r512 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->labelFont();
// return m_labelFont;
sauimone
better use of gradients in barcharts
r512 }
sauimone
values visibility handling changed in barchart
r813 /*!
Marek Rosa
Docs updated
r908 Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets.
sauimone
values visibility handling changed in barchart
r813 */
Marek Rosa
Docs updated
r908
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 void QBarSet::setLabelsVisible(bool visible)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSet);
d->setLabelsVisible(visible);
// m_labelsVisible = visible;
// emit labelsVisibleChanged(visible);
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 }
/*!
Returns the visibility of values
*/
bool QBarSet::labelsVisible() const
sauimone
values visibility handling changed in barchart
r813 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSet);
return d->labelsVisible();
// return m_labelsVisible;
sauimone
values visibility handling changed in barchart
r813 }
sauimone
barchart pimpl part 1
r934 /*
sauimone
right click feature for bar series. Enables drilldown
r412 void QBarSet::barHoverEnterEvent(QPoint pos)
sauimone
updated barchart examples. minor fixes
r276 {
sauimone
minor code review fixes, part n
r763 emit showToolTip(pos, m_name);
sauimone
moved tooltip to presenter
r288 emit hoverEnter(pos);
sauimone
updated barchart examples. minor fixes
r276 }
sauimone
Documentation for bar charts
r313 */
sauimone
barchart pimpl part 1
r934 /*
sauimone
right click feature for bar series. Enables drilldown
r412 void QBarSet::barHoverLeaveEvent()
sauimone
updated barchart examples. minor fixes
r276 {
sauimone
moved tooltip to presenter
r288 // Emit signal to user of charts
emit hoverLeave();
sauimone
updated barchart examples. minor fixes
r276 }
sauimone
barchart pimpl part 1
r934 */
sauimone
signals and slots for bars and sets
r239 #include "moc_qbarset.cpp"
sauimone
barchart pimpl part 1
r934 #include "moc_qbarsetprivate_p.cpp"
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737
sauimone
proof of concept implementation for barset and barcategory
r169 QTCOMMERCIALCHART_END_NAMESPACE