2
* Copyright 2009 by Sebastian Kügler <sebas@kde.org>
3
* Copyright 2009 by Richard Moore <rich@kde.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Library General Public License as
7
* published by the Free Software Foundation; either version 2, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details
15
* You should have received a copy of the GNU Library General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include "kwebslice.h"
22
#include "kgraphicswebslice.h"
26
struct KWebSlicePrivate
28
KGraphicsWebSlice *slice;
32
KWebSlice::KWebSlice( QWidget *parent )
33
: QGraphicsView( parent )
35
d = new KWebSlicePrivate;
36
d->slice = new KGraphicsWebSlice;
37
connect(d->slice, SIGNAL(sizeChanged(QSizeF)), this, SLOT(sizeChanged(QSizeF)));
39
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
40
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
42
QGraphicsScene *qgs = new QGraphicsScene(this);
43
qgs->addItem(d->slice);
44
qgs->setActiveWindow(d->slice);
47
setMinimumSize(20,20);
48
//setPreferedSize(20,80);
51
KWebSlice::~KWebSlice()
56
void KWebSlice::setUrl( const QUrl &url )
58
d->slice->setUrl( url );
61
void KWebSlice::setLoadingText(const QString &html)
63
d->slice->setLoadingText(html);
66
void KWebSlice::setElement( const QString &selector )
68
d->slice->setElement(selector);
71
void KWebSlice::sizeChanged(QSizeF newsize)
73
//qDebug() << "size changed" << newsize;
74
QRectF newgeometry = QRectF(QPointF(0, 0), newsize);
75
setSceneRect(newgeometry);
76
resize(newgeometry.toRect().size());
79
QSize KWebSlice::sizeHint () const
81
return sceneRect().size().toSize();
84
void KWebSlice::resizeEvent ( QResizeEvent * event )
86
QRectF newgeometry = QRectF(QPointF(0, 0), event->size());
87
//qDebug() << "KWebSlice::resizeEvent" << newgeometry << "(" << event->oldSize() << ")";
88
setSceneRect(newgeometry);
89
d->slice->setGeometry(newgeometry);