File indexing completed on 2024-06-16 04:38:06

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad*
0003  *   bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef FRAMETHUMBVIEW_H
0021 #define FRAMETHUMBVIEW_H
0022 
0023 #include <QPoint>
0024 #include <QString>
0025 
0026 #include "thumbview.h"
0027 
0028 class FrameBar;
0029 class QMouseEvent;
0030 class QDropEvent;
0031 class QPaintEvent;
0032 class QWidget;
0033 
0034 /**
0035  * Widget representing a frame in the animation.
0036  * 
0037  * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
0038  */
0039 class FrameThumbView : public ThumbView {
0040     Q_OBJECT
0041 public:
0042     /**
0043      * Creates and sets up the framethumbview.
0044      * @param frameBar the framebar for communicating with it.
0045      * @param parent the parent widget.
0046      * @param number the number of this widget in the framebar.
0047      */
0048     FrameThumbView(FrameBar *frameBar, QWidget *parent = 0, int number = 0, const char *name = 0);
0049     
0050     /**
0051      * Cleans up after the widget.
0052      */
0053     ~FrameThumbView();
0054     
0055     /**
0056      * Overloaded event function to receive mousepress-events.
0057      * @param e information about the mousepress-event.
0058      */
0059     void mousePressEvent( QMouseEvent * e );
0060     
0061     /**
0062      * Overloaded event function to receive mouserelease-events.
0063      * @param e information about the mouserelease-event.
0064      */
0065     void mouseReleaseEvent( QMouseEvent * e );
0066     
0067     /**
0068      * Overloaded event function to receive mouseMoveEvents.
0069      * @param me information about the mouseMoveEvent. 
0070      */
0071     void mouseMoveEvent(QMouseEvent *me);
0072     
0073     /**
0074      * Overloaded event function to receive events when the user double clicks
0075      * in the thumbview. Double clicks here cause the preferences menu for this
0076      * frame to be shown.
0077      * @param e information about the mouseDoubleClickEvent.
0078      */
0079     void mouseDoubleClickEvent ( QMouseEvent * e );
0080     
0081     /**
0082      * Sets/changes the number of this widget.
0083      * @param number the new number of this widget.
0084      */
0085     void setNumber(int number);
0086     
0087     /**
0088      * Sets whether this widget has sounds.
0089      * @param hasSounds 
0090      */
0091     void setHasSounds( bool hasSounds );
0092     
0093     /**
0094      * Sets whether this thumbview should be selected.
0095      * @param selected whether this frame is selected.
0096      */
0097     void setSelected(bool selected);
0098     
0099     /**
0100      * Notifies the framethumbview that a drop have happened inside its borders. 
0101      * @param event information about the event.
0102      */
0103     void contentsDropped(QDropEvent * event);
0104     
0105 protected:
0106     /**
0107      * Event function which paints the widget.
0108      */
0109     void paintEvent ( QPaintEvent * );
0110     
0111 private:    
0112     /** Coordinate for calculating when a drag should start */
0113     QPoint dragPos;
0114 
0115     QString stringNumber;
0116     
0117     /** The width the text should have. (Cached for efficiency reasons)*/
0118     int textWidth;
0119     
0120     /** Whether this frame has sounds attached to it */
0121     bool hasSounds;
0122     
0123     /** Specifies whether this frame is selected. */
0124     bool selected;
0125     
0126     /** Starts an uri drag of the picture in this label. */
0127     void startDrag();
0128 };
0129 
0130 #endif