~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/progressframe.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-31 09:49:54 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071231094954-ix1amvcsj9pk61ya
Tags: 1:1.4.1.57486.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #180254), remaining changes:
  - debian/rules;
    - Added dh_icons
  - Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 *   You should have received a copy of the GNU General Public License     *
17
17
 *   along with this program; if not, write to the                         *
18
18
 *   Free Software Foundation, Inc.,                                       *
19
 
 *   51 Franklin Steet, Fifth Floor, Boston, MA  02111-1307, USA.          *
 
19
 *   51 Franklin Steet, Fifth Floor, Boston, MA  02110-1301, USA.          *
20
20
 ***************************************************************************/
21
21
 
22
22
#include "progressframe.h"
 
23
 
23
24
#include <QPainter>
 
25
#include <QPaintEvent>
 
26
 
24
27
 
25
28
ProgressFrame::ProgressFrame( QWidget *parent ) :
26
29
    QFrame( parent ),
 
30
    m_itemType( 0 ),
27
31
    m_progressEnabled( false ),
28
32
    m_clockEnabled( false ),
29
33
    m_reverse( false ),
30
 
    m_itemType( 0 ),
31
34
    m_watch( NULL ),
32
35
    m_value( 0 )
33
36
{
48
51
{
49
52
    setText( "" );
50
53
    setClockText( "" );
 
54
    setEnabled( false );
 
55
    setValue( 0 );
51
56
}
52
57
 
53
58
 
167
172
    rect.adjust( 8, 0, -8, 0 );
168
173
 
169
174
    QPainter painter( this );
 
175
 
170
176
    drawFrame( &painter );
171
 
 
172
 
    int progressWidth = paintProgressBar( &painter, m_foregroundGradient );
173
 
 
174
 
    paintBackground( &painter, progressWidth, m_backgroundGradient );
175
 
    
 
177
    paintGradients( &painter );
176
178
    paintIcon( &painter, rect, icon() );
177
 
    
 
179
 
178
180
    QRect clockRect = paintClock( &painter, rect );
179
 
 
180
181
    paintText( &painter, rect, clockRect );
181
182
}
182
183
 
183
184
 
 
185
void
 
186
ProgressFrame::paintGradients( QPainter* painter, bool progressBar )
 
187
{
 
188
    int progressWidth = 0;
 
189
 
 
190
    if ( progressBar )
 
191
        progressWidth = paintProgressBar( painter, m_foregroundGradient );
 
192
 
 
193
    paintBackground( painter, progressWidth, m_backgroundGradient );
 
194
}
 
195
 
 
196
 
184
197
int
185
198
ProgressFrame::paintProgressBar( QPainter* painter, const QLinearGradient& grad )
186
199
{
197
210
        QRect r( 1, 1, w, height() - 2 );
198
211
        painter->fillRect( r, grad );
199
212
    }
 
213
 
200
214
    return w;
201
215
}
202
216
 
208
222
    painter->fillRect( r, grad );
209
223
}
210
224
 
 
225
 
211
226
void
212
227
ProgressFrame::paintIcon( QPainter* painter, QRect rect, const QPixmap& icon )
213
228
{
247
262
        timeString = secondsToTimeString( time );
248
263
    }
249
264
 
250
 
    painter->drawText( rect, Qt::AlignRight | Qt::AlignVCenter, timeString );
 
265
    QRectF boundingRect;
 
266
    painter->drawText( rect, Qt::AlignRight | Qt::AlignVCenter, timeString, &boundingRect );
251
267
 
252
 
    return painter->fontMetrics().boundingRect( timeString );
 
268
    return boundingRect.toRect();
253
269
}
254
270
 
255
271
 
300
316
        QMimeData *mimeData = new QMimeData();
301
317
        mimeData->setData( "item/type", QByteArray::number( m_itemType ) );
302
318
 
303
 
        QHash<QString, QString> data = itemData();
 
319
        QMap<QString, QString> data = itemData();
304
320
        if ( data.count() )
305
321
        {
306
322
            for ( int i = 0; i < data.count(); i++ )
332
348
        drag->setPixmap( pixmap );
333
349
 
334
350
        Qt::DropAction dropAction = drag->start( Qt::CopyAction );
335
 
        
 
351
 
336
352
        Q_UNUSED( dropAction )
337
353
    }
338
354
}