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

KDEUI

Public Member Functions | Static Public Member Functions
KRatingPainter Class Reference

#include <Nepomuk/KRatingPainter>

List of all members.

Public Member Functions

 KRatingPainter ()
 ~KRatingPainter ()
Qt::Alignment alignment () const
QPixmap customPixmap () const
bool halfStepsEnabled () const
QIcon icon () const
bool isEnabled () const
Qt::LayoutDirection layoutDirection () const
int maxRating () const
void paint (QPainter *painter, const QRect &rect, int rating, int hoverRating=-1) const
int ratingFromPosition (const QRect &rect, const QPoint &pos) const
void setAlignment (Qt::Alignment align)
void setCustomPixmap (const QPixmap &pixmap)
void setEnabled (bool enabled)
void setHalfStepsEnabled (bool enabled)
void setIcon (const QIcon &icon)
void setLayoutDirection (Qt::LayoutDirection direction)
void setMaxRating (int max)
void setSpacing (int spacing)
int spacing () const

Static Public Member Functions

static int getRatingFromPosition (const QRect &rect, Qt::Alignment align, Qt::LayoutDirection direction, const QPoint &pos)
static void paintRating (QPainter *p, const QRect &rect, Qt::Alignment align, int rating, int hoverRating=-1)

Detailed Description

Utility class that draws a row of stars for a rating value.

The KRatingPainter also allows to determine a rating value from a position in the draw area. it supports all different alignments and custom icons.

For showing a rating in a widget see KRatingWidget.

Author:
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org
Since:
4.1

Definition at line 50 of file kratingpainter.h.


Constructor & Destructor Documentation

KRatingPainter::KRatingPainter ( )

Create a new KRatingPainter.

For most cases the static methods paintRating and getRatingFromPosition should be sufficient.

Definition at line 75 of file kratingpainter.cpp.

KRatingPainter::~KRatingPainter ( )

Destructor.

Definition at line 81 of file kratingpainter.cpp.


Member Function Documentation

Qt::Alignment KRatingPainter::alignment ( ) const

The alignment of the stars.

See also:
setAlignment

Definition at line 99 of file kratingpainter.cpp.

QPixmap KRatingPainter::customPixmap ( ) const

The custom pixmap set to draw a star.

If no custom pixmap has been set, an invalid pixmap is returned.

See also:
setCustomPixmap

Definition at line 123 of file kratingpainter.cpp.

int KRatingPainter::getRatingFromPosition ( const QRect &  rect,
Qt::Alignment  align,
Qt::LayoutDirection  direction,
const QPoint &  pos 
)
static

Get the rating that would be selected if the user clicked position pos within rect if the rating has been drawn with paintRating() using the same rect and align values.

Returns:
The new rating or -1 if pos is outside of the rating area.

Definition at line 352 of file kratingpainter.cpp.

bool KRatingPainter::halfStepsEnabled ( ) const

If half steps are enabled one star equals to 2 rating points and uneven rating values result in half-stars being drawn.

See also:
setHalfStepsEnabled

Definition at line 93 of file kratingpainter.cpp.

QIcon KRatingPainter::icon ( ) const

The icon used to draw a star.

In case a custom pixmap has been set this value is ignored.

See also:
setIcon, setCustomPixmap

Definition at line 111 of file kratingpainter.cpp.

bool KRatingPainter::isEnabled ( ) const

The rating can be painted in a disabled state where no color is used and hover ratings are ignored.

See also:
setEnabled

Definition at line 117 of file kratingpainter.cpp.

Qt::LayoutDirection KRatingPainter::layoutDirection ( ) const

The layout direction.

If RTL the stars representing the rating value will be drawn from the right.

See also:
setLayoutDirection

Definition at line 105 of file kratingpainter.cpp.

int KRatingPainter::maxRating ( ) const

The maximum rating, i.e.

how many stars are drawn in total.

See also:
setMaxRating

Definition at line 87 of file kratingpainter.cpp.

void KRatingPainter::paint ( QPainter *  painter,
const QRect &  rect,
int  rating,
int  hoverRating = -1 
) const

Draw the rating.

Parameters:
painterThe painter to draw the rating to.
rectThe geometry of the rating. The alignment of the rating is used relative to this value.
ratingThe actual rating value to draw.
hoverRatingThe hover rating indicates the position the user hovers the mouse pointer at. This will provide visual feedback about the new rating if the user would actually click as well as the difference to the current rating.

Definition at line 183 of file kratingpainter.cpp.

void KRatingPainter::paintRating ( QPainter *  p,
const QRect &  rect,
Qt::Alignment  align,
int  rating,
int  hoverRating = -1 
)
static

Convenience method that paints a rating into the given rect.

LayoutDirection is read from QPainter.

Parameters:
aligncan be aligned vertically and horizontally. Using Qt::AlignJustify will insert spacing between the stars.

Definition at line 343 of file kratingpainter.cpp.

int KRatingPainter::ratingFromPosition ( const QRect &  rect,
const QPoint &  pos 
) const

Calculate the rating value from mouse position pos.

Returns:
The rating corresponding to pos or -1 if pos is outside of the configured rect.

Definition at line 288 of file kratingpainter.cpp.

void KRatingPainter::setAlignment ( Qt::Alignment  align)

The alignment of the stars in the drawing rect.

All alignment flags are supported.

Definition at line 147 of file kratingpainter.cpp.

void KRatingPainter::setCustomPixmap ( const QPixmap &  pixmap)

Set a custom pixmap.

Definition at line 171 of file kratingpainter.cpp.

void KRatingPainter::setEnabled ( bool  enabled)

Enable or disable the rating.

Default is enabled.

Definition at line 165 of file kratingpainter.cpp.

void KRatingPainter::setHalfStepsEnabled ( bool  enabled)

If half steps are enabled (the default) then one rating step corresponds to half a star.

Definition at line 141 of file kratingpainter.cpp.

void KRatingPainter::setIcon ( const QIcon &  icon)

Set a custom icon.

Defaults to "rating".

Definition at line 159 of file kratingpainter.cpp.

void KRatingPainter::setLayoutDirection ( Qt::LayoutDirection  direction)

LTR or RTL.

Definition at line 153 of file kratingpainter.cpp.

void KRatingPainter::setMaxRating ( int  max)

The maximum rating.

Defaults to 10.

Definition at line 135 of file kratingpainter.cpp.

void KRatingPainter::setSpacing ( int  spacing)

Set the spacing between rating pixmaps.

Be aware that for justified horizontal alignment this values may be ignored.

Definition at line 177 of file kratingpainter.cpp.

int KRatingPainter::spacing ( ) const

The spacing between rating pixmaps.

See also:
setSpacing

Definition at line 129 of file kratingpainter.cpp.


The documentation for this class was generated from the following files:
  • kratingpainter.h
  • kratingpainter.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 23 2013 21:59:38 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 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