-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 809d5ac..d9a70ce 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,967 +1,967 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 27 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
29 | 29 | ||
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qaction.h> | 34 | #include <qaction.h> |
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlist.h> | 40 | #include <qlist.h> |
41 | #include <qlistbox.h> | 41 | #include <qlistbox.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
45 | #include <qtabwidget.h> | 45 | #include <qtabwidget.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qpoint.h> | 47 | #include <qpoint.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
50 | 50 | ||
51 | //#include <qtimer.h> | 51 | //#include <qtimer.h> |
52 | 52 | ||
53 | #include "playlistselection.h" | 53 | #include "playlistselection.h" |
54 | #include "playlistwidget.h" | 54 | #include "playlistwidget.h" |
55 | #include "mediaplayerstate.h" | 55 | #include "mediaplayerstate.h" |
56 | 56 | ||
57 | #include "inputDialog.h" | 57 | #include "inputDialog.h" |
58 | 58 | ||
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | 60 | ||
61 | #define BUTTONS_ON_TOOLBAR | 61 | #define BUTTONS_ON_TOOLBAR |
62 | #define SIDE_BUTTONS | 62 | #define SIDE_BUTTONS |
63 | #define CAN_SAVE_LOAD_PLAYLISTS | 63 | #define CAN_SAVE_LOAD_PLAYLISTS |
64 | 64 | ||
65 | extern MediaPlayerState *mediaPlayerState; | 65 | extern MediaPlayerState *mediaPlayerState; |
66 | 66 | ||
67 | // class myFileSelector { | 67 | // class myFileSelector { |
68 | 68 | ||
69 | // }; | 69 | // }; |
70 | class PlayListWidgetPrivate { | 70 | class PlayListWidgetPrivate { |
71 | public: | 71 | public: |
72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
73 | QFrame *playListFrame; | 73 | QFrame *playListFrame; |
74 | FileSelector *files; | 74 | FileSelector *files; |
75 | PlayListSelection *selectedFiles; | 75 | PlayListSelection *selectedFiles; |
76 | bool setDocumentUsed; | 76 | bool setDocumentUsed; |
77 | DocLnk *current; | 77 | DocLnk *current; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | class ToolButton : public QToolButton { | 81 | class ToolButton : public QToolButton { |
82 | public: | 82 | public: |
83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
84 | : QToolButton( parent, name ) { | 84 | : QToolButton( parent, name ) { |
85 | setTextLabel( name ); | 85 | setTextLabel( name ); |
86 | setPixmap( Resource::loadPixmap( icon ) ); | 86 | setPixmap( Resource::loadPixmap( icon ) ); |
87 | setAutoRaise( TRUE ); | 87 | setAutoRaise( TRUE ); |
88 | setFocusPolicy( QWidget::NoFocus ); | 88 | setFocusPolicy( QWidget::NoFocus ); |
89 | setToggleButton( t ); | 89 | setToggleButton( t ); |
90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
91 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 91 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
92 | } | 92 | } |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | class MenuItem : public QAction { | 96 | class MenuItem : public QAction { |
97 | public: | 97 | public: |
98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
99 | : QAction( text, QString::null, 0, 0 ) { | 99 | : QAction( text, QString::null, 0, 0 ) { |
100 | connect( this, SIGNAL( activated() ), handler, slot ); | 100 | connect( this, SIGNAL( activated() ), handler, slot ); |
101 | addTo( parent ); | 101 | addTo( parent ); |
102 | } | 102 | } |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
107 | : QMainWindow( parent, name, fl ) { | 107 | : QMainWindow( parent, name, fl ) { |
108 | 108 | ||
109 | d = new PlayListWidgetPrivate; | 109 | d = new PlayListWidgetPrivate; |
110 | d->setDocumentUsed = FALSE; | 110 | d->setDocumentUsed = FALSE; |
111 | d->current = NULL; | 111 | d->current = NULL; |
112 | fromSetDocument = FALSE; | 112 | fromSetDocument = FALSE; |
113 | insanityBool=FALSE; | 113 | insanityBool=FALSE; |
114 | // menuTimer = new QTimer( this ,"menu timer"), | 114 | // menuTimer = new QTimer( this ,"menu timer"), |
115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
116 | 116 | ||
117 | setBackgroundMode( PaletteButton ); | 117 | setBackgroundMode( PaletteButton ); |
118 | 118 | ||
119 | setCaption( tr("OpiePlayer") ); | 119 | setCaption( tr("OpiePlayer") ); |
120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
121 | 121 | ||
122 | setToolBarsMovable( FALSE ); | 122 | setToolBarsMovable( FALSE ); |
123 | 123 | ||
124 | // Create Toolbar | 124 | // Create Toolbar |
125 | QPEToolBar *toolbar = new QPEToolBar( this ); | 125 | QPEToolBar *toolbar = new QPEToolBar( this ); |
126 | toolbar->setHorizontalStretchable( TRUE ); | 126 | toolbar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | // Create Menubar | 128 | // Create Menubar |
129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
130 | menu->setMargin( 0 ); | 130 | menu->setMargin( 0 ); |
131 | 131 | ||
132 | QPEToolBar *bar = new QPEToolBar( this ); | 132 | QPEToolBar *bar = new QPEToolBar( this ); |
133 | bar->setLabel( tr( "Play Operations" ) ); | 133 | bar->setLabel( tr( "Play Operations" ) ); |
134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", | 134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
135 | // this , SLOT( addSelected()) ); | 135 | // this , SLOT( addSelected()) ); |
136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
137 | tbDeletePlaylist->setFlat(TRUE); | 137 | tbDeletePlaylist->setFlat(TRUE); |
138 | tbDeletePlaylist->setFixedSize(20,20); | 138 | tbDeletePlaylist->setFixedSize(20,20); |
139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
140 | 140 | ||
141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
142 | this , SLOT(addSelected()) ); | 142 | this , SLOT(addSelected()) ); |
143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
144 | this , SLOT(removeSelected()) ); | 144 | this , SLOT(removeSelected()) ); |
145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
147 | this , SLOT( btnPlay(bool) ), TRUE ); | 147 | this , SLOT( btnPlay(bool) ), TRUE ); |
148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | 148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", |
149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | 150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", |
151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
152 | tbDeletePlaylist->hide(); | 152 | tbDeletePlaylist->hide(); |
153 | 153 | ||
154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
155 | menu->insertItem( tr( "File" ), pmPlayList ); | 155 | menu->insertItem( tr( "File" ), pmPlayList ); |
156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
162 | 162 | ||
163 | QPopupMenu *pmView = new QPopupMenu( this ); | 163 | QPopupMenu *pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
165 | 165 | ||
166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
168 | fullScreenButton->addTo(pmView); | 168 | fullScreenButton->addTo(pmView); |
169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
171 | scaleButton->addTo(pmView); | 171 | scaleButton->addTo(pmView); |
172 | 172 | ||
173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
175 | 175 | ||
176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
177 | 177 | ||
178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
179 | tabWidget->setTabShape(QTabWidget::Triangular); | 179 | tabWidget->setTabShape(QTabWidget::Triangular); |
180 | 180 | ||
181 | QWidget *pTab; | 181 | QWidget *pTab; |
182 | pTab = new QWidget( tabWidget, "pTab" ); | 182 | pTab = new QWidget( tabWidget, "pTab" ); |
183 | // playlistView = new QListView( pTab, "playlistview" ); | 183 | // playlistView = new QListView( pTab, "playlistview" ); |
184 | // playlistView->setMinimumSize(236,260); | 184 | // playlistView->setMinimumSize(236,260); |
185 | tabWidget->insertTab( pTab,"Playlist"); | 185 | tabWidget->insertTab( pTab,"Playlist"); |
186 | 186 | ||
187 | 187 | ||
188 | // Add the playlist area | 188 | // Add the playlist area |
189 | 189 | ||
190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
191 | d->playListFrame = vbox3; | 191 | d->playListFrame = vbox3; |
192 | d->playListFrame ->setMinimumSize(235,260); | 192 | d->playListFrame ->setMinimumSize(235,260); |
193 | 193 | ||
194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
195 | 195 | ||
196 | d->selectedFiles = new PlayListSelection( hbox2); | 196 | d->selectedFiles = new PlayListSelection( hbox2); |
197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
198 | 198 | ||
199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
202 | 202 | ||
203 | 203 | ||
204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
209 | 209 | ||
210 | QWidget *aTab; | 210 | QWidget *aTab; |
211 | aTab = new QWidget( tabWidget, "aTab" ); | 211 | aTab = new QWidget( tabWidget, "aTab" ); |
212 | audioView = new QListView( aTab, "Audioview" ); | 212 | audioView = new QListView( aTab, "Audioview" ); |
213 | audioView->setMinimumSize(233,260); | 213 | audioView->setMinimumSize(233,260); |
214 | audioView->addColumn( tr("Title"),140); | 214 | audioView->addColumn( tr("Title"),140); |
215 | audioView->addColumn(tr("Size"), -1); | 215 | audioView->addColumn(tr("Size"), -1); |
216 | audioView->addColumn(tr("Media"),-1); | 216 | audioView->addColumn(tr("Media"),-1); |
217 | audioView->setColumnAlignment(1, Qt::AlignRight); | 217 | audioView->setColumnAlignment(1, Qt::AlignRight); |
218 | audioView->setColumnAlignment(2, Qt::AlignRight); | 218 | audioView->setColumnAlignment(2, Qt::AlignRight); |
219 | audioView->setAllColumnsShowFocus(TRUE); | 219 | audioView->setAllColumnsShowFocus(TRUE); |
220 | // audioView->setMultiSelection( TRUE ); | 220 | // audioView->setMultiSelection( TRUE ); |
221 | // audioView->setSelectionMode( QListView::Extended); | 221 | // audioView->setSelectionMode( QListView::Extended); |
222 | 222 | ||
223 | tabWidget->insertTab(aTab,tr("Audio")); | 223 | tabWidget->insertTab(aTab,tr("Audio")); |
224 | 224 | ||
225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
228 | 228 | ||
229 | 229 | ||
230 | // audioView | 230 | // audioView |
231 | populateAudioView(); | 231 | populateAudioView(); |
232 | // videowidget | 232 | // videowidget |
233 | 233 | ||
234 | QWidget *vTab; | 234 | QWidget *vTab; |
235 | vTab = new QWidget( tabWidget, "vTab" ); | 235 | vTab = new QWidget( tabWidget, "vTab" ); |
236 | videoView = new QListView( vTab, "Videoview" ); | 236 | videoView = new QListView( vTab, "Videoview" ); |
237 | videoView->setMinimumSize(233,260); | 237 | videoView->setMinimumSize(233,260); |
238 | 238 | ||
239 | videoView->addColumn(tr("Title"),140); | 239 | videoView->addColumn(tr("Title"),140); |
240 | videoView->addColumn(tr("Size"),-1); | 240 | videoView->addColumn(tr("Size"),-1); |
241 | videoView->addColumn(tr("Media"),-1); | 241 | videoView->addColumn(tr("Media"),-1); |
242 | videoView->setColumnAlignment(1, Qt::AlignRight); | 242 | videoView->setColumnAlignment(1, Qt::AlignRight); |
243 | videoView->setColumnAlignment(2, Qt::AlignRight); | 243 | videoView->setColumnAlignment(2, Qt::AlignRight); |
244 | videoView->setAllColumnsShowFocus(TRUE); | 244 | videoView->setAllColumnsShowFocus(TRUE); |
245 | // videoView->setMultiSelection( TRUE ); | 245 | // videoView->setMultiSelection( TRUE ); |
246 | // videoView->setSelectionMode( QListView::Extended); | 246 | // videoView->setSelectionMode( QListView::Extended); |
247 | 247 | ||
248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | 251 | ||
252 | tabWidget->insertTab( vTab,tr("Video")); | 252 | tabWidget->insertTab( vTab,tr("Video")); |
253 | 253 | populateVideoView(); | |
254 | 254 | ||
255 | //playlists list | 255 | //playlists list |
256 | QWidget *LTab; | 256 | QWidget *LTab; |
257 | LTab = new QWidget( tabWidget, "LTab" ); | 257 | LTab = new QWidget( tabWidget, "LTab" ); |
258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
259 | playLists->setMinimumSize(233,260);; | 259 | playLists->setMinimumSize(233,260);; |
260 | tabWidget->insertTab(LTab,tr("Lists")); | 260 | tabWidget->insertTab(LTab,tr("Lists")); |
261 | 261 | ||
262 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 262 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
264 | 264 | ||
265 | 265 | ||
266 | // add the library area | 266 | // add the library area |
267 | 267 | ||
268 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 268 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
269 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 269 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
270 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 270 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
271 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 271 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
272 | 272 | ||
273 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 273 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
275 | 275 | ||
276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
278 | 278 | ||
279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
284 | 284 | ||
285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
287 | 287 | ||
288 | setCentralWidget( vbox5 ); | 288 | setCentralWidget( vbox5 ); |
289 | 289 | ||
290 | Config cfg( "MediaPlayer" ); | 290 | Config cfg( "MediaPlayer" ); |
291 | readConfig( cfg ); | 291 | readConfig( cfg ); |
292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
293 | // qDebug("currentList is "+currentPlaylist); | 293 | // qDebug("currentList is "+currentPlaylist); |
294 | loadList(DocLnk( currentPlaylist)); | 294 | loadList(DocLnk( currentPlaylist)); |
295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
296 | 296 | ||
297 | initializeStates(); | 297 | initializeStates(); |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | PlayListWidget::~PlayListWidget() { | 301 | PlayListWidget::~PlayListWidget() { |
302 | Config cfg( "MediaPlayer" ); | 302 | Config cfg( "MediaPlayer" ); |
303 | writeConfig( cfg ); | 303 | writeConfig( cfg ); |
304 | 304 | ||
305 | 305 | ||
306 | if ( d->current ) | 306 | if ( d->current ) |
307 | delete d->current; | 307 | delete d->current; |
308 | delete d; | 308 | delete d; |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void PlayListWidget::initializeStates() { | 312 | void PlayListWidget::initializeStates() { |
313 | 313 | ||
314 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 314 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
315 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 315 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
320 | // setPlaylist( mediaPlayerState->playlist() ); | 320 | // setPlaylist( mediaPlayerState->playlist() ); |
321 | setPlaylist( true); | 321 | setPlaylist( true); |
322 | // d->selectedFiles->first(); | 322 | // d->selectedFiles->first(); |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void PlayListWidget::readConfig( Config& cfg ) { | 327 | void PlayListWidget::readConfig( Config& cfg ) { |
328 | cfg.setGroup("PlayList"); | 328 | cfg.setGroup("PlayList"); |
329 | QString currentString = cfg.readEntry("current", "" ); | 329 | QString currentString = cfg.readEntry("current", "" ); |
330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
331 | for ( int i = 0; i < noOfFiles; i++ ) { | 331 | for ( int i = 0; i < noOfFiles; i++ ) { |
332 | QString entryName; | 332 | QString entryName; |
333 | entryName.sprintf( "File%i", i + 1 ); | 333 | entryName.sprintf( "File%i", i + 1 ); |
334 | QString linkFile = cfg.readEntry( entryName ); | 334 | QString linkFile = cfg.readEntry( entryName ); |
335 | DocLnk lnk( linkFile ); | 335 | DocLnk lnk( linkFile ); |
336 | if ( lnk.isValid() ) { | 336 | if ( lnk.isValid() ) { |
337 | d->selectedFiles->addToSelection( lnk ); | 337 | d->selectedFiles->addToSelection( lnk ); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | d->selectedFiles->setSelectedItem( currentString); | 340 | d->selectedFiles->setSelectedItem( currentString); |
341 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 341 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void PlayListWidget::writeConfig( Config& cfg ) const { | 345 | void PlayListWidget::writeConfig( Config& cfg ) const { |
346 | 346 | ||
347 | d->selectedFiles->writeCurrent( cfg); | 347 | d->selectedFiles->writeCurrent( cfg); |
348 | cfg.setGroup("PlayList"); | 348 | cfg.setGroup("PlayList"); |
349 | int noOfFiles = 0; | 349 | int noOfFiles = 0; |
350 | d->selectedFiles->first(); | 350 | d->selectedFiles->first(); |
351 | do { | 351 | do { |
352 | const DocLnk *lnk = d->selectedFiles->current(); | 352 | const DocLnk *lnk = d->selectedFiles->current(); |
353 | if ( lnk ) { | 353 | if ( lnk ) { |
354 | QString entryName; | 354 | QString entryName; |
355 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 355 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
356 | // qDebug(entryName); | 356 | // qDebug(entryName); |
357 | cfg.writeEntry( entryName, lnk->linkFile() ); | 357 | cfg.writeEntry( entryName, lnk->linkFile() ); |
358 | // if this link does exist, add it so we have the file | 358 | // if this link does exist, add it so we have the file |
359 | // next time... | 359 | // next time... |
360 | if ( !QFile::exists( lnk->linkFile() ) ) { | 360 | if ( !QFile::exists( lnk->linkFile() ) ) { |
361 | // the way writing lnks doesn't really check for out | 361 | // the way writing lnks doesn't really check for out |
362 | // of disk space, but check it anyway. | 362 | // of disk space, but check it anyway. |
363 | if ( !lnk->writeLink() ) { | 363 | if ( !lnk->writeLink() ) { |
364 | QMessageBox::critical( 0, tr("Out of space"), | 364 | QMessageBox::critical( 0, tr("Out of space"), |
365 | tr( "There was a problem saving " | 365 | tr( "There was a problem saving " |
366 | "the playlist.\n" | 366 | "the playlist.\n" |
367 | "Your playlist " | 367 | "Your playlist " |
368 | "may be missing some entries\n" | 368 | "may be missing some entries\n" |
369 | "the next time you start it." ) | 369 | "the next time you start it." ) |
370 | ); | 370 | ); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | noOfFiles++; | 373 | noOfFiles++; |
374 | } | 374 | } |
375 | } | 375 | } |
376 | while ( d->selectedFiles->next() ); | 376 | while ( d->selectedFiles->next() ); |
377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
382 | // qDebug("add"); | 382 | // qDebug("add"); |
383 | d->setDocumentUsed = FALSE; | 383 | d->setDocumentUsed = FALSE; |
384 | if ( mediaPlayerState->playlist() ) | 384 | if ( mediaPlayerState->playlist() ) |
385 | d->selectedFiles->addToSelection( lnk ); | 385 | d->selectedFiles->addToSelection( lnk ); |
386 | else | 386 | else |
387 | mediaPlayerState->setPlaying( TRUE ); | 387 | mediaPlayerState->setPlaying( TRUE ); |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void PlayListWidget::clearList() { | 391 | void PlayListWidget::clearList() { |
392 | while ( first() ) | 392 | while ( first() ) |
393 | d->selectedFiles->removeSelected(); | 393 | d->selectedFiles->removeSelected(); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | void PlayListWidget::addAllToList() { | 397 | void PlayListWidget::addAllToList() { |
398 | DocLnkSet filesAll; | 398 | DocLnkSet filesAll; |
399 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 399 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
400 | QListIterator<DocLnk> Adit( filesAll.children() ); | 400 | QListIterator<DocLnk> Adit( filesAll.children() ); |
401 | for ( ; Adit.current(); ++Adit ) | 401 | for ( ; Adit.current(); ++Adit ) |
402 | d->selectedFiles->addToSelection( **Adit ); | 402 | d->selectedFiles->addToSelection( **Adit ); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | void PlayListWidget::addAllMusicToList() { | 406 | void PlayListWidget::addAllMusicToList() { |
407 | // DocLnkSet files; | 407 | // DocLnkSet files; |
408 | // Global::findDocuments(&files, "audio/*"); | 408 | // Global::findDocuments(&files, "audio/*"); |
409 | QListIterator<DocLnk> dit( files.children() ); | 409 | QListIterator<DocLnk> dit( files.children() ); |
410 | for ( ; dit.current(); ++dit ) | 410 | for ( ; dit.current(); ++dit ) |
411 | d->selectedFiles->addToSelection( **dit ); | 411 | d->selectedFiles->addToSelection( **dit ); |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | void PlayListWidget::addAllVideoToList() { | 415 | void PlayListWidget::addAllVideoToList() { |
416 | QListIterator<DocLnk> dit( vFiles.children() ); | 416 | QListIterator<DocLnk> dit( vFiles.children() ); |
417 | for ( ; dit.current(); ++dit ) | 417 | for ( ; dit.current(); ++dit ) |
418 | d->selectedFiles->addToSelection( **dit ); | 418 | d->selectedFiles->addToSelection( **dit ); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void PlayListWidget::setDocument(const QString& fileref) { | 422 | void PlayListWidget::setDocument(const QString& fileref) { |
423 | fromSetDocument = TRUE; | 423 | fromSetDocument = TRUE; |
424 | if ( fileref.isNull() ) { | 424 | if ( fileref.isNull() ) { |
425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | // qDebug("setDocument "+fileref); | 428 | // qDebug("setDocument "+fileref); |
429 | if(fileref.find("playlist",0,TRUE) == -1) { | 429 | if(fileref.find("playlist",0,TRUE) == -1) { |
430 | clearList(); | 430 | clearList(); |
431 | addToSelection( DocLnk( fileref ) ); | 431 | addToSelection( DocLnk( fileref ) ); |
432 | d->setDocumentUsed = TRUE; | 432 | d->setDocumentUsed = TRUE; |
433 | mediaPlayerState->setPlaying( FALSE ); | 433 | mediaPlayerState->setPlaying( FALSE ); |
434 | qApp->processEvents(); | 434 | qApp->processEvents(); |
435 | mediaPlayerState->setPlaying( TRUE ); | 435 | mediaPlayerState->setPlaying( TRUE ); |
436 | qApp->processEvents(); | 436 | qApp->processEvents(); |
437 | setCaption(tr("OpiePlayer")); | 437 | setCaption(tr("OpiePlayer")); |
438 | 438 | ||
439 | } else { //is playlist | 439 | } else { //is playlist |
440 | clearList(); | 440 | clearList(); |
441 | loadList(DocLnk(fileref)); | 441 | loadList(DocLnk(fileref)); |
442 | d->selectedFiles->first(); | 442 | d->selectedFiles->first(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void PlayListWidget::setActiveWindow() { | 447 | void PlayListWidget::setActiveWindow() { |
448 | // When we get raised we need to ensure that it switches views | 448 | // When we get raised we need to ensure that it switches views |
449 | char origView = mediaPlayerState->view(); | 449 | char origView = mediaPlayerState->view(); |
450 | mediaPlayerState->setView( 'l' ); // invalidate | 450 | mediaPlayerState->setView( 'l' ); // invalidate |
451 | mediaPlayerState->setView( origView ); // now switch back | 451 | mediaPlayerState->setView( origView ); // now switch back |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::useSelectedDocument() { | 455 | void PlayListWidget::useSelectedDocument() { |
456 | d->setDocumentUsed = FALSE; | 456 | d->setDocumentUsed = FALSE; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | const DocLnk *PlayListWidget::current() { // this is fugly | 460 | const DocLnk *PlayListWidget::current() { // this is fugly |
461 | 461 | ||
462 | // if( fromSetDocument) { | 462 | // if( fromSetDocument) { |
463 | // qDebug("from setDoc"); | 463 | // qDebug("from setDoc"); |
464 | // DocLnkSet files; | 464 | // DocLnkSet files; |
465 | // Global::findDocuments(&files, "video/*;audio/*"); | 465 | // Global::findDocuments(&files, "video/*;audio/*"); |
466 | // QListIterator<DocLnk> dit( files.children() ); | 466 | // QListIterator<DocLnk> dit( files.children() ); |
467 | // for ( ; dit.current(); ++dit ) { | 467 | // for ( ; dit.current(); ++dit ) { |
468 | // if(dit.current()->linkFile() == setDocFileRef) { | 468 | // if(dit.current()->linkFile() == setDocFileRef) { |
469 | // qDebug(setDocFileRef); | 469 | // qDebug(setDocFileRef); |
470 | // return dit; | 470 | // return dit; |
471 | // } | 471 | // } |
472 | // } | 472 | // } |
473 | // } else | 473 | // } else |
474 | 474 | ||
475 | 475 | ||
476 | switch (tabWidget->currentPageIndex()) { | 476 | switch (tabWidget->currentPageIndex()) { |
477 | case 0: //playlist | 477 | case 0: //playlist |
478 | { | 478 | { |
479 | qDebug("playlist"); | 479 | qDebug("playlist"); |
480 | if ( mediaPlayerState->playlist() ) { | 480 | if ( mediaPlayerState->playlist() ) { |
481 | return d->selectedFiles->current(); | 481 | return d->selectedFiles->current(); |
482 | } | 482 | } |
483 | else if ( d->setDocumentUsed && d->current ) { | 483 | else if ( d->setDocumentUsed && d->current ) { |
484 | return d->current; | 484 | return d->current; |
485 | } else { | 485 | } else { |
486 | return d->files->selected(); | 486 | return d->files->selected(); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | break; | 489 | break; |
490 | case 1://audio | 490 | case 1://audio |
491 | { | 491 | { |
492 | qDebug("audioView"); | 492 | qDebug("audioView"); |
493 | // Global::findDocuments(&files, "audio/*"); | 493 | // Global::findDocuments(&files, "audio/*"); |
494 | QListIterator<DocLnk> dit( files.children() ); | 494 | QListIterator<DocLnk> dit( files.children() ); |
495 | for ( ; dit.current(); ++dit ) { | 495 | for ( ; dit.current(); ++dit ) { |
496 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 496 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
497 | qDebug("here"); | 497 | qDebug("here"); |
498 | insanityBool=TRUE; | 498 | insanityBool=TRUE; |
499 | return dit; | 499 | return dit; |
500 | } | 500 | } |
501 | } | 501 | } |
502 | } | 502 | } |
503 | break; | 503 | break; |
504 | case 2: // video | 504 | case 2: // video |
505 | { | 505 | { |
506 | qDebug("videoView"); | 506 | qDebug("videoView"); |
507 | // Global::findDocuments(&vFiles, "video/*"); | 507 | // Global::findDocuments(&vFiles, "video/*"); |
508 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 508 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
509 | for ( ; Vdit.current(); ++Vdit ) { | 509 | for ( ; Vdit.current(); ++Vdit ) { |
510 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 510 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
511 | insanityBool=TRUE; | 511 | insanityBool=TRUE; |
512 | return Vdit; | 512 | return Vdit; |
513 | } | 513 | } |
514 | } | 514 | } |
515 | } | 515 | } |
516 | break; | 516 | break; |
517 | }; | 517 | }; |
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | bool PlayListWidget::prev() { | 521 | bool PlayListWidget::prev() { |
522 | if ( mediaPlayerState->playlist() ) { | 522 | if ( mediaPlayerState->playlist() ) { |
523 | if ( mediaPlayerState->shuffled() ) { | 523 | if ( mediaPlayerState->shuffled() ) { |
524 | const DocLnk *cur = current(); | 524 | const DocLnk *cur = current(); |
525 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 525 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
526 | for ( int i = 0; i < j; i++ ) { | 526 | for ( int i = 0; i < j; i++ ) { |
527 | if ( !d->selectedFiles->next() ) | 527 | if ( !d->selectedFiles->next() ) |
528 | d->selectedFiles->first(); | 528 | d->selectedFiles->first(); |
529 | } | 529 | } |
530 | if ( cur == current() ) | 530 | if ( cur == current() ) |
531 | if ( !d->selectedFiles->next() ) | 531 | if ( !d->selectedFiles->next() ) |
532 | d->selectedFiles->first(); | 532 | d->selectedFiles->first(); |
533 | return TRUE; | 533 | return TRUE; |
534 | } else { | 534 | } else { |
535 | if ( !d->selectedFiles->prev() ) { | 535 | if ( !d->selectedFiles->prev() ) { |
536 | if ( mediaPlayerState->looping() ) { | 536 | if ( mediaPlayerState->looping() ) { |
537 | return d->selectedFiles->last(); | 537 | return d->selectedFiles->last(); |
538 | } else { | 538 | } else { |
539 | return FALSE; | 539 | return FALSE; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | return TRUE; | 542 | return TRUE; |
543 | } | 543 | } |
544 | } else { | 544 | } else { |
545 | return mediaPlayerState->looping(); | 545 | return mediaPlayerState->looping(); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | bool PlayListWidget::next() { | 550 | bool PlayListWidget::next() { |
551 | if ( mediaPlayerState->playlist() ) { | 551 | if ( mediaPlayerState->playlist() ) { |
552 | if ( mediaPlayerState->shuffled() ) { | 552 | if ( mediaPlayerState->shuffled() ) { |
553 | return prev(); | 553 | return prev(); |
554 | } else { | 554 | } else { |
555 | if ( !d->selectedFiles->next() ) { | 555 | if ( !d->selectedFiles->next() ) { |
556 | if ( mediaPlayerState->looping() ) { | 556 | if ( mediaPlayerState->looping() ) { |
557 | return d->selectedFiles->first(); | 557 | return d->selectedFiles->first(); |
558 | } else { | 558 | } else { |
559 | return FALSE; | 559 | return FALSE; |
560 | } | 560 | } |
561 | } | 561 | } |
562 | return TRUE; | 562 | return TRUE; |
563 | } | 563 | } |
564 | } else { | 564 | } else { |
565 | return mediaPlayerState->looping(); | 565 | return mediaPlayerState->looping(); |
566 | } | 566 | } |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | bool PlayListWidget::first() { | 570 | bool PlayListWidget::first() { |
571 | if ( mediaPlayerState->playlist() ) | 571 | if ( mediaPlayerState->playlist() ) |
572 | return d->selectedFiles->first(); | 572 | return d->selectedFiles->first(); |
573 | else | 573 | else |
574 | return mediaPlayerState->looping(); | 574 | return mediaPlayerState->looping(); |
575 | } | 575 | } |
576 | 576 | ||
577 | 577 | ||
578 | bool PlayListWidget::last() { | 578 | bool PlayListWidget::last() { |
579 | if ( mediaPlayerState->playlist() ) | 579 | if ( mediaPlayerState->playlist() ) |
580 | return d->selectedFiles->last(); | 580 | return d->selectedFiles->last(); |
581 | else | 581 | else |
582 | return mediaPlayerState->looping(); | 582 | return mediaPlayerState->looping(); |
583 | } | 583 | } |
584 | 584 | ||
585 | 585 | ||
586 | void PlayListWidget::saveList() { | 586 | void PlayListWidget::saveList() { |
587 | 587 | ||
588 | QString filename; | 588 | QString filename; |
589 | InputDialog *fileDlg; | 589 | InputDialog *fileDlg; |
590 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 590 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
591 | fileDlg->exec(); | 591 | fileDlg->exec(); |
592 | if( fileDlg->result() == 1 ) { | 592 | if( fileDlg->result() == 1 ) { |
593 | if ( d->current ) | 593 | if ( d->current ) |
594 | delete d->current; | 594 | delete d->current; |
595 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 595 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
596 | // qDebug("saving playlist "+filename+".playlist"); | 596 | // qDebug("saving playlist "+filename+".playlist"); |
597 | Config cfg( filename +".playlist"); | 597 | Config cfg( filename +".playlist"); |
598 | writeConfig( cfg ); | 598 | writeConfig( cfg ); |
599 | 599 | ||
600 | // qDebug("same name so delete lnk??"); | 600 | // qDebug("same name so delete lnk??"); |
601 | // if( playLists->selected()->name() == filename) { | 601 | // if( playLists->selected()->name() == filename) { |
602 | 602 | ||
603 | // qDebug("same name so delete lnk"); | 603 | // qDebug("same name so delete lnk"); |
604 | // QFile().remove(playLists->selected()->file()); | 604 | // QFile().remove(playLists->selected()->file()); |
605 | // QFile().remove(playLists->selected()->linkFile()); | 605 | // QFile().remove(playLists->selected()->linkFile()); |
606 | // playLists->reread(); | 606 | // playLists->reread(); |
607 | // } | 607 | // } |
608 | // qDebug("new doclnk"); | 608 | // qDebug("new doclnk"); |
609 | DocLnk lnk; | 609 | DocLnk lnk; |
610 | // lnk.setComment( ""); | 610 | // lnk.setComment( ""); |
611 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 611 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
612 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 612 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
613 | lnk.setIcon("mpegplayer/playlist2"); | 613 | lnk.setIcon("mpegplayer/playlist2"); |
614 | lnk.setName( filename); //sets file name | 614 | lnk.setName( filename); //sets file name |
615 | // qDebug(filename); | 615 | // qDebug(filename); |
616 | if(!lnk.writeLink()) | 616 | if(!lnk.writeLink()) |
617 | qDebug("Writing doclink did not work"); | 617 | qDebug("Writing doclink did not work"); |
618 | } | 618 | } |
619 | Config config( "MediaPlayer" ); | 619 | Config config( "MediaPlayer" ); |
620 | config.writeEntry("CurrentPlaylist",filename); | 620 | config.writeEntry("CurrentPlaylist",filename); |
621 | setCaption(tr("OpiePlayer: ")+filename); | 621 | setCaption(tr("OpiePlayer: ")+filename); |
622 | d->selectedFiles->first(); | 622 | d->selectedFiles->first(); |
623 | if(fileDlg) | 623 | if(fileDlg) |
624 | delete fileDlg; | 624 | delete fileDlg; |
625 | } | 625 | } |
626 | 626 | ||
627 | void PlayListWidget::loadList( const DocLnk & lnk) { | 627 | void PlayListWidget::loadList( const DocLnk & lnk) { |
628 | QString name= lnk.name(); | 628 | QString name= lnk.name(); |
629 | // qDebug("currentList is "+name); | 629 | // qDebug("currentList is "+name); |
630 | if( name.length()>1) { | 630 | if( name.length()>1) { |
631 | setCaption("OpiePlayer: "+name); | 631 | setCaption("OpiePlayer: "+name); |
632 | // qDebug("load list "+ name+".playlist"); | 632 | // qDebug("load list "+ name+".playlist"); |
633 | clearList(); | 633 | clearList(); |
634 | Config cfg( name+".playlist"); | 634 | Config cfg( name+".playlist"); |
635 | readConfig(cfg); | 635 | readConfig(cfg); |
636 | 636 | ||
637 | tabWidget->setCurrentPage(0); | 637 | tabWidget->setCurrentPage(0); |
638 | 638 | ||
639 | Config config( "MediaPlayer" ); | 639 | Config config( "MediaPlayer" ); |
640 | config.writeEntry("CurrentPlaylist", name); | 640 | config.writeEntry("CurrentPlaylist", name); |
641 | // d->selectedFiles->first(); | 641 | // d->selectedFiles->first(); |
642 | } | 642 | } |
643 | 643 | ||
644 | } | 644 | } |
645 | 645 | ||
646 | void PlayListWidget::setPlaylist( bool shown ) { | 646 | void PlayListWidget::setPlaylist( bool shown ) { |
647 | if ( shown ) | 647 | if ( shown ) |
648 | d->playListFrame->show(); | 648 | d->playListFrame->show(); |
649 | else | 649 | else |
650 | d->playListFrame->hide(); | 650 | d->playListFrame->hide(); |
651 | } | 651 | } |
652 | 652 | ||
653 | void PlayListWidget::setView( char view ) { | 653 | void PlayListWidget::setView( char view ) { |
654 | if ( view == 'l' ) | 654 | if ( view == 'l' ) |
655 | showMaximized(); | 655 | showMaximized(); |
656 | else | 656 | else |
657 | hide(); | 657 | hide(); |
658 | } | 658 | } |
659 | 659 | ||
660 | void PlayListWidget::addSelected() { | 660 | void PlayListWidget::addSelected() { |
661 | 661 | ||
662 | Config cfg( "MediaPlayer" ); | 662 | Config cfg( "MediaPlayer" ); |
663 | cfg.setGroup("PlayList"); | 663 | cfg.setGroup("PlayList"); |
664 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 664 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
665 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 665 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
666 | 666 | ||
667 | switch (tabWidget->currentPageIndex()) { | 667 | switch (tabWidget->currentPageIndex()) { |
668 | case 0: //playlist | 668 | case 0: //playlist |
669 | break; | 669 | break; |
670 | case 1: { //audio | 670 | case 1: { //audio |
671 | for ( int i = 0; i < noOfFiles; i++ ) { | 671 | for ( int i = 0; i < noOfFiles; i++ ) { |
672 | QString entryName; | 672 | QString entryName; |
673 | entryName.sprintf( "File%i", i + 1 ); | 673 | entryName.sprintf( "File%i", i + 1 ); |
674 | QString linkFile = cfg.readEntry( entryName ); | 674 | QString linkFile = cfg.readEntry( entryName ); |
675 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 675 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
676 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 676 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
677 | tr("This is all ready in your playlist.\nContinue?"), | 677 | tr("This is all ready in your playlist.\nContinue?"), |
678 | tr("Yes"),tr("No"),0,0,1); | 678 | tr("Yes"),tr("No"),0,0,1); |
679 | if (result !=0) | 679 | if (result !=0) |
680 | return; | 680 | return; |
681 | } | 681 | } |
682 | } | 682 | } |
683 | addToSelection( audioView->selectedItem() ); | 683 | addToSelection( audioView->selectedItem() ); |
684 | tabWidget->setCurrentPage(1); | 684 | tabWidget->setCurrentPage(1); |
685 | } | 685 | } |
686 | break; | 686 | break; |
687 | case 2: { // video | 687 | case 2: { // video |
688 | for ( int i = 0; i < noOfFiles; i++ ) { | 688 | for ( int i = 0; i < noOfFiles; i++ ) { |
689 | QString entryName; | 689 | QString entryName; |
690 | entryName.sprintf( "File%i", i + 1 ); | 690 | entryName.sprintf( "File%i", i + 1 ); |
691 | QString linkFile = cfg.readEntry( entryName ); | 691 | QString linkFile = cfg.readEntry( entryName ); |
692 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 692 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
693 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 693 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
694 | tr("This is all ready in your playlist.\nContinue?"), | 694 | tr("This is all ready in your playlist.\nContinue?"), |
695 | tr("Yes"),tr("No"),0,0,1); | 695 | tr("Yes"),tr("No"),0,0,1); |
696 | if (result !=0) | 696 | if (result !=0) |
697 | return; | 697 | return; |
698 | } | 698 | } |
699 | } | 699 | } |
700 | addToSelection( videoView->selectedItem() ); | 700 | addToSelection( videoView->selectedItem() ); |
701 | tabWidget->setCurrentPage(2); | 701 | tabWidget->setCurrentPage(2); |
702 | } | 702 | } |
703 | break; | 703 | break; |
704 | }; | 704 | }; |
705 | } | 705 | } |
706 | 706 | ||
707 | void PlayListWidget::removeSelected() { | 707 | void PlayListWidget::removeSelected() { |
708 | d->selectedFiles->removeSelected( ); | 708 | d->selectedFiles->removeSelected( ); |
709 | } | 709 | } |
710 | 710 | ||
711 | void PlayListWidget::playIt( QListViewItem *it) { | 711 | void PlayListWidget::playIt( QListViewItem *it) { |
712 | // d->setDocumentUsed = FALSE; | 712 | // d->setDocumentUsed = FALSE; |
713 | mediaPlayerState->setPlaying(TRUE); | 713 | mediaPlayerState->setPlaying(TRUE); |
714 | } | 714 | } |
715 | 715 | ||
716 | void PlayListWidget::addToSelection( QListViewItem *it) { | 716 | void PlayListWidget::addToSelection( QListViewItem *it) { |
717 | d->setDocumentUsed = FALSE; | 717 | d->setDocumentUsed = FALSE; |
718 | 718 | ||
719 | if(it) { | 719 | if(it) { |
720 | switch (tabWidget->currentPageIndex()) { | 720 | switch (tabWidget->currentPageIndex()) { |
721 | case 1: { | 721 | case 1: { |
722 | QListIterator<DocLnk> dit( files.children() ); | 722 | QListIterator<DocLnk> dit( files.children() ); |
723 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
724 | if( dit.current()->name() == it->text(0)) { | 724 | if( dit.current()->name() == it->text(0)) { |
725 | d->selectedFiles->addToSelection( **dit ); | 725 | d->selectedFiles->addToSelection( **dit ); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | } | 728 | } |
729 | break; | 729 | break; |
730 | case 2: { | 730 | case 2: { |
731 | QListIterator<DocLnk> dit( vFiles.children() ); | 731 | QListIterator<DocLnk> dit( vFiles.children() ); |
732 | for ( ; dit.current(); ++dit ) { | 732 | for ( ; dit.current(); ++dit ) { |
733 | if( dit.current()->name() == it->text(0)) { | 733 | if( dit.current()->name() == it->text(0)) { |
734 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | } | 737 | } |
738 | break; | 738 | break; |
739 | case 0: | 739 | case 0: |
740 | break; | 740 | break; |
741 | }; | 741 | }; |
742 | tabWidget->setCurrentPage(0); | 742 | tabWidget->setCurrentPage(0); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | void PlayListWidget::tabChanged(QWidget *widg) { | 746 | void PlayListWidget::tabChanged(QWidget *widg) { |
747 | 747 | ||
748 | switch ( tabWidget->currentPageIndex()) { | 748 | switch ( tabWidget->currentPageIndex()) { |
749 | case 0: | 749 | case 0: |
750 | { | 750 | { |
751 | if( !tbDeletePlaylist->isHidden()) | 751 | if( !tbDeletePlaylist->isHidden()) |
752 | tbDeletePlaylist->hide(); | 752 | tbDeletePlaylist->hide(); |
753 | d->tbRemoveFromList->setEnabled(TRUE); | 753 | d->tbRemoveFromList->setEnabled(TRUE); |
754 | d->tbAddToList->setEnabled(FALSE); | 754 | d->tbAddToList->setEnabled(FALSE); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | case 1: | 757 | case 1: |
758 | { | 758 | { |
759 | if( !tbDeletePlaylist->isHidden()) | 759 | if( !tbDeletePlaylist->isHidden()) |
760 | tbDeletePlaylist->hide(); | 760 | tbDeletePlaylist->hide(); |
761 | d->tbRemoveFromList->setEnabled(FALSE); | 761 | d->tbRemoveFromList->setEnabled(FALSE); |
762 | d->tbAddToList->setEnabled(TRUE); | 762 | d->tbAddToList->setEnabled(TRUE); |
763 | } | 763 | } |
764 | break; | 764 | break; |
765 | case 2: | 765 | case 2: |
766 | { | 766 | { |
767 | if( !tbDeletePlaylist->isHidden()) | 767 | if( !tbDeletePlaylist->isHidden()) |
768 | tbDeletePlaylist->hide(); | 768 | tbDeletePlaylist->hide(); |
769 | d->tbRemoveFromList->setEnabled(FALSE); | 769 | d->tbRemoveFromList->setEnabled(FALSE); |
770 | d->tbAddToList->setEnabled(TRUE); | 770 | d->tbAddToList->setEnabled(TRUE); |
771 | } | 771 | } |
772 | break; | 772 | break; |
773 | case 3: | 773 | case 3: |
774 | { | 774 | { |
775 | if( tbDeletePlaylist->isHidden()) | 775 | if( tbDeletePlaylist->isHidden()) |
776 | tbDeletePlaylist->show(); | 776 | tbDeletePlaylist->show(); |
777 | playLists->reread(); | 777 | playLists->reread(); |
778 | } | 778 | } |
779 | break; | 779 | break; |
780 | }; | 780 | }; |
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||
784 | 784 | ||
785 | void PlayListWidget::btnPlay(bool b) { | 785 | void PlayListWidget::btnPlay(bool b) { |
786 | 786 | ||
787 | // mediaPlayerState->setPlaying(b); | 787 | // mediaPlayerState->setPlaying(b); |
788 | switch ( tabWidget->currentPageIndex()) { | 788 | switch ( tabWidget->currentPageIndex()) { |
789 | case 0: | 789 | case 0: |
790 | { | 790 | { |
791 | mediaPlayerState->setPlaying(b); | 791 | mediaPlayerState->setPlaying(b); |
792 | } | 792 | } |
793 | break; | 793 | break; |
794 | case 1: | 794 | case 1: |
795 | { | 795 | { |
796 | addToSelection( audioView->selectedItem() ); | 796 | addToSelection( audioView->selectedItem() ); |
797 | mediaPlayerState->setPlaying(b); | 797 | mediaPlayerState->setPlaying(b); |
798 | d->selectedFiles->removeSelected( ); | 798 | d->selectedFiles->removeSelected( ); |
799 | tabWidget->setCurrentPage(1); | 799 | tabWidget->setCurrentPage(1); |
800 | d->selectedFiles->unSelect(); | 800 | d->selectedFiles->unSelect(); |
801 | // audioView->clearSelection(); | 801 | // audioView->clearSelection(); |
802 | } | 802 | } |
803 | break; | 803 | break; |
804 | case 2: | 804 | case 2: |
805 | { | 805 | { |
806 | addToSelection( videoView->selectedItem() ); | 806 | addToSelection( videoView->selectedItem() ); |
807 | mediaPlayerState->setPlaying(b); | 807 | mediaPlayerState->setPlaying(b); |
808 | qApp->processEvents(); | 808 | qApp->processEvents(); |
809 | d->selectedFiles->removeSelected( ); | 809 | d->selectedFiles->removeSelected( ); |
810 | tabWidget->setCurrentPage(2); | 810 | tabWidget->setCurrentPage(2); |
811 | d->selectedFiles->unSelect(); | 811 | d->selectedFiles->unSelect(); |
812 | // videoView->clearSelection(); | 812 | // videoView->clearSelection(); |
813 | } | 813 | } |
814 | break; | 814 | break; |
815 | }; | 815 | }; |
816 | } | 816 | } |
817 | 817 | ||
818 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
820 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
821 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
822 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
823 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
824 | QFile().remove(playLists->selected()->linkFile()); | 824 | QFile().remove(playLists->selected()->linkFile()); |
825 | playLists->reread(); | 825 | playLists->reread(); |
826 | break; | 826 | break; |
827 | case 1: // Cancel | 827 | case 1: // Cancel |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | 830 | ||
831 | } | 831 | } |
832 | 832 | ||
833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
834 | { | 834 | { |
835 | switch (mouse) { | 835 | switch (mouse) { |
836 | case 1: | 836 | case 1: |
837 | break; | 837 | break; |
838 | case 2:{ | 838 | case 2:{ |
839 | QPopupMenu m; | 839 | QPopupMenu m; |
840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
842 | m.insertSeparator(); | 842 | m.insertSeparator(); |
843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
844 | m.exec( QCursor::pos() ); | 844 | m.exec( QCursor::pos() ); |
845 | } | 845 | } |
846 | break; | 846 | break; |
847 | }; | 847 | }; |
848 | } | 848 | } |
849 | 849 | ||
850 | void PlayListWidget::playSelected() | 850 | void PlayListWidget::playSelected() |
851 | { | 851 | { |
852 | btnPlay( TRUE); | 852 | btnPlay( TRUE); |
853 | } | 853 | } |
854 | 854 | ||
855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
856 | { | 856 | { |
857 | switch (mouse) { | 857 | switch (mouse) { |
858 | case 1: | 858 | case 1: |
859 | break; | 859 | break; |
860 | case 2:{ | 860 | case 2:{ |
861 | QPopupMenu m; | 861 | QPopupMenu m; |
862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
864 | // m.insertSeparator(); | 864 | // m.insertSeparator(); |
865 | m.exec( QCursor::pos() ); | 865 | m.exec( QCursor::pos() ); |
866 | } | 866 | } |
867 | break; | 867 | break; |
868 | }; | 868 | }; |
869 | 869 | ||
870 | } | 870 | } |
871 | 871 | ||
872 | void PlayListWidget::listDelete() { | 872 | void PlayListWidget::listDelete() { |
873 | Config cfg( "MediaPlayer" ); | 873 | Config cfg( "MediaPlayer" ); |
874 | cfg.setGroup("PlayList"); | 874 | cfg.setGroup("PlayList"); |
875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
876 | QString file; | 876 | QString file; |
877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
878 | switch ( tabWidget->currentPageIndex()) { | 878 | switch ( tabWidget->currentPageIndex()) { |
879 | case 0: | 879 | case 0: |
880 | break; | 880 | break; |
881 | case 1: | 881 | case 1: |
882 | { | 882 | { |
883 | file = audioView->selectedItem()->text(0); | 883 | file = audioView->selectedItem()->text(0); |
884 | // Global::findDocuments(&files, "audio/*"); | 884 | // Global::findDocuments(&files, "audio/*"); |
885 | // AppLnkSet appFiles; | 885 | // AppLnkSet appFiles; |
886 | QListIterator<DocLnk> dit( files.children() ); | 886 | QListIterator<DocLnk> dit( files.children() ); |
887 | for ( ; dit.current(); ++dit ) { | 887 | for ( ; dit.current(); ++dit ) { |
888 | if( dit.current()->name() == file) { | 888 | if( dit.current()->name() == file) { |
889 | // qDebug(file); | 889 | // qDebug(file); |
890 | LnkProperties prop( dit.current() ); | 890 | LnkProperties prop( dit.current() ); |
891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
892 | prop.showMaximized(); | 892 | prop.showMaximized(); |
893 | prop.exec(); | 893 | prop.exec(); |
894 | } | 894 | } |
895 | } | 895 | } |
896 | populateAudioView(); | 896 | populateAudioView(); |
897 | } | 897 | } |
898 | break; | 898 | break; |
899 | case 2: | 899 | case 2: |
900 | { | 900 | { |
901 | // file = videoView->selectedItem()->text(0); | 901 | // file = videoView->selectedItem()->text(0); |
902 | // for ( int i = 0; i < noOfFiles; i++ ) { | 902 | // for ( int i = 0; i < noOfFiles; i++ ) { |
903 | // QString entryName; | 903 | // QString entryName; |
904 | // entryName.sprintf( "File%i", i + 1 ); | 904 | // entryName.sprintf( "File%i", i + 1 ); |
905 | // QString linkFile = cfg.readEntry( entryName ); | 905 | // QString linkFile = cfg.readEntry( entryName ); |
906 | // AppLnk lnk( AppLnk(linkFile)); | 906 | // AppLnk lnk( AppLnk(linkFile)); |
907 | // if( lnk.name() == file ) { | 907 | // if( lnk.name() == file ) { |
908 | // LnkProperties prop( &lnk); | 908 | // LnkProperties prop( &lnk); |
909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
910 | // prop.showMaximized(); | 910 | // prop.showMaximized(); |
911 | // prop.exec(); | 911 | // prop.exec(); |
912 | // } | 912 | // } |
913 | // } | 913 | // } |
914 | } | 914 | } |
915 | break; | 915 | break; |
916 | }; | 916 | }; |
917 | } | 917 | } |
918 | 918 | ||
919 | void PlayListWidget::populateAudioView() { | 919 | void PlayListWidget::populateAudioView() { |
920 | // if(files) | 920 | // if(files) |
921 | // files.~DocLnkSet(); | 921 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | 922 | StorageInfo storageInfo; |
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
924 | 924 | ||
925 | Global::findDocuments(&files, "audio/*"); | 925 | Global::findDocuments(&files, "audio/*"); |
926 | QListIterator<DocLnk> dit( files.children() ); | 926 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | 927 | QListIterator<FileSystem> it ( fs ); |
928 | audioView->clear(); | 928 | audioView->clear(); |
929 | QString storage; | 929 | QString storage; |
930 | for ( ; dit.current(); ++dit ) { | 930 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | 931 | for( ; it.current(); ++it ){ |
932 | const QString name = (*it)->name(); | 932 | const QString name = (*it)->name(); |
933 | const QString path = (*it)->path(); | 933 | const QString path = (*it)->path(); |
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | 934 | if(dit.current()->file().find(path) != -1 ) storage=name; |
935 | } | 935 | } |
936 | 936 | ||
937 | QListViewItem * newItem; | 937 | QListViewItem * newItem; |
938 | if ( QFile( dit.current()->file()).exists() ) { | 938 | if ( QFile( dit.current()->file()).exists() ) { |
939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
941 | } | 941 | } |
942 | } | 942 | } |
943 | } | 943 | } |
944 | 944 | ||
945 | void PlayListWidget::populateVideoView() { | 945 | void PlayListWidget::populateVideoView() { |
946 | StorageInfo storageInfo; | 946 | StorageInfo storageInfo; |
947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
948 | 948 | ||
949 | Global::findDocuments(&vFiles, "video/*"); | 949 | Global::findDocuments(&vFiles, "video/*"); |
950 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 950 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
951 | QListIterator<FileSystem> it ( fs ); | 951 | QListIterator<FileSystem> it ( fs ); |
952 | videoView->clear(); | 952 | videoView->clear(); |
953 | QString storage; | 953 | QString storage; |
954 | for ( ; Vdit.current(); ++Vdit ) { | 954 | for ( ; Vdit.current(); ++Vdit ) { |
955 | for( ; it.current(); ++it ){ | 955 | for( ; it.current(); ++it ){ |
956 | const QString name = (*it)->name(); | 956 | const QString name = (*it)->name(); |
957 | const QString path = (*it)->path(); | 957 | const QString path = (*it)->path(); |
958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
959 | } | 959 | } |
960 | 960 | ||
961 | QListViewItem * newItem; | 961 | QListViewItem * newItem; |
962 | if ( QFile( Vdit.current()->file()).exists() ) { | 962 | if ( QFile( Vdit.current()->file()).exists() ) { |
963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | } | 967 | } |