~ubuntu-branches/ubuntu/lucid/amarok/lucid-backports

« back to all changes in this revision

Viewing changes to src/context/widgets/RatingWidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2011-03-03 10:27:39 UTC
  • mfrom: (114.1.20 natty)
  • Revision ID: james.westby@ubuntu.com-20110303102739-ar67wpa6mllo59n2
Tags: 2:2.4.0-0ubuntu4~lucid1
* Source backport to lucid (LP: #728447)
  - Drop version requirement on libindicate-qt-dev build-dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************************
2
 
 * Copyright (c) 2008 William Viana Soares <vianasw@gmail.com>                          *
 
2
 * Copyright (c) 2008 William Viana Soarjs <vianasw@gmail.com>                          *
 
3
 * Copyright (c) 2010 Mark Kretschmann <kretschmann@kde.org>                            *
3
4
 *                                                                                      *
4
5
 * This program is free software; you can redistribute it and/or modify it under        *
5
6
 * the terms of the GNU General Public License as published by the Free Software        *
21
22
 
22
23
#include "RatingWidget.h"
23
24
 
24
 
#include "Debug.h"
 
25
#include "core/support/Debug.h"
25
26
 
26
27
#include "kratingpainter.h"
27
28
 
38
39
#include <klocale.h>
39
40
#include <kstandarddirs.h>
40
41
 
 
42
using namespace Amarok;
 
43
 
41
44
class RatingWidget::Private
42
45
{
43
46
public:
61
64
RatingWidget::RatingWidget( QGraphicsItem* parent )
62
65
    : QGraphicsWidget( parent )
63
66
    , d( new Private() )
 
67
    , m_startupUpdates( 2 )
64
68
{
65
69
    setAcceptHoverEvents( true );
66
 
    setToolTip( i18n( "Track rating: %1", d->rating ) );
 
70
    setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) );
67
71
}
68
72
 
69
73
 
214
218
        if ( ratingFromPos >= 0 )
215
219
        {
216
220
            d->hoverRating = d->rating = ratingFromPos;
217
 
            setToolTip( i18n( "Track rating: %1", d->rating ) );
 
221
            setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) );
218
222
            update();
219
223
            emit ratingChanged( d->rating );
220
224
        }
240
244
                    contentsRect().width(), contentsRect().height() );
241
245
    d->hoverRating = d->ratingPainter.ratingFromPosition( rect, QPoint( e->pos().x(), e->pos().y() ) );
242
246
 
243
 
    setToolTip( i18n( "Track rating: %1", d->rating ) );
 
247
    setToolTip( i18n( "Track rating: %1", (float)d->rating / 2 ) );
244
248
 
245
249
    update();
246
250
}
265
269
                    contentsRect().width(), contentsRect().height() );
266
270
        d->ratingPainter.paint( painter, rect, d->rating, d->hoverRating );
267
271
    }
 
272
 
 
273
    // HACK: (this works fine, but if a better fix is found, we should replace it)
 
274
    // Make sure that the the parent item updates itself correctly on startup.
 
275
    // We use a counter variable to prevent infinite recursion.
 
276
    if( m_startupUpdates )
 
277
    {
 
278
        parentItem()->update();
 
279
        m_startupUpdates--;
 
280
    }
268
281
}
269
282
 
270
283
QSizeF
285
298
                  pixSize.height() + contentsRect().width() );
286
299
}
287
300
 
288
 
 
289
 
// void
290
 
// RatingWidget::resizeEvent( QGraphicsSceneResizeEvent* e )
291
 
// {
292
 
//     DEBUG_BLOCK
293
 
// 
294
 
// //     QFrame::resizeEvent( e );
295
 
// 
296
 
//     // FIXME: Disabled because this causes infinite recursion
297
 
//     //updateGeometry();
298
 
// }
299
 
 
300
301
#include "RatingWidget.moc"
301
302