Changelog fixed.
[jspeed] / src / graphicselement.h
1 /*
2  * This file is part of jSpeed.
3  *
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.
8  *
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.
13  *
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/>.
16  *
17  */
18
19 #ifndef GRAPHICSELEMENT_H
20 #define GRAPHICSELEMENT_H
21
22 #include <QtCore/QMap>
23 #include "location.h"
24
25 class QString;
26 class QByteArray;
27 class QFont;
28 class QGraphicsItem;
29 class GraphicsScene;
30 class QGraphicsEffect;
31 class Reader;
32 class Effect;
33
34 class GraphicsElement
35 {
36 public:
37
38     struct AttributeDetails
39     {
40         QString name;
41         bool isInt;
42     };
43
44     GraphicsElement(Reader* reader);
45     static GraphicsElement* getElement(QString const& name, Reader* reader);
46     virtual bool setAttribute(QString const& name, QString const& value) = 0;
47     virtual void addToScene(GraphicsScene* scene) = 0;
48     virtual void update() = 0;
49     virtual QGraphicsItem* getElement() const = 0;
50     QString const& getError() const;
51     bool setEffect(QString const& effect);
52     bool setEffectAttribute(QString const& name, QString const& value);
53     void applyEffect();
54
55 protected:
56     int getAttribute(QString const& name, QString const& value, const AttributeDetails details[], int count, int& intValue);
57     void setError(QString const& error);
58     bool readFile(QString const& name, QByteArray& data);
59     bool getFont(QString const& name, QFont& font);
60
61 private:
62     Reader* reader_;
63     QString error_;
64     Effect* effect_;
65     QMap<QString, QString> loadedFonts_;
66 };
67
68 #endif