File indexing completed on 2024-12-22 04:17:46

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #ifndef SVGITEM_H
0014 #define SVGITEM_H
0015 
0016 
0017 #include "viewitem.h"
0018 #include "graphicsfactory.h"
0019 
0020 #include <QSvgRenderer>
0021 
0022 namespace Kst {
0023 
0024 class SvgItem : public ViewItem
0025 {
0026   Q_OBJECT
0027   public:
0028     explicit SvgItem(View *parent, const QString &file = QString());
0029     ~SvgItem();
0030 
0031     const QString defaultsGroupName() const {return QString("picture");}
0032 
0033     // for view item dialogs
0034     virtual bool hasStroke() const {return false;}
0035     virtual bool hasBrush() const {return false;}
0036 
0037     virtual void save(QXmlStreamWriter &xml);
0038     virtual void paint(QPainter *painter);
0039 
0040     void setSvgData(const QByteArray &svgData);
0041     virtual void creationPolygonChanged(View::CreationEvent event);
0042 
0043   private:
0044     QSvgRenderer *_svg;
0045     QByteArray _svgData;
0046 };
0047 
0048 
0049 class CreateSvgCommand : public CreateCommand
0050 {
0051   Q_OBJECT
0052   public:
0053     CreateSvgCommand() : CreateCommand(QObject::tr("Create Svg")) {}
0054     CreateSvgCommand(View *view) : CreateCommand(view, QObject::tr("Create Svg")) {}
0055     ~CreateSvgCommand() {}
0056     void createItem();
0057 };
0058 
0059 class SvgItemFactory : public GraphicsFactory {
0060   public:
0061     SvgItemFactory();
0062     ~SvgItemFactory();
0063     ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
0064 };
0065 
0066 }
0067 
0068 #endif
0069 
0070 // vim: ts=2 sw=2 et