KoConnectionShapeFactory.cpp 2.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/* This file is part of the KDE project
 *
 * Copyright (C) 2007 Boudewijn Rempt <boud@kde.org>
 * Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
 * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include "KoConnectionShapeFactory.h"

#include "KoConnectionShape.h"
#include "KoConnectionShapeConfigWidget.h"

#include <KoXmlNS.h>
Friedrich W. H. Kossebau's avatar
Friedrich W. H. Kossebau committed
29
#include <KoIcon.h>
30
#include <klocalizedstring.h>
31
#include <KoShapeStroke.h>
32
#include <KoShapeLoadingContext.h>
33

34 35
#include "kis_global.h"

36 37
KoConnectionShapeFactory::KoConnectionShapeFactory()
        : KoShapeFactoryBase(KOCONNECTIONSHAPEID, i18n("Tie"))
38
{
39
    setToolTip(i18n("A connection between two other shapes"));
Friedrich W. H. Kossebau's avatar
Friedrich W. H. Kossebau committed
40
    setIconName(koIconNameCStr("x-shape-connection"));
41
    setXmlElementNames(KoXmlNS::draw, QStringList("connector"));
42
    setLoadingPriority(1);
43
    setHidden(true); // Don't show this shape in collections. Only ConnectionTool should create
44 45
}

46
KoShape* KoConnectionShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
47 48
{
    KoConnectionShape * shape = new KoConnectionShape();
49
    shape->setStroke(toQShared(new KoShapeStroke()));
50
    shape->setShapeId(KoPathShapeId);
51 52 53
    return shape;
}

54
bool KoConnectionShapeFactory::supports(const KoXmlElement & e, KoShapeLoadingContext &context) const
55
{
Halla Rempt's avatar
Halla Rempt committed
56
    Q_UNUSED(context);
57
    return (e.localName() == "connector" && e.namespaceURI() == KoXmlNS::draw);
58 59 60 61 62
}

QList<KoShapeConfigWidgetBase*> KoConnectionShapeFactory::createShapeOptionPanels()
{
    QList<KoShapeConfigWidgetBase*> panels;
63
    panels.append(new KoConnectionShapeConfigWidget());
64 65
    return panels;
}