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/QWidget>
20 #include <QtGui/QGraphicsItem>
21 #include <QtCore/QString>
22 #include <QtCore/QDebug>
23 #include <QtXml/QDomNode>
24 #include <QtXml/QDomNodeList>
25 #include "themescreen.h"
26 #include "graphicselement.h"
28 #include "graphicsscene.h"
30 ThemeScreen::ThemeScreen(QWidget* parent): GraphicsScreen(parent)
34 bool ThemeScreen::load(QDomNode const& data, Reader* reader)
36 QDomNodeList childNodes = data.childNodes();
38 if(childNodes.size() == 0)
40 error_ = "No elements specified for " + data.nodeName();
44 for(int i = 0; i < childNodes.size(); i++)
46 GraphicsElement* element = GraphicsElement::getElement(childNodes.at(i).nodeName(), reader);
50 qDebug() << "Warning: invalid element: " << childNodes.at(i).nodeName();
54 elements_.push_back(element);
56 QDomNodeList options = childNodes.at(i).childNodes();
58 for(int i = 0; i < options.size(); i++)
60 if(!element->setAttribute(options.at(i).nodeName(), options.at(i).toElement().text()))
62 qDebug() << "Warning: invalid option: " << options.at(i).nodeName();
66 element->addToScene(getScene());
73 void ThemeScreen::removeElements()
75 for(int i = 0; i < elements_.size(); i++)
77 QGraphicsItem* item = elements_.at(i)->getElement();
81 getScene()->removeItem(item);
85 delete elements_.at(i);
91 void ThemeScreen::update()
93 for(int i = 0; i < elements_.size(); i++)
95 elements_.at(i)->update();