1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2007 Boudewijn Rempt <boud@kde.org>
4  * Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
5  * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #include "KoConnectionShapeFactory.h"
24 
25 #include "KoConnectionShape.h"
26 #include "KoConnectionShapeConfigWidget.h"
27 
28 #include <KoXmlNS.h>
29 #include <KoIcon.h>
30 #include <klocalizedstring.h>
31 #include <KoShapeStroke.h>
32 #include <KoShapeLoadingContext.h>
33 
KoConnectionShapeFactory()34 KoConnectionShapeFactory::KoConnectionShapeFactory()
35         : KoShapeFactoryBase(KOCONNECTIONSHAPEID, i18n("Tie"))
36 {
37     setToolTip(i18n("A connection between two other shapes"));
38     setIconName(koIconName("x-shape-connection"));
39     setXmlElementNames(KoXmlNS::draw, QStringList("connector"));
40     setLoadingPriority(1);
41     setHidden(true); // Don't show this shape in collections. Only ConnectionTool should create
42 }
43 
createDefaultShape(KoDocumentResourceManager *) const44 KoShape* KoConnectionShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
45 {
46     KoConnectionShape * shape = new KoConnectionShape();
47     shape->setStroke(new KoShapeStroke());
48     shape->setShapeId(KoPathShapeId);
49     return shape;
50 }
51 
supports(const KoXmlElement & e,KoShapeLoadingContext & context) const52 bool KoConnectionShapeFactory::supports(const KoXmlElement & e, KoShapeLoadingContext &context) const
53 {
54     Q_UNUSED(context);
55     return (e.localName() == "connector" && e.namespaceURI() == KoXmlNS::draw);
56 }
57 
createShapeOptionPanels()58 QList<KoShapeConfigWidgetBase*> KoConnectionShapeFactory::createShapeOptionPanels()
59 {
60     QList<KoShapeConfigWidgetBase*> panels;
61     panels.append(new KoConnectionShapeConfigWidget());
62     return panels;
63 }
64