mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
2f4d6bbe53
For the stars on the dive table I had to rework a bit my StarRating widget, because it used a pixmap for each widget that were created. Not it uses only 2 pixmaps: the active and inactive ones. A new file was created named modeldelegates(h, cpp) that should hold all delegates of the models. For the GTK / C folks, a 'Delegate' ia s way to bypass the default behavior of the view that's displaying the data. I also added the code to display the stars if no delegate is set ( good for debugging. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
37 lines
723 B
C++
37 lines
723 B
C++
#ifndef STARWIDGET_H
|
|
#define STARWIDGET_H
|
|
|
|
#include <QWidget>
|
|
|
|
enum StarConfig {SPACING = 2, IMG_SIZE = 16, TOTALSTARS = 5};
|
|
|
|
class StarWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit StarWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
|
int currentStars() const;
|
|
|
|
/*reimp*/ QSize sizeHint() const;
|
|
|
|
static QPixmap starActive();
|
|
static QPixmap starInactive();
|
|
|
|
Q_SIGNALS:
|
|
void valueChanged(int stars);
|
|
|
|
public Q_SLOTS:
|
|
void setCurrentStars(int value);
|
|
|
|
protected:
|
|
/*reimp*/ void mouseReleaseEvent(QMouseEvent* );
|
|
/*reimp*/ void paintEvent(QPaintEvent* );
|
|
|
|
private:
|
|
int current;
|
|
static QPixmap* activeStar;
|
|
static QPixmap* inactiveStar;
|
|
QPixmap grayImage(QPixmap *coloredImg);
|
|
};
|
|
|
|
#endif // STARWIDGET_H
|