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

KDEUI

  • kdeui
  • widgets
kratingpainter.h
Go to the documentation of this file.
1/*
2 This file is part of the Nepomuk KDE project.
3 Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */
20
21#ifndef _NEPOMUK_RATING_PAINTER_H_
22#define _NEPOMUK_RATING_PAINTER_H_
23
24#include <kdeui_export.h>
25
26#include <QtCore/Qt>
27
28class QIcon;
29class QPixmap;
30class QPainter;
31class QPoint;
32class QRect;
33
34
50class KDEUI_EXPORT KRatingPainter
51{
52public:
58 KRatingPainter();
59
63 ~KRatingPainter();
64
71 int maxRating() const;
72
80 bool halfStepsEnabled() const;
81
87 Qt::Alignment alignment() const;
88
96 Qt::LayoutDirection layoutDirection() const;
97
104 QIcon icon() const;
105
112 bool isEnabled() const;
113
120 QPixmap customPixmap() const;
121
127 int spacing() const;
128
132 void setMaxRating( int max );
133
138 void setHalfStepsEnabled( bool enabled );
139
144 void setAlignment( Qt::Alignment align );
145
149 void setLayoutDirection( Qt::LayoutDirection direction );
150
154 void setIcon( const QIcon& icon );
155
159 void setEnabled( bool enabled );
160
164 void setCustomPixmap( const QPixmap& pixmap );
165
171 void setSpacing( int spacing );
172
185 void paint( QPainter* painter, const QRect& rect, int rating, int hoverRating = -1 ) const;
186
193 int ratingFromPosition( const QRect& rect, const QPoint& pos ) const;
194
203 static void paintRating( QPainter* p, const QRect& rect, Qt::Alignment align, int rating, int hoverRating = -1 );
204
212 static int getRatingFromPosition( const QRect& rect, Qt::Alignment align, Qt::LayoutDirection direction, const QPoint& pos );
213
214private:
215 class Private;
216 Private* const d;
217};
218
219#endif
KRatingPainter::maxRating
int maxRating() const
The maximum rating, i.e.
Definition kratingpainter.cpp:87
KRatingPainter::alignment
Qt::Alignment alignment() const
The alignment of the stars.
Definition kratingpainter.cpp:99
KRatingPainter::setMaxRating
void setMaxRating(int max)
The maximum rating.
Definition kratingpainter.cpp:135
KRatingPainter::setEnabled
void setEnabled(bool enabled)
Enable or disable the rating.
Definition kratingpainter.cpp:165
KRatingPainter::paintRating
static void paintRating(QPainter *p, const QRect &rect, Qt::Alignment align, int rating, int hoverRating=-1)
Convenience method that paints a rating into the given rect.
Definition kratingpainter.cpp:343
KRatingPainter::setCustomPixmap
void setCustomPixmap(const QPixmap &pixmap)
Set a custom pixmap.
Definition kratingpainter.cpp:171
KRatingPainter::ratingFromPosition
int ratingFromPosition(const QRect &rect, const QPoint &pos) const
Calculate the rating value from mouse position pos.
Definition kratingpainter.cpp:288
KRatingPainter::icon
QIcon icon() const
The icon used to draw a star.
Definition kratingpainter.cpp:111
KRatingPainter::setAlignment
void setAlignment(Qt::Alignment align)
The alignment of the stars in the drawing rect.
Definition kratingpainter.cpp:147
KRatingPainter::spacing
int spacing() const
The spacing between rating pixmaps.
Definition kratingpainter.cpp:129
KRatingPainter::layoutDirection
Qt::LayoutDirection layoutDirection() const
The layout direction.
Definition kratingpainter.cpp:105
KRatingPainter::setLayoutDirection
void setLayoutDirection(Qt::LayoutDirection direction)
LTR or RTL.
Definition kratingpainter.cpp:153
KRatingPainter::KRatingPainter
KRatingPainter()
Create a new KRatingPainter.
Definition kratingpainter.cpp:75
KRatingPainter::halfStepsEnabled
bool halfStepsEnabled() const
If half steps are enabled one star equals to 2 rating points and uneven rating values result in half-...
Definition kratingpainter.cpp:93
KRatingPainter::isEnabled
bool isEnabled() const
The rating can be painted in a disabled state where no color is used and hover ratings are ignored.
Definition kratingpainter.cpp:117
KRatingPainter::setSpacing
void setSpacing(int spacing)
Set the spacing between rating pixmaps.
Definition kratingpainter.cpp:177
KRatingPainter::getRatingFromPosition
static int getRatingFromPosition(const QRect &rect, Qt::Alignment align, Qt::LayoutDirection direction, const QPoint &pos)
Get the rating that would be selected if the user clicked position pos within rect if the rating has ...
Definition kratingpainter.cpp:352
KRatingPainter::setHalfStepsEnabled
void setHalfStepsEnabled(bool enabled)
If half steps are enabled (the default) then one rating step corresponds to half a star.
Definition kratingpainter.cpp:141
KRatingPainter::customPixmap
QPixmap customPixmap() const
The custom pixmap set to draw a star.
Definition kratingpainter.cpp:123
KRatingPainter::paint
void paint(QPainter *painter, const QRect &rect, int rating, int hoverRating=-1) const
Draw the rating.
Definition kratingpainter.cpp:183
KRatingPainter::setIcon
void setIcon(const QIcon &icon)
Set a custom icon.
Definition kratingpainter.cpp:159
kdeui_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 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
  • 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