2 * This file is part of jSpeed.
4 * jSpeed is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * jSpeed is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtGui/QGraphicsRectItem>
20 #include <QtCore/QString>
21 #include <QtCore/QDebug>
22 #include "rectangle.h"
24 #include "graphicsscene.h"
28 const GraphicsElement::AttributeDetails ATTRIBUTES[Rectangle::ATTRIBUTE_COUNT] =
33 {"visiblewhen", false},
40 Rectangle::Rectangle(Reader* reader): GraphicsElement(reader),
41 x_(0), y_(0), width_(0), height_(0)
43 element_ = new QGraphicsRectItem();
46 bool Rectangle::setAttribute(QString const& name, QString const& value)
51 if((attrId = getAttribute(name, value, ATTRIBUTES, ATTRIBUTE_COUNT, intVal)) != -1)
53 Attribute attr = static_cast<Attribute>(attrId);
64 element_->setZValue(intVal);
67 setVisibleWhen(strToVisibleWhen(value));
76 element_->setBrush(QBrush(QColor(value)));
80 qDebug() << "Unknown attribute: " << attr;
92 void Rectangle::addToScene(GraphicsScene* scene)
96 int maxSize = scene->width();
98 if(scene->height() > maxSize)
100 maxSize = scene->height();
108 int height = height_;
115 element_->setRect(x_, y_, width, height);
116 scene->addItem(element_);
119 void Rectangle::update()
123 QGraphicsItem* Rectangle::getElement() const