From adaed62351ab9d217143ab277d55ca16c21ddb35 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 15 Dec 2008 20:34:03 +0000 Subject: [PATCH] * forward the valueChanged signal * simplify the ctor to be more in line with the other widgets * add setOrientation combined, this elminates the need pretty much everywhere its used for nativeWidget() to be accessed. woo! svn path=/trunk/KDE/kdelibs/; revision=897341 --- widgets/scrollbar.cpp | 14 ++++++++++---- widgets/scrollbar.h | 30 +++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/widgets/scrollbar.cpp b/widgets/scrollbar.cpp index b1dd0697d..8d9c4600f 100644 --- a/widgets/scrollbar.cpp +++ b/widgets/scrollbar.cpp @@ -31,17 +31,18 @@ public: Plasma::Style *style; }; -ScrollBar::ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent) - : QGraphicsProxyWidget(parent), - d(new ScrollBarPrivate) +ScrollBar::ScrollBar(QGraphicsWidget *parent) + : QGraphicsProxyWidget(parent), + d(new ScrollBarPrivate) { - QScrollBar *scrollbar = new QScrollBar(orientation); + QScrollBar *scrollbar = new QScrollBar(); scrollbar->setAttribute(Qt::WA_NoSystemBackground); setWidget(scrollbar); d->style = new Plasma::Style(); scrollbar->setStyle(d->style); scrollbar->resize(scrollbar->sizeHint()); + connect(scrollbar, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); } ScrollBar::~ScrollBar() @@ -111,6 +112,11 @@ QScrollBar *ScrollBar::nativeWidget() const return static_cast(widget()); } +void ScrollBar::setOrientation(Qt::Orientation orientation) +{ + static_cast(widget())->setOrientation(orientation); +} + } #include diff --git a/widgets/scrollbar.h b/widgets/scrollbar.h index 2c31b3c8a..b7a3a62d4 100644 --- a/widgets/scrollbar.h +++ b/widgets/scrollbar.h @@ -49,7 +49,11 @@ class PLASMA_EXPORT ScrollBar : public QGraphicsProxyWidget Q_PROPERTY(QScrollBar *nativeWidget READ nativeWidget) public: - explicit ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent); + /** + * Creates a scrollbar; the default orientation is vertical + */ + explicit ScrollBar(QGraphicsWidget *parent); + ~ScrollBar(); /** @@ -82,12 +86,6 @@ public: */ int pageStep(); - /** - * Sets the current value for the ScrollBar - * @arg value must be minimum() <= value <= maximum() - */ - void setValue(int val); - /** * @return the current scrollbar value */ @@ -120,6 +118,24 @@ public: */ QScrollBar *nativeWidget() const; +public Q_SLOTS: + /** + * Sets the current value for the ScrollBar + * @arg value must be minimum() <= value <= maximum() + */ + void setValue(int val); + + /** + * Sets the orientation of the ScrollBar. + */ + void setOrientation(Qt::Orientation orientation); + +Q_SIGNALS: + /** + * Emitted when the value of the slider changes + */ + void valueChanged(int value); + private: ScrollBarPrivate * const d; };