Thats enough playtime for today. The mp3tunes service can now download the xml list...
[amarok.git] / src / pixmapviewer.cpp
blobca3ac8133ee1f7ddc0d5668422d669e43bcd3d62
1 /***************************************************************************
2 * Copyright (C) 2005 Eyal Lotem <eyal.lotem@gmail.com> *
3 * Copyright (C) 2005 Alexandre Oliveira <aleprj@gmail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20 #include "pixmapviewer.h"
22 #include <KApplication>
24 #include <QDesktopWidget>
25 #include <QMouseEvent>
26 #include <QPainter>
27 #include <QPixmap>
30 PixmapViewer::PixmapViewer(QWidget *widget, const QPixmap &pixmap)
31 : Q3ScrollView(widget, 0, Qt::WNoAutoErase)
32 , m_isDragging(false)
33 , m_pixmap(pixmap)
35 resizeContents( m_pixmap.width(), m_pixmap.height() );
38 void PixmapViewer::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph ) {
39 p->drawPixmap(QPoint(clipx, clipy),
40 m_pixmap,
41 QRect(clipx, clipy, clipw, cliph));
44 void PixmapViewer::contentsMousePressEvent(QMouseEvent *event) {
45 if(Qt::LeftButton == event->button()) {
46 m_currentPos = event->globalPos();
47 m_isDragging = true;
51 void PixmapViewer::contentsMouseReleaseEvent(QMouseEvent *event) {
52 if(Qt::LeftButton == event->button()) {
53 m_currentPos = event->globalPos();
54 m_isDragging = false;
58 void PixmapViewer::contentsMouseMoveEvent(QMouseEvent *event) {
59 if(m_isDragging) {
60 QPoint delta = m_currentPos - event->globalPos();
61 scrollBy(delta.x(), delta.y());
62 m_currentPos = event->globalPos();
66 QSize PixmapViewer::maximalSize() {
67 return m_pixmap.size().boundedTo( KApplication::desktop()->size() ) + size() - viewport()->size();
70 #include "pixmapviewer.moc"