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 <QtCore/QString>
21 #include <QtCore/QDebug>
22 #include <QtXml/QDomNode>
23 #include <QtXml/QDomNodeList>
24 #include "themescreen.h"
25 #include "graphicselement.h"
28 ThemeScreen::ThemeScreen(QWidget* parent): GraphicsScreen(parent)
32 bool ThemeScreen::load(QDomNode const& data, Reader* reader)
34 QDomNodeList childNodes = data.childNodes();
36 if(childNodes.size() == 0)
38 error_ = "No elements specified for " + data.nodeName();
42 for(int i = 0; i < childNodes.size(); i++)
44 GraphicsElement* element = GraphicsElement::getElement(childNodes.at(i).nodeName(), reader);
48 qDebug() << "Warning: invalid element: " << childNodes.at(i).nodeName();
52 elements_.push_back(element);
54 QDomNodeList options = childNodes.at(i).childNodes();
56 for(int i = 0; i < options.size(); i++)
58 if(!element->setAttribute(options.at(i).nodeName(), options.at(i).toElement().text()))
60 qDebug() << "Warning: invalid option: " << options.at(i).nodeName();
64 element->addToScene(getScene());
71 void ThemeScreen::update()
73 for(int i = 0; i < elements_.size(); i++)
75 elements_.at(i)->update();