Commit 3e831420 authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

Use QGraphicsView instead of QSvgWidget. This way we get scrolling and image

ratio is kept.

svn path=/trunk/playground/graphics/svgpart/; revision=737273
parent 0488145b
......@@ -19,7 +19,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "svgpart.moc"
// Qt
#include <QSvgWidget>
#include <QGraphicsScene>
#include <QGraphicsSvgItem>
#include <QGraphicsView>
#include <QSvgRenderer>
// KDE
#include <kparts/genericfactory.h>
......@@ -34,14 +37,19 @@ K_EXPORT_COMPONENT_FACTORY( svgpart /*library name*/, SvgPartFactory )
SvgPart::SvgPart(QWidget* parentWidget, QObject* parent, const QStringList&)
: KParts::ReadOnlyPart(parent)
{
mSvgWidget = new QSvgWidget(parentWidget);
setWidget(mSvgWidget);
mScene = new QGraphicsScene(this);
mView = new QGraphicsView(mScene, parentWidget);
mView->setDragMode(QGraphicsView::ScrollHandDrag);
mItem = 0;
setWidget(mView);
setXMLFile("svgpart/svgpart.rc");
}
bool SvgPart::openFile() {
mSvgWidget->load(localFilePath());
delete mItem;
mItem = new QGraphicsSvgItem(localFilePath());
mScene->addItem(mItem);
return true;
}
......
......@@ -24,7 +24,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class KAboutData;
class QSvgWidget;
class QGraphicsScene;
class QGraphicsSvgItem;
class QGraphicsView;
class SvgPart : public KParts::ReadOnlyPart {
Q_OBJECT
......@@ -37,7 +39,9 @@ protected:
virtual bool openFile();
private:
QSvgWidget* mSvgWidget;
QGraphicsScene* mScene;
QGraphicsView* mView;
QGraphicsSvgItem* mItem;
};
#endif /* SVGPART_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment