KDEUI
Go to the documentation of this file.
24 #include <QtGui/QPainter>
25 #include <QtGui/QPixmap>
26 #include <QtGui/QKeyEvent>
27 #include <QtGui/QImage>
28 #include <QtGui/QIcon>
30 class KRatingWidget::Private
52 setMouseTracking(
true );
62 #ifndef KDE_NO_DEPRECATED
72 d->ratingPainter.setCustomPixmap( pix );
79 d->ratingPainter.setIcon(
icon );
93 return d->ratingPainter.spacing();
99 return d->ratingPainter.icon();
105 d->ratingPainter.setSpacing( s );
112 return d->ratingPainter.alignment();
118 d->ratingPainter.setAlignment( align );
125 return d->ratingPainter.layoutDirection();
131 d->ratingPainter.setLayoutDirection( direction );
144 return d->ratingPainter.maxRating();
150 return d->ratingPainter.halfStepsEnabled();
154 #ifndef KDE_NO_DEPRECATED
164 if (
rating != d->rating ) {
174 #ifndef KDE_NO_DEPRECATED
184 d->ratingPainter.setMaxRating( max );
191 d->ratingPainter.setHalfStepsEnabled( enabled );
196 #ifndef KDE_NO_DEPRECATED
206 if ( e->button() == Qt::LeftButton ) {
207 const int prevRating = d->rating;
208 d->hoverRating = d->ratingPainter.ratingFromPosition( contentsRect(), e->pos() );
209 if ( !( d->hoverRating % 2 ) ) {
210 if ( d->hoverRating == prevRating + 1 ) {
213 else if ( d->hoverRating == prevRating ) {
221 if ( d->hoverRating == prevRating - 1 ) {
224 else if ( d->hoverRating == prevRating ) {
238 const int prevHoverRating = d->hoverRating;
239 d->hoverRating = d->ratingPainter.ratingFromPosition( contentsRect(), e->pos() );
240 if ( !( d->hoverRating % 2 ) ) {
241 if ( d->hoverRating == prevHoverRating + 1 ) {
244 else if ( d->hoverRating == prevHoverRating ) {
249 if ( d->hoverRating == prevHoverRating ) {
256 if ( d->hoverRating != prevHoverRating ) {
271 QFrame::paintEvent( e );
273 d->ratingPainter.setEnabled( isEnabled() );
274 d->ratingPainter.paint( &p, contentsRect(), d->rating, d->hoverRating );
280 int numPix = d->ratingPainter.maxRating();
281 if( d->ratingPainter.halfStepsEnabled() )
284 QSize pixSize( d->pixSize, d->pixSize );
285 if ( !d->ratingPainter.customPixmap().isNull() ) {
286 pixSize = d->ratingPainter.customPixmap().size();
289 return QSize( pixSize.width()*numPix +
spacing()*(numPix-1) + frameWidth()*2,
290 pixSize.height() + frameWidth()*2 );
296 QFrame::resizeEvent( e );
299 #include "kratingwidget.moc"
Utility class that draws a row of stars for a rating value.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jan 30 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.