![]() |
Mixxx
|
00001 /*************************************************************************** 00002 stareditor.h 00003 ------------------- 00004 copyright : (C) 2010 Tobias Rafreider 00005 copyright : (C) 2009 Nokia Corporation 00006 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 /*************************************************************************** 00019 * * 00020 * StarEditor inherits QWidget and is used by StarDelegate to let the user * 00021 * edit a star rating in the library using the mouse. * 00022 * * 00023 * The class has been adapted from the official "Star Delegate Example", * 00024 * see http://doc.trolltech.com/4.5/itemviews-stardelegate.html * 00025 ***************************************************************************/ 00026 00027 #ifndef STAREDITOR_H 00028 #define STAREDITOR_H 00029 00030 #include <QWidget> 00031 00032 #include "starrating.h" 00033 00034 class StarEditor : public QWidget 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 StarEditor(QWidget *parent, const QStyleOptionViewItem& option); 00040 00041 QSize sizeHint() const; 00042 void setStarRating(const StarRating &starRating) { 00043 m_starRating = starRating; 00044 } 00045 StarRating starRating() { return m_starRating; } 00046 00047 signals: 00048 void editingFinished(); 00049 00050 protected: 00051 void paintEvent(QPaintEvent *event); 00052 void mouseMoveEvent(QMouseEvent *event); 00053 void mouseReleaseEvent(QMouseEvent *event); 00054 00055 private: 00056 int starAtPosition(int x); 00057 00058 StarRating m_starRating; 00059 }; 00060 00061 #endif