--- /dev/null
+/*
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+http://www.gnu.org/licenses/gpl-3.0.txt
+*/
+/**
+ * @file ffchartbutton.cpp
+ * @brief Implementation of the FFChartButton class.
+ *
+ * @author ComArch S.A.
+ * @date 2009.09.03
+ * @version 1.0
+ * Extend QGraphicsSvgItem to easy use 1 or 2 image and added functionality
+ * to decrease and increase item after click
+ */
+
+#include "ffchartbutton.h"
+
+/**
+ * Constructs a FFChartButton with a parent.
+ * Set variables to initial values.
+ */
+FFChartButton::FFChartButton(QGraphicsItem* parent) :
+ QGraphicsSvgItem(parent)
+{
+ init();
+}
+
+/**
+ * A virtual destructor of FFChartButton.
+ */
+FFChartButton::~FFChartButton()
+{
+ ;
+}
+
+/**
+ * Set variables to initial values.
+ */
+void FFChartButton::init()
+{
+ //sets default values
+ state = false; //usefull when changing beetwen 2 images, it remember click state - what image should be display
+ twoImageON = false; //state to store if the button have 2 images
+ startedTimeLine = false; //state to store if time line ends
+
+ sizeRatio = 1;
+ frameRange_ = DEFAULT_FRAME_RANGE;
+ duration_ = DEFAULT_DURATION_TIME;
+ zoomRatio_ = DEFAULT_ZOOM_RATIO;
+ scaleWidth = 1;
+ scaleHeight = 1;
+
+ image = new FFViewCache;
+ image2 = new FFViewCache;
+
+ //sets animation's parameters
+ animation = new QTimeLine(duration_, this);
+ animation->setFrameRange(0, frameRange_);
+ animation->setUpdateInterval(duration_ / frameRange_);
+
+ //connects
+ connect(animation, SIGNAL(frameChanged(int)), this, SLOT(tick(int)));
+ connect(animation, SIGNAL(finished()), this, SLOT(animationFinished()));
+}
+
+/**
+ * Function responsible for animation (zooming)
+ * @param frame Number of the frame
+ */
+void FFChartButton::tick(int frame)
+{
+
+ qreal width = this->boundingRect().width();
+ qreal height = this->boundingRect().height();
+ qreal ratio = 1;
+ QGraphicsSvgItem::scale(1 / sizeRatio, 1 / sizeRatio);
+
+ //Setting scaling ratio
+ //first part of animation
+ if(frame <= frameRange_ / 2)
+ {
+ ratio = ((zoomRatio_ - 1) * (frame)) / (frameRange_ / 2) + 1;
+ }
+ //second part of animation
+ else if(frame <= frameRange_)
+ {
+ ratio = (zoomRatio_ - 1) * (frameRange_ - frame) / (frameRange_
+ / 2) + 1;
+ }
+
+ sizeRatio = ratio;
+ //change scale and posiotion of button
+ QGraphicsSvgItem::scale(ratio, ratio);
+ this->setPos(startingPosition.x() - ((ratio * width - width)
+ * scaleWidth / 2), startingPosition.y() - ((ratio
+ * height - height) * scaleHeight / 2));
+}
+
+/**
+ * Function to handle situation when animation reach end
+ */
+void FFChartButton::animationFinished()
+{
+ animation->stop();
+ sizeRatio = 1;
+ startedTimeLine = false;
+}
+
+/**
+ * Set image of item
+ * @param path Path to image
+ */
+void FFChartButton::setImage(QString path)
+{
+ image->init(path + ".svg");
+ image->updateView(image->defaultSize());
+ setSharedRenderer(image->renderer());
+
+ twoImageON = false;
+}
+
+/**
+ * Set images of item
+ * @param path Path to first image
+ * @param path2 Path to second image
+ */
+void FFChartButton::setImage(QString path, QString path2)
+{
+
+ image->init(path + ".svg");
+ image2->init(path2 + ".svg");
+
+ setSharedRenderer(image->renderer());
+ twoImageON = true;
+}
+
+/**
+ * Set size of item
+ * @param size New size of the item
+ */
+void FFChartButton::setSize(const QSizeF& size)
+{
+ qreal tmpScaleWidth = size.toSize().width() / boundingRect().width()
+ * scaleWidth;
+ qreal tmpScaleHeight = size.toSize().height() / boundingRect().height()
+ * scaleHeight;
+ scale(tmpScaleWidth, tmpScaleHeight);
+}
+
+/**
+ * Set if item will be increasing (zoomRatio>1) or will be decreasing (zoomRatio<1)
+ * @param zoomRatio How much size will be changing during animation
+ */
+void FFChartButton::setZoomRatio(qreal zoomRatio)
+{
+ zoomRatio_ = zoomRatio;
+}
+
+/**
+ * Set number of frame in animation
+ * @param frameRange Number of frames
+ */
+void FFChartButton::setFrameRange(int frameRange)
+{
+ frameRange_ = frameRange;
+ animation->setFrameRange(0, frameRange_);
+}
+
+/**
+ * Set how much time animation take
+ * @param duration Time of animation
+ */
+void FFChartButton::setDuration(int duration)
+{
+ duration_ = duration;
+ animation->setDuration(duration_);
+}
+
+/**
+ * Scale the item
+ * @param sx Size of scale in width
+ * @param sy Size of scale in height
+ */
+void FFChartButton::scale(qreal sx, qreal sy)
+{
+ scaleWidth = sx * scaleWidth;
+ scaleHeight = sy * scaleHeight;
+ QGraphicsSvgItem::scale(scaleWidth, scaleHeight);
+}
+
+/**
+ * Return if the item will be increasing (zoomRatio>1) or will be decreasing (zoomRatio<1)
+ */
+qreal FFChartButton::zoomRatio()
+{
+ return zoomRatio_;
+}
+
+/**
+ * Return number of frame in animation
+ */
+int FFChartButton::frameRange()
+{
+ return frameRange_;
+}
+
+/**
+ * Return how much time animation take
+ */
+int FFChartButton::duration()
+{
+ return duration_;
+}
+
+/**
+ * Support mouse release event.
+ * @param event Contains all informations about event.
+ */
+void FFChartButton::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
+{
+ Q_UNUSED(event)
+ //If button has two images they are toggled
+ if(twoImageON)
+ {
+ if(state == false)
+ {
+ setSharedRenderer(image2->renderer());
+ }
+ else
+ {
+ setSharedRenderer(image->renderer());
+ }
+ state = !state;
+ }
+
+ //Starts animation
+ if(!startedTimeLine)
+ {
+ startingPosition = this->pos();
+ animation->start();
+ startedTimeLine = true;
+ }
+ emit mouseRelease();
+}
+
+/**
+ * Support mouse press event.
+ * @param event Contains all informations about event.
+ */
+void FFChartButton::mousePressEvent(QGraphicsSceneMouseEvent* event)
+{
+ Q_UNUSED(event)
+ emit mousePress();
+}
+
+/**
+ * \fn void FFChartButton::mouseRelease()
+ * This signal is emitted when the item is released.
+ */
+
+/**
+ * \fn void FFChartButton::mousePress()
+ * This signal is emitted when the item is pressed.
+ */