Added POI text field. Some tuning to detail screen item position.
[jspeed] / src / effect.cpp
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 #include <QtCore/QString>
20 #include <QtGui/QGraphicsItem>
21 #include "effect.h"
22 #include "dropshadoweffect.h"
23 #include "blureffect.h"
24 #include "opacityeffect.h"
25 #include "flickereffect.h"
26
27
28 Effect::Effect()
29 {
30 }
31
32 Effect* Effect::getEffect(QString const& name)
33 {
34    if(name == "dropshadow")
35    {
36        return new DropshadowEffect;
37    }
38    else if(name == "blur")
39    {
40        return new BlurEffect;
41    }
42    else if(name == "opacity")
43    {
44        return new OpacityEffect;
45    }
46    else if(name == "flicker")
47    {
48        return new FlickerEffect;
49    }
50
51    return 0;
52 }
53
54 int Effect::getAttribute(QString const& name,
55                          QString const& value,
56                          const Effect::AttributeDetails details[],
57                          int count,
58                          qreal& realValue)
59 {
60     QString lower = name.toLower();
61
62     for(int i = 0; i < count; i++)
63     {
64         if(details[i].name == lower)
65         {
66             if(!details[i].isQreal)
67             {
68                 return i;
69             }
70             else
71             {
72                 bool ok = true;
73                 double tmp = value.toDouble(&ok);
74
75                 if(ok)
76                 {
77                     realValue = static_cast<qreal>(tmp);
78                     return i;
79                 }
80                 else
81                 {
82                     return -1;
83                 }
84             }
85         }
86     }
87
88     return -1;
89 }
90