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 #ifndef GRAPHICSELEMENT_H
20 #define GRAPHICSELEMENT_H
22 #include <QtCore/QObject>
23 #include <QtCore/QMap>
30 class QGraphicsEffect;
34 class GraphicsElement : public QObject
40 struct AttributeDetails
46 GraphicsElement(Reader* reader);
47 static GraphicsElement* getElement(QString const& name, Reader* reader);
48 virtual bool setAttribute(QString const& name, QString const& value) = 0;
49 virtual void addToScene(GraphicsScene* scene) = 0;
50 virtual void update() = 0;
51 virtual QGraphicsItem* getElement() const = 0;
52 QString const& getError() const;
53 bool setEffect(QString const& effect);
54 bool setEffectAttribute(QString const& name, QString const& value);
56 bool canBeVisible() const;
59 enum VisibleWhen {ALWAYS, POI_VISIBLE, SPEED_EXCEEDED};
61 int getAttribute(QString const& name, QString const& value, const AttributeDetails details[], int count, int& intValue);
62 void setError(QString const& error);
63 bool readFile(QString const& name, QByteArray& data);
64 bool getFont(QString const& name, QFont& font);
65 void setVisibleWhen(VisibleWhen when);
66 VisibleWhen strToVisibleWhen(QString const& str) const;
69 void updateVisibility(bool visible);
75 QMap<QString, QString> loadedFonts_;
76 VisibleWhen visibleWhen_;