File indexing completed on 2024-05-12 05:09:49
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef TELLICO_RATINGWIDGET_H 0026 #define TELLICO_RATINGWIDGET_H 0027 0028 #include "../datavectors.h" 0029 0030 #include <QList> 0031 #include <QLabel> 0032 #include <QPixmap> 0033 0034 class QToolButton; 0035 class QSpacerItem; 0036 0037 namespace Tellico { 0038 namespace Data { 0039 class Field; 0040 } 0041 namespace GUI { 0042 0043 /** 0044 * @author Robby Stephenson 0045 */ 0046 class RatingWidget : public QWidget { 0047 Q_OBJECT 0048 0049 typedef QList<QLabel*> LabelList; 0050 0051 public: 0052 RatingWidget(Data::FieldPtr field, QWidget* parent); 0053 0054 void clear(); 0055 QString text() const; 0056 void setText(const QString& text); 0057 void updateField(Data::FieldPtr field); 0058 0059 public Q_SLOTS: 0060 void update(); 0061 0062 Q_SIGNALS: 0063 void signalModified(); 0064 0065 protected: 0066 virtual void mousePressEvent(QMouseEvent* e) Q_DECL_OVERRIDE; 0067 virtual void enterEvent(QEvent* e) Q_DECL_OVERRIDE; 0068 virtual void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; 0069 0070 private Q_SLOTS: 0071 void clearClicked(); 0072 0073 private: 0074 void init(); 0075 void updateBounds(); 0076 0077 Data::FieldPtr m_field; 0078 LabelList m_widgets; 0079 QToolButton* m_clearButton; 0080 QSpacerItem* m_clearSpacer; 0081 0082 int m_currIndex; 0083 int m_total; 0084 int m_min; 0085 int m_max; 0086 0087 QPixmap m_pixOn; 0088 QPixmap m_pixOff; 0089 }; 0090 0091 } // end GUI namespace 0092 } // end namespace 0093 #endif