2 GNU GENERAL PUBLIC LICENSE
3 Version 3, 29 June 2007
5 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
11 The GNU General Public License is a free, copyleft license for
12 software and other kinds of works.
14 The licenses for most software and other practical works are designed
15 to take away your freedom to share and change the works. By contrast,
16 the GNU General Public License is intended to guarantee your freedom to
17 share and change all versions of a program--to make sure it remains free
18 software for all its users. We, the Free Software Foundation, use the
19 GNU General Public License for most of our software; it applies also to
20 any other work released this way by its authors. You can apply it to
23 When we speak of free software, we are referring to freedom, not
24 price. Our General Public Licenses are designed to make sure that you
25 have the freedom to distribute copies of free software (and charge for
26 them if you wish), that you receive source code or can get it if you
27 want it, that you can change the software or use pieces of it in new
28 free programs, and that you know you can do these things.
30 To protect your rights, we need to prevent others from denying you
31 these rights or asking you to surrender the rights. Therefore, you have
32 certain responsibilities if you distribute copies of the software, or if
33 you modify it: responsibilities to respect the freedom of others.
35 For example, if you distribute copies of such a program, whether
36 gratis or for a fee, you must pass on to the recipients the same
37 freedoms that you received. You must make sure that they, too, receive
38 or can get the source code. And you must show them these terms so they
41 Developers that use the GNU GPL protect your rights with two steps:
42 (1) assert copyright on the software, and (2) offer you this License
43 giving you legal permission to copy, distribute and/or modify it.
45 For the developers' and authors' protection, the GPL clearly explains
46 that there is no warranty for this free software. For both users' and
47 authors' sake, the GPL requires that modified versions be marked as
48 changed, so that their problems will not be attributed erroneously to
49 authors of previous versions.
51 Some devices are designed to deny users access to install or run
52 modified versions of the software inside them, although the manufacturer
53 can do so. This is fundamentally incompatible with the aim of
54 protecting users' freedom to change the software. The systematic
55 pattern of such abuse occurs in the area of products for individuals to
56 use, which is precisely where it is most unacceptable. Therefore, we
57 have designed this version of the GPL to prohibit the practice for those
58 products. If such problems arise substantially in other domains, we
59 stand ready to extend this provision to those domains in future versions
60 of the GPL, as needed to protect the freedom of users.
62 Finally, every program is threatened constantly by software patents.
63 States should not allow patents to restrict development and use of
64 software on general-purpose computers, but in those that do, we wish to
65 avoid the special danger that patents applied to a free program could
66 make it effectively proprietary. To prevent this, the GPL assures that
67 patents cannot be used to render the program non-free.
69 The precise terms and conditions for copying, distribution and
72 http://www.gnu.org/licenses/gpl-3.0.txt
75 * @file ffchartlegend.cpp
76 * @brief Implementation of the FFChartLegend class
78 * @author ComArch S.A.
82 #include "ffchartlegend.h"
85 * Constructs a FFChartLegend with a parent.
87 FFChartLegend::FFChartLegend(QWidget* parent) :
88 FFAbstractWidget(parent)
90 this->parent = parent;
95 * A virtual destructor.
97 FFChartLegend::~FFChartLegend()
99 int num = legendSeriesTable.size();
100 for(int i = 0; i < num; ++i)
102 delete legendSeriesTable.at(0);
103 legendSeriesTable.remove(0);
108 * Initiates all needed fields and functionality
110 void FFChartLegend::init()
112 //sets default values
115 backgroundColor = DEFAULT_LEGEND_BACKGROUND_COLOR;
116 backgroundOpacity = DEFAULT_LEGEND_BACKGROUND_OPACITY;
118 actualChangingSeries = NULL;
121 setStyleSheet("background-color: transparent");
124 legendLayout = new QGridLayout(this);
125 legendLayout ->setMargin(0);
126 this->setLayout(legendLayout);
128 legendScrollArea = new FFScrollArea(this);
129 legendScrollArea->setFrameStyle(0);
130 legendScrollAreaItem = new QWidget(legendScrollArea);
131 legendScrollAreaLayout = new QGridLayout(legendScrollAreaItem);
132 legendScrollAreaItem->setLayout(legendScrollAreaLayout);
133 legendScrollAreaLayout->setMargin(0);
134 legendScrollAreaLayout->setSpacing(5);
136 legendScrollAreaItem->setStyleSheet("background-color: transparent");
137 legendScrollArea->setWidget(legendScrollAreaItem);
138 legendScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
139 legendScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
140 legendScrollArea->setFrameStyle(0);
142 legendLayout->addWidget(legendScrollArea);
144 legendControlPanel = new FFChartLegendControlPanel(this);
145 legendControlPanel->hide();
148 connect(legendControlPanel,
149 SIGNAL(penChanged(QPen)),
151 SLOT(changeSeriesPen(QPen)));
155 * Supports click event. Shows or hide chart's legend
157 void FFChartLegend::popUp()
171 * It updates size of FFChartLegend's elements
172 * Calls changeSize() method
174 void FFChartLegend::resizeEvent(QResizeEvent* event)
177 if(this->isVisible())
184 * Fits size of FFChartLegend's elements chart when show event appeared.
185 * Calls changeSize() method.
187 void FFChartLegend::showEvent(QShowEvent* event)
195 * Add series to FFChartLegend.
197 * @param series is a pointer to series on a FFChart
199 void FFChartLegend::addSeries(FFChartSeries* series)
201 //creates buttons representing series
202 FFScrollingCheckBox* visibleCheckbox =
203 new FFScrollingCheckBox(legendScrollAreaItem);
204 FFLineButton* modifyButton = new FFLineButton(legendScrollAreaItem);
206 //sets series name in buttons
207 visibleCheckbox->setDescription(series->name());
208 visibleCheckbox->setChecked(series->isVisible());
209 visibleCheckbox->disableTitle(true);
210 visibleCheckbox->setTopMargin(8);
211 visibleCheckbox->setBottomMargin(8);
212 visibleCheckbox->setRightMargin(2);
213 visibleCheckbox->setLeftMargin(2);
214 visibleCheckbox->setAttribute(Qt::WA_DeleteOnClose);
216 modifyButton->setPen(*series->pen());
217 modifyButton->setAttribute(Qt::WA_DeleteOnClose);
219 SeriesContainer* tempSeriesPointer =
220 new SeriesContainer(series,
223 //adds seriesContener to series table
224 legendSeriesTable.append(tempSeriesPointer);
226 //adds buttons to layout
227 legendScrollAreaLayout->addWidget(legendSeriesTable.at(legendSeriesTable.size()
228 - 1)->visibleCheckBox_,
229 legendSeriesTable.size() - 1,
233 legendScrollAreaLayout->addWidget(legendSeriesTable.at(legendSeriesTable.size()
234 - 1)->controlPanelButton_,
235 legendSeriesTable.size() - 1,
240 //connecting buttons to legend
241 connect(modifyButton,
244 SLOT(chooseChangingSeries()));
245 connect(visibleCheckbox, SIGNAL(clicked()), this, SLOT(changeVisible()));
250 * Fits size of FFChartLegend's elements
252 void FFChartLegend::changeSize()
254 // sets geometry for legend elements
255 legendControlPanel->setGeometry(0, 0, size().width(), size().height());
257 legendScrollAreaItem->setGeometry(0,
259 legendScrollArea->width(),
260 legendSeriesTable.size()
261 * (DEFAULT_BUTTON_HEIGHT
263 //update legendscrollarea
264 legendScrollArea->setWidget(NULL);
265 legendScrollArea->setWidget(legendScrollAreaItem);
269 * Assign pointer on actual modified series to the temporary pointer.
271 void FFChartLegend::chooseChangingSeries()
273 //check which series was chosen to modification
274 for(int i = 0; i < legendSeriesTable.size(); i++)
276 if(legendSeriesTable.at(i)->controlPanelButton_
277 == (FFLineButton*)sender())
278 actualChangingSeries = legendSeriesTable.at(i);
281 //sets and shows legendCotnrolPanel
282 legendControlPanel->setPen(*actualChangingSeries->series_->pen());
283 legendControlPanel->show();
289 * Updates a pen of button representing actual modified series and emits
292 * @param pen represents setting series pen
295 void FFChartLegend::changeSeriesPen(QPen pen)
297 actualChangingSeries->series_->setPen(pen);
298 actualChangingSeries->controlPanelButton_->setPen(pen);
303 * Updates series visibility
305 void FFChartLegend::changeVisible()
307 //looks for pointer to changing series and change it visibility and
308 //state of visibleCheckbox
310 for(int i = 0; i < legendSeriesTable.size(); i++)
312 if(legendSeriesTable.at(i)->visibleCheckBox_
313 == (FFScrollingCheckBox*)sender())
317 !(legendSeriesTable.at(i)->series_->isVisible());
319 legendSeriesTable.at(i)->series_->setVisible(tempVisible);
320 legendSeriesTable.at(i)->visibleCheckBox_->setChecked(tempVisible);
328 * Deletes series from series contener
330 * @param series is a pointer to series that will be removed.
332 void FFChartLegend::deleteSeries(FFChartSeries* series)
334 //looks for given series in legendSeriesTable and deletes it.
335 for(int i = 0; i < legendSeriesTable.size(); i++)
337 if(series == legendSeriesTable.at(i)->series_)
339 legendControlPanel->hide();
341 delete legendSeriesTable.at(i);
342 legendSeriesTable.remove(i);
350 * Draw FFChartLegend background
351 * @param event Contains all informations about event.
353 void FFChartLegend::paintEvent(QPaintEvent *event)
358 paint.setOpacity(backgroundOpacity);
359 paint.setBrush(backgroundColor);
360 paint.setPen(Qt::transparent);
361 paint.drawRect(0, 0, width(), height());
366 \fn void FFChartLegend::updateSeries()
368 This signal is emitted when the series is/are changed
372 * Constructs a FFChartLegend with pointers to series, and buttons .
374 SeriesContainer::SeriesContainer(FFChartSeries* series,
375 FFScrollingCheckBox* visibleCheckBox,
376 FFLineButton* controlPanelButton)
379 visibleCheckBox_ = visibleCheckBox;
380 controlPanelButton_ = controlPanelButton;
384 * A virtual destructor
386 SeriesContainer::~SeriesContainer()
388 visibleCheckBox_->close();
389 controlPanelButton_->close();