• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • widgets
scrollwidget.h
Go to the documentation of this file.
1/*
2 * Copyright 2009 Marco Martin <notmart@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef PLASMA_SCROLLWIDGET_H
21#define PLASMA_SCROLLWIDGET_H
22
23#include <QtCore/QAbstractAnimation>
24#include <QtGui/QGraphicsWidget>
25
26#include <plasma/plasma_export.h>
27
28
29namespace Plasma
30{
31
32class ScrollWidgetPrivate;
33
43class PLASMA_EXPORT ScrollWidget : public QGraphicsWidget
44{
45 Q_OBJECT
46 Q_PROPERTY(QGraphicsWidget *widget READ widget WRITE setWidget)
47 Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
48 Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
49 Q_PROPERTY(bool overflowBordersVisible READ overflowBordersVisible WRITE setOverflowBordersVisible)
50 Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition)
51 Q_PROPERTY(QSizeF contentsSize READ contentsSize)
52 Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
53 Q_PROPERTY(QSizeF snapSize READ snapSize WRITE setSnapSize)
54 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
55 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
56 Q_PROPERTY(bool overShoot READ hasOverShoot WRITE setOverShoot)
57
58public:
59
65 explicit ScrollWidget(QGraphicsWidget *parent = 0);
66 explicit ScrollWidget(QGraphicsItem *parent);
67 ~ScrollWidget();
68
79 void setWidget(QGraphicsWidget *widget);
80
84 QGraphicsWidget *widget() const;
85
92 void setAlignment(Qt::Alignment align);
93
98 Qt::Alignment alignment() const;
99
106 void setOverShoot(bool enable);
107
112 bool hasOverShoot() const;
113
119 void setHorizontalScrollBarPolicy(const Qt::ScrollBarPolicy policy);
120
124 Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
125
131 void setVerticalScrollBarPolicy(const Qt::ScrollBarPolicy policy);
132
136 Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
137
143 bool overflowBordersVisible() const;
144
152 void setOverflowBordersVisible(const bool visible);
153
160 Q_INVOKABLE void ensureRectVisible(const QRectF &rect);
161
168 Q_INVOKABLE void ensureItemVisible(QGraphicsItem *item);
169
184#ifndef KDE_NO_DEPRECATED
185 KDE_DEPRECATED Q_INVOKABLE void registerAsDragHandle(QGraphicsWidget *item);
186#endif
187
196#ifndef KDE_NO_DEPRECATED
197 KDE_DEPRECATED Q_INVOKABLE void unregisterAsDragHandle(QGraphicsWidget *item);
198#endif
199
204 QRectF viewportGeometry() const;
205
206
211 QSizeF contentsSize() const;
212
217 void setScrollPosition(const QPointF &position);
218
223 QPointF scrollPosition() const;
224
232 void setSnapSize(const QSizeF &size);
233
238 QSizeF snapSize() const;
239
245 void setStyleSheet(const QString &stylesheet);
246
250 QString styleSheet() const;
251
255 QWidget *nativeWidget() const;
256
257Q_SIGNALS:
262 void scrollStateChanged(QAbstractAnimation::State newState,
263 QAbstractAnimation::State oldState);
264
270 void viewportGeometryChanged(const QRectF &geomety);
271
272protected:
273
274 void resizeEvent(QGraphicsSceneResizeEvent *event);
275
276 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
277 void mousePressEvent(QGraphicsSceneMouseEvent *event);
278 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
279 void keyPressEvent(QKeyEvent *event);
280 void wheelEvent(QGraphicsSceneWheelEvent *event);
281 bool eventFilter(QObject *watched, QEvent *event);
282 void focusInEvent(QFocusEvent *event);
283 QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const;
284 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
285
286private:
287 ScrollWidgetPrivate * const d;
288
289 Q_PRIVATE_SLOT(d, void verticalScroll(int value))
290 Q_PRIVATE_SLOT(d, void horizontalScroll(int value))
291 Q_PRIVATE_SLOT(d, void makeRectVisible())
292 Q_PRIVATE_SLOT(d, void makeItemVisible())
293 Q_PRIVATE_SLOT(d, void adjustScrollbars())
294 Q_PRIVATE_SLOT(d, void fixupX())
295 Q_PRIVATE_SLOT(d, void fixupY())
296 Q_PRIVATE_SLOT(d, void setScrollX())
297 Q_PRIVATE_SLOT(d, void setScrollY())
298
299 friend class ScrollWidgetPrivate;
300};
301
302} // namespace Plasma
303
304#endif // multiple inclusion guard
Plasma::ScrollWidget::sizeHint
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
Definition scrollwidget.cpp:1457
Plasma::ScrollWidget::sceneEventFilter
bool sceneEventFilter(QGraphicsItem *i, QEvent *e)
Definition scrollwidget.cpp:1478
Plasma::ScrollWidget::setOverflowBordersVisible
void setOverflowBordersVisible(const bool visible)
Sets whether borders should be shown when the inner widget is bigger than the viewport.
Definition scrollwidget.cpp:1189
Plasma::ScrollWidget::setSnapSize
void setSnapSize(const QSizeF &size)
Set the nap size of the kinetic scrolling: the scrolling will always stop at multiples of that size.
Definition scrollwidget.cpp:1297
Plasma::ScrollWidget::setAlignment
void setAlignment(Qt::Alignment align)
Sets the alignment for the inner widget.
Definition scrollwidget.cpp:1576
Plasma::ScrollWidget::ensureItemVisible
Q_INVOKABLE void ensureItemVisible(QGraphicsItem *item)
Scroll the view until the given item is visible.
Definition scrollwidget.cpp:1209
Plasma::ScrollWidget::keyPressEvent
void keyPressEvent(QKeyEvent *event)
Definition scrollwidget.cpp:1358
Plasma::ScrollWidget::overShoot
bool overShoot
Definition scrollwidget.h:56
Plasma::ScrollWidget::eventFilter
bool eventFilter(QObject *watched, QEvent *event)
Definition scrollwidget.cpp:1415
Plasma::ScrollWidget::setWidget
void setWidget(QGraphicsWidget *widget)
Sets the widget this ScrollWidget will contain ownership is transferred to this scrollwidget,...
Definition scrollwidget.cpp:1129
Plasma::ScrollWidget::snapSize
QSizeF snapSize
Definition scrollwidget.h:53
Plasma::ScrollWidget::setVerticalScrollBarPolicy
void setVerticalScrollBarPolicy(const Qt::ScrollBarPolicy policy)
Sets the vertical scrollbar policy.
Definition scrollwidget.cpp:1174
Plasma::ScrollWidget::contentsSize
QSizeF contentsSize
Definition scrollwidget.h:51
Plasma::ScrollWidget::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition scrollwidget.cpp:1393
Plasma::ScrollWidget::nativeWidget
QWidget * nativeWidget() const
Definition scrollwidget.cpp:1319
Plasma::ScrollWidget::mouseMoveEvent
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition scrollwidget.cpp:1363
Plasma::ScrollWidget::overflowBordersVisible
bool overflowBordersVisible
Definition scrollwidget.h:49
Plasma::ScrollWidget::setHorizontalScrollBarPolicy
void setHorizontalScrollBarPolicy(const Qt::ScrollBarPolicy policy)
Sets the horizontal scrollbar policy.
Definition scrollwidget.cpp:1162
Plasma::ScrollWidget::setStyleSheet
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this ScrollWidget.
Definition scrollwidget.cpp:1307
Plasma::ScrollWidget::ScrollWidget
ScrollWidget(QGraphicsWidget *parent=0)
Constructs a new ScrollWidget.
Definition scrollwidget.cpp:1117
Plasma::ScrollWidget::horizontalScrollBarPolicy
Qt::ScrollBarPolicy horizontalScrollBarPolicy
Definition scrollwidget.h:47
Plasma::ScrollWidget::scrollStateChanged
void scrollStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
The widget started or stopped an animated scroll.
Plasma::ScrollWidget::scrollPosition
QPointF scrollPosition
Definition scrollwidget.h:50
Plasma::ScrollWidget::widget
QGraphicsWidget * widget
Definition scrollwidget.h:46
Plasma::ScrollWidget::ScrollWidgetPrivate
friend class ScrollWidgetPrivate
Definition scrollwidget.h:299
Plasma::ScrollWidget::setOverShoot
void setOverShoot(bool enable)
Tells the scrollwidget whether the widget can scroll a little beyond its boundaries and then automati...
Definition scrollwidget.cpp:1591
Plasma::ScrollWidget::viewportGeometry
QRectF viewportGeometry
Definition scrollwidget.h:52
Plasma::ScrollWidget::verticalScrollBarPolicy
Qt::ScrollBarPolicy verticalScrollBarPolicy
Definition scrollwidget.h:48
Plasma::ScrollWidget::resizeEvent
void resizeEvent(QGraphicsSceneResizeEvent *event)
Definition scrollwidget.cpp:1334
Plasma::ScrollWidget::unregisterAsDragHandle
Q_INVOKABLE void unregisterAsDragHandle(QGraphicsWidget *item)
Unregister the given item as drag handle (if it was registered)
Definition scrollwidget.cpp:1245
Plasma::ScrollWidget::viewportGeometryChanged
void viewportGeometryChanged(const QRectF &geomety)
The viewport geomety changed, for instance due a widget resize.
Plasma::ScrollWidget::wheelEvent
void wheelEvent(QGraphicsSceneWheelEvent *event)
Definition scrollwidget.cpp:1403
Plasma::ScrollWidget::focusInEvent
void focusInEvent(QFocusEvent *event)
Definition scrollwidget.cpp:1324
Plasma::ScrollWidget::ensureRectVisible
Q_INVOKABLE void ensureRectVisible(const QRectF &rect)
Scroll the view until the given rectangle is visible.
Definition scrollwidget.cpp:1199
Plasma::ScrollWidget::hasOverShoot
bool hasOverShoot() const
Definition scrollwidget.cpp:1596
Plasma::ScrollWidget::alignment
Qt::Alignment alignment
Definition scrollwidget.h:55
Plasma::ScrollWidget::styleSheet
QString styleSheet
Definition scrollwidget.h:54
Plasma::ScrollWidget::setScrollPosition
void setScrollPosition(const QPointF &position)
Sets the position of the internal widget relative to this widget.
Definition scrollwidget.cpp:1274
Plasma::ScrollWidget::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition scrollwidget.cpp:1375
Plasma::ScrollWidget::registerAsDragHandle
Q_INVOKABLE void registerAsDragHandle(QGraphicsWidget *item)
Register an item as a drag handle, it means mouse events will pass trough it and will be possible to ...
Definition scrollwidget.cpp:1237
QGraphicsWidget
QObject
QWidget
Plasma
Namespace for everything in libplasma.
Definition abstractdialogmanager.cpp:25
plasma_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal