~ubuntu-branches/debian/squeeze/smplayer/squeeze

« back to all changes in this revision

Viewing changes to src/playlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Breuil Cyril
  • Date: 2007-06-24 16:35:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070624163529-hhckbmd24uicada7
Tags: 0.5.20-0ubuntu1
* New upstream release
* Change Maintainer Email

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  smplayer, GUI front-end for mplayer.
 
2
    Copyright (C) 2007 Ricardo Villalba <rvm@escomposlinux.org>
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify
 
5
    it under the terms of the GNU General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or
 
7
    (at your option) any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
    GNU General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License
 
15
    along with this program; if not, write to the Free Software
 
16
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
*/
 
18
 
 
19
 
 
20
#ifndef _PLAYLIST2_H_
 
21
#define _PLAYLIST2_H_
 
22
 
 
23
#include <qvaluelist.h>
 
24
#include <qstringlist.h>
 
25
#include <qmainwindow.h>
 
26
 
 
27
class PlaylistItem {
 
28
 
 
29
public:
 
30
        PlaylistItem() { _filename=""; _name=""; _duration=0; 
 
31
                     _played = FALSE; _deleted=FALSE; };
 
32
        PlaylistItem(QString filename, QString name, double duration) {
 
33
                         _filename = filename; _name = name; _duration = duration; 
 
34
                 _played = FALSE; _deleted = FALSE; };
 
35
        ~PlaylistItem() {};
 
36
 
 
37
        void setFilename(QString filename) { _filename = filename; };
 
38
        void setName(QString name) { _name = name; };
 
39
        void setDuration(double duration) { _duration = duration; };
 
40
        void setPlayed(bool b) { _played = b; };
 
41
        void setMarkForDeletion(bool b) { _deleted = b; };
 
42
 
 
43
        QString filename() { return _filename; };
 
44
        QString name() { return _name; };
 
45
        double duration() { return _duration; };
 
46
        bool played() { return _played; };
 
47
        bool markedForDeletion() { return _deleted; };
 
48
 
 
49
private:
 
50
        QString _filename, _name;
 
51
        double _duration;
 
52
        bool _played, _deleted;
 
53
};
 
54
 
 
55
 
 
56
class MyTable;
 
57
class QToolBar;
 
58
class MyAction;
 
59
class Core;
 
60
class QPopupMenu;
 
61
class QSettings;
 
62
class QToolButton;
 
63
class QTimer;
 
64
 
 
65
class Playlist : public QMainWindow
 
66
{
 
67
        Q_OBJECT
 
68
 
 
69
public:
 
70
        Playlist( Core *c, QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel );
 
71
        ~Playlist();
 
72
 
 
73
        void clear();
 
74
        void list();
 
75
        int count();
 
76
        bool isEmpty();
 
77
 
 
78
        bool isModified() { return modified; };
 
79
 
 
80
public slots:
 
81
        void addItem(QString filename, QString name, double duration);
 
82
 
 
83
        // Start playing, from item 0 if shuffle is off, or from
 
84
        // a random item otherwise
 
85
        void startPlay();
 
86
 
 
87
        void playItem(int n);
 
88
 
 
89
        virtual void playNext();
 
90
        virtual void playPrev();
 
91
 
 
92
        virtual void removeSelected();
 
93
        virtual void removeAll();
 
94
 
 
95
        virtual void addCurrentFile();
 
96
        virtual void addFiles();
 
97
        virtual void addDirectory();
 
98
 
 
99
        virtual void addFiles(QStringList files);
 
100
        virtual void addDirectory(QString dir);
 
101
 
 
102
        virtual bool maybeSave();
 
103
    virtual void load();
 
104
    virtual bool save();
 
105
 
 
106
        virtual void load_m3u(QString file);
 
107
        virtual bool save_m3u(QString file);
 
108
 
 
109
        virtual void getMediaInfo();
 
110
 
 
111
        void setModified(bool);
 
112
 
 
113
/*
 
114
public:
 
115
        MyAction * playPrevAct() { return prevAct; };
 
116
        MyAction * playNextAct() { return nextAct; };
 
117
*/
 
118
 
 
119
signals:
 
120
        void playlistEnded();
 
121
        void visibilityChanged();
 
122
        void modifiedChanged(bool);
 
123
 
 
124
protected:
 
125
        void updateView();
 
126
        void setCurrentItem(int current);
 
127
        void clearPlayedTag();
 
128
        int chooseRandomItem();
 
129
        void swapItems(int item1, int item2 );
 
130
        QString lastDir();
 
131
 
 
132
        virtual void dragEnterEvent( QDragEnterEvent * ) ;
 
133
        virtual void dropEvent ( QDropEvent * );
 
134
        virtual void hideEvent ( QHideEvent * );
 
135
        virtual void showEvent ( QShowEvent * );
 
136
        virtual void closeEvent( QCloseEvent * e );
 
137
 
 
138
protected slots:
 
139
        virtual void languageChange();
 
140
 
 
141
        virtual void playCurrent();
 
142
        virtual void itemDoubleClicked(int row);
 
143
        virtual void showPopup(int row, int col, const QPoint & pos);
 
144
        virtual void upItem();
 
145
        virtual void downItem();
 
146
        virtual void editCurrentItem();
 
147
        virtual void editItem(int item);
 
148
 
 
149
        virtual void saveSettings();
 
150
        virtual void loadSettings();
 
151
 
 
152
        virtual void maybeSaveSettings();
 
153
 
 
154
protected:
 
155
        void createTable();
 
156
        void createActions();
 
157
        void createToolbar();
 
158
 
 
159
protected:
 
160
        typedef QValueList <PlaylistItem> PlaylistItemList;
 
161
        PlaylistItemList pl;
 
162
        int current_item;
 
163
 
 
164
        QString playlist_path;
 
165
        QString latest_dir;
 
166
 
 
167
        Core * core;
 
168
        QPopupMenu * add_menu;
 
169
        QPopupMenu * remove_menu;
 
170
        QPopupMenu * popup;
 
171
 
 
172
        MyTable * listView;
 
173
 
 
174
        QToolBar * toolbar;
 
175
        QToolButton * add_button;
 
176
        QToolButton * remove_button;
 
177
 
 
178
        MyAction * openAct;
 
179
        MyAction * saveAct;
 
180
        MyAction * playAct;
 
181
        MyAction * prevAct;
 
182
        MyAction * nextAct;
 
183
        MyAction * repeatAct;
 
184
        MyAction * shuffleAct;
 
185
        MyAction * moveUpAct;
 
186
        MyAction * moveDownAct;
 
187
        MyAction * editAct;
 
188
 
 
189
        MyAction * addCurrentAct;
 
190
        MyAction * addFilesAct;
 
191
        MyAction * addDirectoryAct;
 
192
 
 
193
        MyAction * removeSelectedAct;
 
194
        MyAction * removeAllAct;
 
195
 
 
196
private:
 
197
        bool modified;
 
198
        QTimer * save_timer;
 
199
};
 
200
 
 
201
 
 
202
#endif
 
203