1 | /* |
2 | * Copyright (c) 2009 Cyrille Berger <cberger@cberger.net> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; |
7 | * either version 2, or (at your option) any later version of the License. |
8 | * |
9 | * This library 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 GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public License |
15 | * along with this library; see the file COPYING. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "StateShapeFactory.h" |
21 | |
22 | #include "StateShape.h" |
23 | #include <KoProperties.h> |
24 | |
25 | #include <KoIcon.h> |
26 | #include <klocale.h> |
27 | |
28 | |
29 | StateShapeFactory::StateShapeFactory() |
30 | : KoShapeFactoryBase(STATESHAPEID, |
31 | i18n("State Shape" )) |
32 | { |
33 | setToolTip(i18n("A state shape" )); |
34 | setIconName(koIconNameCStr("stateshape" )); |
35 | setXmlElementNames("http://kde.org/braindump" , QStringList("state" )); |
36 | } |
37 | |
38 | KoShape *StateShapeFactory::createDefaultShape(KoDocumentResourceManager */*documentResources*/) const |
39 | { |
40 | StateShape* fooShape = new StateShape(); |
41 | fooShape->setShapeId(STATESHAPEID); |
42 | // set defaults |
43 | return fooShape; |
44 | } |
45 | |
46 | KoShape *StateShapeFactory::createShape(const KoProperties *params, KoDocumentResourceManager */*documentResources*/) const |
47 | { |
48 | Q_UNUSED(params); |
49 | StateShape* fooShape = new StateShape(); |
50 | fooShape->setShapeId(STATESHAPEID); |
51 | if(params->contains("state" )) { |
52 | fooShape->setStateId(params->stringProperty("state" )); |
53 | } |
54 | if(params->contains("category" )) { |
55 | fooShape->setCategoryId(params->stringProperty("category" )); |
56 | } |
57 | // use the params |
58 | return fooShape; |
59 | } |
60 | |
61 | bool StateShapeFactory::supports(const KoXmlElement& e, KoShapeLoadingContext& /*context*/) const |
62 | { |
63 | return (e.localName() == "state" && e.namespaceURI() == "http://kde.org/braindump" ); |
64 | } |
65 | |
66 | QList<KoShapeConfigWidgetBase*> StateShapeFactory::createShapeOptionPanels() |
67 | { |
68 | QList<KoShapeConfigWidgetBase*> answer; |
69 | return answer; |
70 | } |
71 | |