~neon/kdeplasma-addons/trunk

« back to all changes in this revision

Viewing changes to applets/webslice/kwebslice.cpp

  • Committer: asouza
  • Date: 2011-02-01 19:41:58 UTC
  • Revision ID: svn-v4:283d02a7-25f6-0310-bc7c-ecb5cbfe19da:trunk/KDE/kdeplasma-addons:1218275
Move kdeplasma-addons to git

- You can find information about the project in the link below:

https://projects.kde.org/projects/kde/kdeplasma-addons/repository

- And you can clone the repository using:

git clone git://anongit.kde.org/kdeplasma-addons


Thanks eean and all the sysadmins for the help.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright 2009 by Sebastian Kügler <sebas@kde.org>
3
 
 *   Copyright 2009 by Richard Moore <rich@kde.org>
4
 
 
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.
9
 
 *
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
14
 
 *
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.
19
 
 */
20
 
 
21
 
#include "kwebslice.h"
22
 
#include "kgraphicswebslice.h"
23
 
 
24
 
#include <qdebug.h>
25
 
 
26
 
struct KWebSlicePrivate
27
 
{
28
 
    KGraphicsWebSlice *slice;
29
 
    QString selector;
30
 
};
31
 
 
32
 
KWebSlice::KWebSlice( QWidget *parent )
33
 
    : QGraphicsView( parent )
34
 
{
35
 
    d = new KWebSlicePrivate;
36
 
    d->slice = new KGraphicsWebSlice;
37
 
    connect(d->slice, SIGNAL(sizeChanged(QSizeF)), this, SLOT(sizeChanged(QSizeF)));
38
 
 
39
 
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
40
 
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
41
 
 
42
 
    QGraphicsScene *qgs = new QGraphicsScene(this);
43
 
    qgs->addItem(d->slice);
44
 
    qgs->setActiveWindow(d->slice);
45
 
    setScene(qgs);
46
 
 
47
 
    setMinimumSize(20,20);
48
 
    //setPreferedSize(20,80);
49
 
}
50
 
 
51
 
KWebSlice::~KWebSlice()
52
 
{
53
 
    delete d;
54
 
}
55
 
 
56
 
void KWebSlice::setUrl( const QUrl &url )
57
 
{
58
 
    d->slice->setUrl( url );
59
 
}
60
 
 
61
 
void KWebSlice::setLoadingText(const QString &html)
62
 
{
63
 
    d->slice->setLoadingText(html);
64
 
}
65
 
 
66
 
void KWebSlice::setElement( const QString &selector )
67
 
{
68
 
    d->slice->setElement(selector);
69
 
}
70
 
 
71
 
void KWebSlice::sizeChanged(QSizeF newsize)
72
 
{
73
 
    //qDebug() << "size changed" << newsize;
74
 
    QRectF newgeometry = QRectF(QPointF(0, 0), newsize);
75
 
    setSceneRect(newgeometry);
76
 
    resize(newgeometry.toRect().size());
77
 
}
78
 
 
79
 
QSize KWebSlice::sizeHint () const
80
 
{
81
 
    return sceneRect().size().toSize();
82
 
}
83
 
 
84
 
void KWebSlice::resizeEvent ( QResizeEvent * event )
85
 
{
86
 
    QRectF newgeometry = QRectF(QPointF(0, 0), event->size());
87
 
    //qDebug() << "KWebSlice::resizeEvent" << newgeometry << "(" << event->oldSize() << ")";
88
 
    setSceneRect(newgeometry);
89
 
    d->slice->setGeometry(newgeometry);
90
 
}