-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 9373f6b..cd53748 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1217 +1,1212 @@ | |||
1 | 1 | ||
2 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 2 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
3 | #define QTOPIA_INTERNAL_FSLP | 3 | #define QTOPIA_INTERNAL_FSLP |
4 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
5 | 5 | ||
6 | #include <qpe/qpemenubar.h> | 6 | #include <qpe/qpemenubar.h> |
7 | #include <qpe/qpetoolbar.h> | 7 | #include <qpe/qpetoolbar.h> |
8 | #include <qpe/fileselector.h> | 8 | #include <qpe/fileselector.h> |
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/lnkproperties.h> | 10 | #include <qpe/lnkproperties.h> |
11 | #include <qpe/storage.h> | 11 | #include <qpe/storage.h> |
12 | 12 | ||
13 | #include <qpe/applnk.h> | 13 | #include <qpe/applnk.h> |
14 | #include <qpe/config.h> | 14 | #include <qpe/config.h> |
15 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qcursor.h> | 18 | #include <qcursor.h> |
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlist.h> | 24 | #include <qlist.h> |
25 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qlistview.h> | 30 | #include <qlistview.h> |
31 | #include <qpoint.h> | 31 | #include <qpoint.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | 37 | ||
38 | #include "playlistselection.h" | 38 | #include "playlistselection.h" |
39 | #include "playlistwidget.h" | 39 | #include "playlistwidget.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | #include "inputDialog.h" | 42 | #include "inputDialog.h" |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include "audiowidget.h" | 45 | #include "audiowidget.h" |
46 | #include "videowidget.h" | 46 | #include "videowidget.h" |
47 | 47 | ||
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | #include <sys/file.h> | 49 | #include <sys/file.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/soundcard.h> | 51 | #include <sys/soundcard.h> |
52 | 52 | ||
53 | // for setBacklight() | 53 | // for setBacklight() |
54 | #include <linux/fb.h> | 54 | #include <linux/fb.h> |
55 | #include <sys/types.h> | 55 | #include <sys/types.h> |
56 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | #define BUTTONS_ON_TOOLBAR | 59 | #define BUTTONS_ON_TOOLBAR |
60 | #define SIDE_BUTTONS | 60 | #define SIDE_BUTTONS |
61 | #define CAN_SAVE_LOAD_PLAYLISTS | 61 | #define CAN_SAVE_LOAD_PLAYLISTS |
62 | 62 | ||
63 | extern MediaPlayerState *mediaPlayerState; | 63 | extern MediaPlayerState *mediaPlayerState; |
64 | 64 | ||
65 | 65 | ||
66 | class PlayListWidgetPrivate { | 66 | class PlayListWidgetPrivate { |
67 | public: | 67 | public: |
68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
69 | QFrame *playListFrame; | 69 | QFrame *playListFrame; |
70 | FileSelector *files; | 70 | FileSelector *files; |
71 | PlayListSelection *selectedFiles; | 71 | PlayListSelection *selectedFiles; |
72 | bool setDocumentUsed; | 72 | bool setDocumentUsed; |
73 | DocLnk *current; | 73 | DocLnk *current; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | class ToolButton : public QToolButton { | 77 | class ToolButton : public QToolButton { |
78 | public: | 78 | public: |
79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
80 | : QToolButton( parent, name ) { | 80 | : QToolButton( parent, name ) { |
81 | setTextLabel( name ); | 81 | setTextLabel( name ); |
82 | setPixmap( Resource::loadPixmap( icon ) ); | 82 | setPixmap( Resource::loadPixmap( icon ) ); |
83 | setAutoRaise( TRUE ); | 83 | setAutoRaise( TRUE ); |
84 | setFocusPolicy( QWidget::NoFocus ); | 84 | setFocusPolicy( QWidget::NoFocus ); |
85 | setToggleButton( t ); | 85 | setToggleButton( t ); |
86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
87 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 87 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
88 | } | 88 | } |
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | class MenuItem : public QAction { | 92 | class MenuItem : public QAction { |
93 | public: | 93 | public: |
94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
95 | : QAction( text, QString::null, 0, 0 ) { | 95 | : QAction( text, QString::null, 0, 0 ) { |
96 | connect( this, SIGNAL( activated() ), handler, slot ); | 96 | connect( this, SIGNAL( activated() ), handler, slot ); |
97 | addTo( parent ); | 97 | addTo( parent ); |
98 | } | 98 | } |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
103 | : QMainWindow( parent, name, fl ) { | 103 | : QMainWindow( parent, name, fl ) { |
104 | 104 | ||
105 | d = new PlayListWidgetPrivate; | 105 | d = new PlayListWidgetPrivate; |
106 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
107 | d->current = NULL; | 107 | d->current = NULL; |
108 | fromSetDocument = FALSE; | 108 | fromSetDocument = FALSE; |
109 | insanityBool=FALSE; | 109 | insanityBool=FALSE; |
110 | audioScan = FALSE; | 110 | audioScan = FALSE; |
111 | videoScan = FALSE; | 111 | videoScan = FALSE; |
112 | 112 | ||
113 | setBackgroundMode( PaletteButton ); | 113 | setBackgroundMode( PaletteButton ); |
114 | 114 | ||
115 | setCaption( tr("OpiePlayer") ); | 115 | setCaption( tr("OpiePlayer") ); |
116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
117 | 117 | ||
118 | setToolBarsMovable( FALSE ); | 118 | setToolBarsMovable( FALSE ); |
119 | 119 | ||
120 | // Create Toolbar | 120 | // Create Toolbar |
121 | QPEToolBar *toolbar = new QPEToolBar( this ); | 121 | QPEToolBar *toolbar = new QPEToolBar( this ); |
122 | toolbar->setHorizontalStretchable( TRUE ); | 122 | toolbar->setHorizontalStretchable( TRUE ); |
123 | 123 | ||
124 | // Create Menubar | 124 | // Create Menubar |
125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
126 | menu->setMargin( 0 ); | 126 | menu->setMargin( 0 ); |
127 | 127 | ||
128 | QPEToolBar *bar = new QPEToolBar( this ); | 128 | QPEToolBar *bar = new QPEToolBar( this ); |
129 | bar->setLabel( tr( "Play Operations" ) ); | 129 | bar->setLabel( tr( "Play Operations" ) ); |
130 | 130 | ||
131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
132 | tbDeletePlaylist->setFlat(TRUE); | 132 | tbDeletePlaylist->setFlat(TRUE); |
133 | tbDeletePlaylist->setFixedSize(20,20); | 133 | tbDeletePlaylist->setFixedSize(20,20); |
134 | 134 | ||
135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
136 | this , SLOT(addSelected()) ); | 136 | this , SLOT(addSelected()) ); |
137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
138 | this , SLOT(removeSelected()) ); | 138 | this , SLOT(removeSelected()) ); |
139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
140 | this , SLOT( btnPlay(bool) ), TRUE ); | 140 | this , SLOT( btnPlay(bool) ), TRUE ); |
141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
145 | tbDeletePlaylist->hide(); | 145 | tbDeletePlaylist->hide(); |
146 | 146 | ||
147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
148 | menu->insertItem( tr( "File" ), pmPlayList ); | 148 | menu->insertItem( tr( "File" ), pmPlayList ); |
149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
153 | pmPlayList->insertSeparator(-1); | 153 | pmPlayList->insertSeparator(-1); |
154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
156 | pmPlayList->insertSeparator(-1); | 156 | pmPlayList->insertSeparator(-1); |
157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
158 | pmPlayList->insertSeparator(-1); | 158 | pmPlayList->insertSeparator(-1); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
161 | 161 | ||
162 | QPopupMenu *pmView = new QPopupMenu( this ); | 162 | QPopupMenu *pmView = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "View" ), pmView ); | 163 | menu->insertItem( tr( "View" ), pmView ); |
164 | 164 | ||
165 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 165 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
166 | fullScreenButton->addTo(pmView); | 166 | fullScreenButton->addTo(pmView); |
167 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 167 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
168 | scaleButton->addTo(pmView); | 168 | scaleButton->addTo(pmView); |
169 | 169 | ||
170 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 170 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
171 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 171 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
172 | 172 | ||
173 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 173 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
174 | 174 | ||
175 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 175 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
176 | tabWidget->setTabShape(QTabWidget::Triangular); | 176 | tabWidget->setTabShape(QTabWidget::Triangular); |
177 | 177 | ||
178 | QWidget *pTab; | 178 | QWidget *pTab; |
179 | pTab = new QWidget( tabWidget, "pTab" ); | 179 | pTab = new QWidget( tabWidget, "pTab" ); |
180 | tabWidget->insertTab( pTab,"Playlist"); | 180 | tabWidget->insertTab( pTab,"Playlist"); |
181 | 181 | ||
182 | 182 | ||
183 | // Add the playlist area | 183 | // Add the playlist area |
184 | 184 | ||
185 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 185 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
186 | d->playListFrame = vbox3; | 186 | d->playListFrame = vbox3; |
187 | d->playListFrame ->setMinimumSize(235,260); | 187 | d->playListFrame ->setMinimumSize(235,260); |
188 | 188 | ||
189 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 189 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
190 | 190 | ||
191 | d->selectedFiles = new PlayListSelection( hbox2); | 191 | d->selectedFiles = new PlayListSelection( hbox2); |
192 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
193 | 193 | ||
194 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 194 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
195 | 195 | ||
196 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 196 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
197 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 197 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
198 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 198 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
199 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 199 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
200 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 200 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
201 | 201 | ||
202 | QWidget *aTab; | 202 | QWidget *aTab; |
203 | aTab = new QWidget( tabWidget, "aTab" ); | 203 | aTab = new QWidget( tabWidget, "aTab" ); |
204 | audioView = new QListView( aTab, "Audioview" ); | 204 | audioView = new QListView( aTab, "Audioview" ); |
205 | audioView->setMinimumSize(233,260); | 205 | audioView->setMinimumSize(233,260); |
206 | audioView->addColumn( tr("Title"),140); | 206 | audioView->addColumn( tr("Title"),140); |
207 | audioView->addColumn(tr("Size"), -1); | 207 | audioView->addColumn(tr("Size"), -1); |
208 | audioView->addColumn(tr("Media"),-1); | 208 | audioView->addColumn(tr("Media"),-1); |
209 | audioView->setColumnAlignment(1, Qt::AlignRight); | 209 | audioView->setColumnAlignment(1, Qt::AlignRight); |
210 | audioView->setColumnAlignment(2, Qt::AlignRight); | 210 | audioView->setColumnAlignment(2, Qt::AlignRight); |
211 | audioView->setAllColumnsShowFocus(TRUE); | 211 | audioView->setAllColumnsShowFocus(TRUE); |
212 | 212 | ||
213 | audioView->setMultiSelection( TRUE ); | 213 | audioView->setMultiSelection( TRUE ); |
214 | audioView->setSelectionMode( QListView::Extended); | 214 | audioView->setSelectionMode( QListView::Extended); |
215 | 215 | ||
216 | tabWidget->insertTab(aTab,tr("Audio")); | 216 | tabWidget->insertTab(aTab,tr("Audio")); |
217 | 217 | ||
218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
219 | 219 | ||
220 | QWidget *vTab; | 220 | QWidget *vTab; |
221 | vTab = new QWidget( tabWidget, "vTab" ); | 221 | vTab = new QWidget( tabWidget, "vTab" ); |
222 | videoView = new QListView( vTab, "Videoview" ); | 222 | videoView = new QListView( vTab, "Videoview" ); |
223 | videoView->setMinimumSize(233,260); | 223 | videoView->setMinimumSize(233,260); |
224 | 224 | ||
225 | videoView->addColumn(tr("Title"),140); | 225 | videoView->addColumn(tr("Title"),140); |
226 | videoView->addColumn(tr("Size"),-1); | 226 | videoView->addColumn(tr("Size"),-1); |
227 | videoView->addColumn(tr("Media"),-1); | 227 | videoView->addColumn(tr("Media"),-1); |
228 | videoView->setColumnAlignment(1, Qt::AlignRight); | 228 | videoView->setColumnAlignment(1, Qt::AlignRight); |
229 | videoView->setColumnAlignment(2, Qt::AlignRight); | 229 | videoView->setColumnAlignment(2, Qt::AlignRight); |
230 | videoView->setAllColumnsShowFocus(TRUE); | 230 | videoView->setAllColumnsShowFocus(TRUE); |
231 | videoView->setMultiSelection( TRUE ); | 231 | videoView->setMultiSelection( TRUE ); |
232 | videoView->setSelectionMode( QListView::Extended); | 232 | videoView->setSelectionMode( QListView::Extended); |
233 | 233 | ||
234 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 234 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
235 | 235 | ||
236 | tabWidget->insertTab( vTab,tr("Video")); | 236 | tabWidget->insertTab( vTab,tr("Video")); |
237 | 237 | ||
238 | //playlists list | 238 | //playlists list |
239 | QWidget *LTab; | 239 | QWidget *LTab; |
240 | LTab = new QWidget( tabWidget, "LTab" ); | 240 | LTab = new QWidget( tabWidget, "LTab" ); |
241 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 241 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
242 | playLists->setMinimumSize(233,260); | 242 | playLists->setMinimumSize(233,260); |
243 | tabWidget->insertTab(LTab,tr("Lists")); | 243 | tabWidget->insertTab(LTab,tr("Lists")); |
244 | 244 | ||
245 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 245 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
246 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 246 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
247 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 247 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
248 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 248 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
249 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 249 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
250 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 250 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
251 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 251 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
252 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 252 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
253 | this,SLOT( playIt( QListViewItem *)) ); | 253 | this,SLOT( playIt( QListViewItem *)) ); |
254 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 254 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
255 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 255 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
256 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 256 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
257 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 257 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
258 | this,SLOT( playIt( QListViewItem *)) ); | 258 | this,SLOT( playIt( QListViewItem *)) ); |
259 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 259 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
260 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 260 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
261 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 261 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
262 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 262 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
263 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 263 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
264 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 264 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
265 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 265 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
266 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 266 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
267 | 267 | ||
268 | setCentralWidget( vbox5 ); | 268 | setCentralWidget( vbox5 ); |
269 | 269 | ||
270 | Config cfg( "OpiePlayer" ); | 270 | Config cfg( "OpiePlayer" ); |
271 | readConfig( cfg ); | 271 | readConfig( cfg ); |
272 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 272 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
273 | loadList(DocLnk( currentPlaylist)); | 273 | loadList(DocLnk( currentPlaylist)); |
274 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 274 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
275 | 275 | ||
276 | initializeStates(); | 276 | initializeStates(); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | PlayListWidget::~PlayListWidget() { | 280 | PlayListWidget::~PlayListWidget() { |
281 | Config cfg( "OpiePlayer" ); | 281 | Config cfg( "OpiePlayer" ); |
282 | writeConfig( cfg ); | 282 | writeConfig( cfg ); |
283 | 283 | ||
284 | if ( d->current ) { | 284 | if ( d->current ) { |
285 | delete d->current; | 285 | delete d->current; |
286 | } | 286 | } |
287 | delete d; | 287 | delete d; |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void PlayListWidget::initializeStates() { | 291 | void PlayListWidget::initializeStates() { |
292 | 292 | ||
293 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 293 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
294 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 294 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
295 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 295 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
296 | setPlaylist( true); | 296 | setPlaylist( true); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void PlayListWidget::readConfig( Config& cfg ) { | 300 | void PlayListWidget::readConfig( Config& cfg ) { |
301 | cfg.setGroup("PlayList"); | 301 | cfg.setGroup("PlayList"); |
302 | QString currentString = cfg.readEntry("current", "" ); | 302 | QString currentString = cfg.readEntry("current", "" ); |
303 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 303 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
304 | for ( int i = 0; i < noOfFiles; i++ ) { | 304 | for ( int i = 0; i < noOfFiles; i++ ) { |
305 | QString entryName; | 305 | QString entryName; |
306 | entryName.sprintf( "File%i", i + 1 ); | 306 | entryName.sprintf( "File%i", i + 1 ); |
307 | QString linkFile = cfg.readEntry( entryName ); | 307 | QString linkFile = cfg.readEntry( entryName ); |
308 | DocLnk lnk( linkFile ); | 308 | DocLnk lnk( linkFile ); |
309 | if ( lnk.isValid() ) { | 309 | if ( lnk.isValid() ) { |
310 | d->selectedFiles->addToSelection( lnk ); | 310 | d->selectedFiles->addToSelection( lnk ); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | d->selectedFiles->setSelectedItem( currentString); | 313 | d->selectedFiles->setSelectedItem( currentString); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void PlayListWidget::writeConfig( Config& cfg ) const { | 317 | void PlayListWidget::writeConfig( Config& cfg ) const { |
318 | 318 | ||
319 | d->selectedFiles->writeCurrent( cfg); | 319 | d->selectedFiles->writeCurrent( cfg); |
320 | cfg.setGroup("PlayList"); | 320 | cfg.setGroup("PlayList"); |
321 | int noOfFiles = 0; | 321 | int noOfFiles = 0; |
322 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
323 | do { | 323 | do { |
324 | const DocLnk *lnk = d->selectedFiles->current(); | 324 | const DocLnk *lnk = d->selectedFiles->current(); |
325 | if ( lnk ) { | 325 | if ( lnk ) { |
326 | QString entryName; | 326 | QString entryName; |
327 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 327 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
328 | cfg.writeEntry( entryName, lnk->linkFile() ); | 328 | cfg.writeEntry( entryName, lnk->linkFile() ); |
329 | // if this link does exist, add it so we have the file | 329 | // if this link does exist, add it so we have the file |
330 | // next time... | 330 | // next time... |
331 | if ( !QFile::exists( lnk->linkFile() ) ) { | 331 | if ( !QFile::exists( lnk->linkFile() ) ) { |
332 | // the way writing lnks doesn't really check for out | 332 | // the way writing lnks doesn't really check for out |
333 | // of disk space, but check it anyway. | 333 | // of disk space, but check it anyway. |
334 | if ( !lnk->writeLink() ) { | 334 | if ( !lnk->writeLink() ) { |
335 | QMessageBox::critical( 0, tr("Out of space"), | 335 | QMessageBox::critical( 0, tr("Out of space"), |
336 | tr( "There was a problem saving " | 336 | tr( "There was a problem saving " |
337 | "the playlist.\n" | 337 | "the playlist.\n" |
338 | "Your playlist " | 338 | "Your playlist " |
339 | "may be missing some entries\n" | 339 | "may be missing some entries\n" |
340 | "the next time you start it." ) | 340 | "the next time you start it." ) |
341 | ); | 341 | ); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | noOfFiles++; | 344 | noOfFiles++; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | while ( d->selectedFiles->next() ); | 347 | while ( d->selectedFiles->next() ); |
348 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 348 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 352 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
353 | d->setDocumentUsed = FALSE; | 353 | d->setDocumentUsed = FALSE; |
354 | if ( mediaPlayerState->playlist() ) { | 354 | if ( mediaPlayerState->playlist() ) { |
355 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 355 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
356 | d->selectedFiles->addToSelection( lnk ); | 356 | d->selectedFiles->addToSelection( lnk ); |
357 | } | 357 | } |
358 | else | 358 | else |
359 | mediaPlayerState->setPlaying( TRUE ); | 359 | mediaPlayerState->setPlaying( TRUE ); |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void PlayListWidget::clearList() { | 363 | void PlayListWidget::clearList() { |
364 | while ( first() ) { | 364 | while ( first() ) { |
365 | d->selectedFiles->removeSelected(); | 365 | d->selectedFiles->removeSelected(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void PlayListWidget::addAllToList() { | 370 | void PlayListWidget::addAllToList() { |
371 | DocLnkSet filesAll; | 371 | DocLnkSet filesAll; |
372 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 372 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
373 | QListIterator<DocLnk> Adit( filesAll.children() ); | 373 | QListIterator<DocLnk> Adit( filesAll.children() ); |
374 | for ( ; Adit.current(); ++Adit ) { | 374 | for ( ; Adit.current(); ++Adit ) { |
375 | if(QFileInfo(Adit.current()->file()).exists()) { | 375 | if(QFileInfo(Adit.current()->file()).exists()) { |
376 | d->selectedFiles->addToSelection( **Adit ); | 376 | d->selectedFiles->addToSelection( **Adit ); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | void PlayListWidget::addAllMusicToList() { | 382 | void PlayListWidget::addAllMusicToList() { |
383 | QListIterator<DocLnk> dit( files.children() ); | 383 | QListIterator<DocLnk> dit( files.children() ); |
384 | for ( ; dit.current(); ++dit ) { | 384 | for ( ; dit.current(); ++dit ) { |
385 | if(QFileInfo(dit.current()->file()).exists()) { | 385 | if(QFileInfo(dit.current()->file()).exists()) { |
386 | d->selectedFiles->addToSelection( **dit ); | 386 | d->selectedFiles->addToSelection( **dit ); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | void PlayListWidget::addAllVideoToList() { | 392 | void PlayListWidget::addAllVideoToList() { |
393 | QListIterator<DocLnk> dit( vFiles.children() ); | 393 | QListIterator<DocLnk> dit( vFiles.children() ); |
394 | for ( ; dit.current(); ++dit ) | 394 | for ( ; dit.current(); ++dit ) |
395 | if(QFileInfo( dit.current()->file()).exists()) | 395 | if(QFileInfo( dit.current()->file()).exists()) |
396 | d->selectedFiles->addToSelection( **dit ); | 396 | d->selectedFiles->addToSelection( **dit ); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | void PlayListWidget::setDocument(const QString& fileref) { | 400 | void PlayListWidget::setDocument(const QString& fileref) { |
401 | qDebug(fileref); | 401 | qDebug(fileref); |
402 | fromSetDocument = TRUE; | 402 | fromSetDocument = TRUE; |
403 | if ( fileref.isNull() ) { | 403 | if ( fileref.isNull() ) { |
404 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 404 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | 407 | ||
408 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 408 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
409 | readm3u( fileref); | 409 | readm3u( fileref); |
410 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 410 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
411 | readPls( fileref); | 411 | readPls( fileref); |
412 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 412 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
413 | clearList(); | 413 | clearList(); |
414 | loadList(DocLnk(fileref)); | 414 | loadList(DocLnk(fileref)); |
415 | d->selectedFiles->first(); | 415 | d->selectedFiles->first(); |
416 | } else { | 416 | } else { |
417 | clearList(); | 417 | clearList(); |
418 | addToSelection( DocLnk( fileref ) ); | 418 | addToSelection( DocLnk( fileref ) ); |
419 | d->setDocumentUsed = TRUE; | 419 | d->setDocumentUsed = TRUE; |
420 | mediaPlayerState->setPlaying( FALSE ); | 420 | mediaPlayerState->setPlaying( FALSE ); |
421 | qApp->processEvents(); | 421 | qApp->processEvents(); |
422 | mediaPlayerState->setPlaying( TRUE ); | 422 | mediaPlayerState->setPlaying( TRUE ); |
423 | qApp->processEvents(); | 423 | qApp->processEvents(); |
424 | setCaption(tr("OpiePlayer")); | 424 | setCaption(tr("OpiePlayer")); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | void PlayListWidget::setActiveWindow() { | 429 | void PlayListWidget::setActiveWindow() { |
430 | // When we get raised we need to ensure that it switches views | 430 | // When we get raised we need to ensure that it switches views |
431 | char origView = mediaPlayerState->view(); | 431 | char origView = mediaPlayerState->view(); |
432 | mediaPlayerState->setView( 'l' ); // invalidate | 432 | mediaPlayerState->setView( 'l' ); // invalidate |
433 | mediaPlayerState->setView( origView ); // now switch back | 433 | mediaPlayerState->setView( origView ); // now switch back |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void PlayListWidget::useSelectedDocument() { | 437 | void PlayListWidget::useSelectedDocument() { |
438 | d->setDocumentUsed = FALSE; | 438 | d->setDocumentUsed = FALSE; |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | const DocLnk *PlayListWidget::current() { // this is fugly | 442 | const DocLnk *PlayListWidget::current() { // this is fugly |
443 | 443 | ||
444 | switch (tabWidget->currentPageIndex()) { | 444 | switch (tabWidget->currentPageIndex()) { |
445 | case 0: //playlist | 445 | case 0: //playlist |
446 | { | 446 | { |
447 | qDebug("playlist"); | 447 | qDebug("playlist"); |
448 | if ( mediaPlayerState->playlist() ) { | 448 | if ( mediaPlayerState->playlist() ) { |
449 | return d->selectedFiles->current(); | 449 | return d->selectedFiles->current(); |
450 | } else if ( d->setDocumentUsed && d->current ) { | 450 | } else if ( d->setDocumentUsed && d->current ) { |
451 | return d->current; | 451 | return d->current; |
452 | } else { | 452 | } else { |
453 | return d->files->selected(); | 453 | return d->files->selected(); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | break; | 456 | break; |
457 | case 1://audio | 457 | case 1://audio |
458 | { | 458 | { |
459 | qDebug("audioView"); | 459 | qDebug("audioView"); |
460 | QListIterator<DocLnk> dit( files.children() ); | 460 | QListIterator<DocLnk> dit( files.children() ); |
461 | for ( ; dit.current(); ++dit ) { | 461 | for ( ; dit.current(); ++dit ) { |
462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 462 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
463 | qDebug("here"); | 463 | qDebug("here"); |
464 | insanityBool=TRUE; | 464 | insanityBool=TRUE; |
465 | return dit; | 465 | return dit; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } | 468 | } |
469 | break; | 469 | break; |
470 | case 2: // video | 470 | case 2: // video |
471 | { | 471 | { |
472 | qDebug("videoView"); | 472 | qDebug("videoView"); |
473 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 473 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
474 | for ( ; Vdit.current(); ++Vdit ) { | 474 | for ( ; Vdit.current(); ++Vdit ) { |
475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 475 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
476 | insanityBool=TRUE; | 476 | insanityBool=TRUE; |
477 | return Vdit; | 477 | return Vdit; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | }; | 482 | }; |
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
485 | 485 | ||
486 | bool PlayListWidget::prev() { | 486 | bool PlayListWidget::prev() { |
487 | if ( mediaPlayerState->playlist() ) { | 487 | if ( mediaPlayerState->playlist() ) { |
488 | if ( mediaPlayerState->shuffled() ) { | 488 | if ( mediaPlayerState->shuffled() ) { |
489 | const DocLnk *cur = current(); | 489 | const DocLnk *cur = current(); |
490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 490 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
491 | for ( int i = 0; i < j; i++ ) { | 491 | for ( int i = 0; i < j; i++ ) { |
492 | if ( !d->selectedFiles->next() ) | 492 | if ( !d->selectedFiles->next() ) |
493 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
494 | } | 494 | } |
495 | if ( cur == current() ) | 495 | if ( cur == current() ) |
496 | if ( !d->selectedFiles->next() ) | 496 | if ( !d->selectedFiles->next() ) |
497 | d->selectedFiles->first(); | 497 | d->selectedFiles->first(); |
498 | return TRUE; | 498 | return TRUE; |
499 | } else { | 499 | } else { |
500 | if ( !d->selectedFiles->prev() ) { | 500 | if ( !d->selectedFiles->prev() ) { |
501 | if ( mediaPlayerState->looping() ) { | 501 | if ( mediaPlayerState->looping() ) { |
502 | return d->selectedFiles->last(); | 502 | return d->selectedFiles->last(); |
503 | } else { | 503 | } else { |
504 | return FALSE; | 504 | return FALSE; |
505 | } | 505 | } |
506 | } | 506 | } |
507 | return TRUE; | 507 | return TRUE; |
508 | } | 508 | } |
509 | } else { | 509 | } else { |
510 | return mediaPlayerState->looping(); | 510 | return mediaPlayerState->looping(); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | bool PlayListWidget::next() { | 515 | bool PlayListWidget::next() { |
516 | if ( mediaPlayerState->playlist() ) { | 516 | if ( mediaPlayerState->playlist() ) { |
517 | if ( mediaPlayerState->shuffled() ) { | 517 | if ( mediaPlayerState->shuffled() ) { |
518 | return prev(); | 518 | return prev(); |
519 | } else { | 519 | } else { |
520 | if ( !d->selectedFiles->next() ) { | 520 | if ( !d->selectedFiles->next() ) { |
521 | if ( mediaPlayerState->looping() ) { | 521 | if ( mediaPlayerState->looping() ) { |
522 | return d->selectedFiles->first(); | 522 | return d->selectedFiles->first(); |
523 | } else { | 523 | } else { |
524 | return FALSE; | 524 | return FALSE; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | return TRUE; | 527 | return TRUE; |
528 | } | 528 | } |
529 | } else { | 529 | } else { |
530 | return mediaPlayerState->looping(); | 530 | return mediaPlayerState->looping(); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | bool PlayListWidget::first() { | 535 | bool PlayListWidget::first() { |
536 | if ( mediaPlayerState->playlist() ) | 536 | if ( mediaPlayerState->playlist() ) |
537 | return d->selectedFiles->first(); | 537 | return d->selectedFiles->first(); |
538 | else | 538 | else |
539 | return mediaPlayerState->looping(); | 539 | return mediaPlayerState->looping(); |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | bool PlayListWidget::last() { | 543 | bool PlayListWidget::last() { |
544 | if ( mediaPlayerState->playlist() ) | 544 | if ( mediaPlayerState->playlist() ) |
545 | return d->selectedFiles->last(); | 545 | return d->selectedFiles->last(); |
546 | else | 546 | else |
547 | return mediaPlayerState->looping(); | 547 | return mediaPlayerState->looping(); |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | void PlayListWidget::saveList() { | 551 | void PlayListWidget::saveList() { |
552 | 552 | ||
553 | QString filename; | 553 | QString filename; |
554 | InputDialog *fileDlg; | 554 | InputDialog *fileDlg; |
555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 555 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
556 | fileDlg->exec(); | 556 | fileDlg->exec(); |
557 | if( fileDlg->result() == 1 ) { | 557 | if( fileDlg->result() == 1 ) { |
558 | if ( d->current ) | 558 | if ( d->current ) |
559 | delete d->current; | 559 | delete d->current; |
560 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 560 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
561 | // qDebug("saving playlist "+filename+".playlist"); | 561 | // qDebug("saving playlist "+filename+".playlist"); |
562 | Config cfg( filename +".playlist"); | 562 | Config cfg( filename +".playlist"); |
563 | writeConfig( cfg ); | 563 | writeConfig( cfg ); |
564 | 564 | ||
565 | DocLnk lnk; | 565 | DocLnk lnk; |
566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
568 | lnk.setIcon("opieplayer/playlist2"); | 568 | lnk.setIcon("opieplayer/playlist2"); |
569 | lnk.setName( filename); //sets file name | 569 | lnk.setName( filename); //sets file name |
570 | // qDebug(filename); | 570 | // qDebug(filename); |
571 | if(!lnk.writeLink()) { | 571 | if(!lnk.writeLink()) { |
572 | qDebug("Writing doclink did not work"); | 572 | qDebug("Writing doclink did not work"); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | Config config( "OpiePlayer" ); | 575 | Config config( "OpiePlayer" ); |
576 | config.writeEntry("CurrentPlaylist",filename); | 576 | config.writeEntry("CurrentPlaylist",filename); |
577 | setCaption(tr("OpiePlayer: ")+filename); | 577 | setCaption(tr("OpiePlayer: ")+filename); |
578 | d->selectedFiles->first(); | 578 | d->selectedFiles->first(); |
579 | if(fileDlg) { | 579 | if(fileDlg) { |
580 | delete fileDlg; | 580 | delete fileDlg; |
581 | } | 581 | } |
582 | } | 582 | } |
583 | 583 | ||
584 | void PlayListWidget::loadList( const DocLnk & lnk) { | 584 | void PlayListWidget::loadList( const DocLnk & lnk) { |
585 | QString name= lnk.name(); | 585 | QString name= lnk.name(); |
586 | // qDebug("currentList is "+name); | 586 | // qDebug("currentList is "+name); |
587 | if( name.length()>1) { | 587 | if( name.length()>1) { |
588 | setCaption("OpiePlayer: "+name); | 588 | setCaption("OpiePlayer: "+name); |
589 | // qDebug("load list "+ name+".playlist"); | 589 | // qDebug("load list "+ name+".playlist"); |
590 | clearList(); | 590 | clearList(); |
591 | Config cfg( name+".playlist"); | 591 | Config cfg( name+".playlist"); |
592 | readConfig(cfg); | 592 | readConfig(cfg); |
593 | 593 | ||
594 | tabWidget->setCurrentPage(0); | 594 | tabWidget->setCurrentPage(0); |
595 | 595 | ||
596 | Config config( "OpiePlayer" ); | 596 | Config config( "OpiePlayer" ); |
597 | config.writeEntry("CurrentPlaylist", name); | 597 | config.writeEntry("CurrentPlaylist", name); |
598 | // d->selectedFiles->first(); | 598 | // d->selectedFiles->first(); |
599 | } | 599 | } |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void PlayListWidget::setPlaylist( bool shown ) { | 603 | void PlayListWidget::setPlaylist( bool shown ) { |
604 | if ( shown ) { | 604 | if ( shown ) { |
605 | d->playListFrame->show(); | 605 | d->playListFrame->show(); |
606 | } else { | 606 | } else { |
607 | d->playListFrame->hide(); | 607 | d->playListFrame->hide(); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
611 | void PlayListWidget::setView( char view ) { | 611 | void PlayListWidget::setView( char view ) { |
612 | if ( view == 'l' ) | 612 | if ( view == 'l' ) |
613 | showMaximized(); | 613 | showMaximized(); |
614 | else | 614 | else |
615 | hide(); | 615 | hide(); |
616 | } | 616 | } |
617 | 617 | ||
618 | void PlayListWidget::addSelected() { | 618 | void PlayListWidget::addSelected() { |
619 | 619 | ||
620 | Config cfg( "OpiePlayer" ); | 620 | Config cfg( "OpiePlayer" ); |
621 | cfg.setGroup("PlayList"); | 621 | cfg.setGroup("PlayList"); |
622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
624 | 624 | ||
625 | switch (tabWidget->currentPageIndex()) { | 625 | switch (tabWidget->currentPageIndex()) { |
626 | case 0: //playlist | 626 | case 0: //playlist |
627 | break; | 627 | break; |
628 | case 1: { //audio | 628 | case 1: { //audio |
629 | QListViewItemIterator it( audioView ); | 629 | QListViewItemIterator it( audioView ); |
630 | // iterate through all items of the listview | 630 | // iterate through all items of the listview |
631 | for ( ; it.current(); ++it ) { | 631 | for ( ; it.current(); ++it ) { |
632 | if ( it.current()->isSelected() ) { | 632 | if ( it.current()->isSelected() ) { |
633 | QListIterator<DocLnk> dit( files.children() ); | 633 | QListIterator<DocLnk> dit( files.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 634 | for ( ; dit.current(); ++dit ) { |
635 | if( dit.current()->name() == it.current()->text(0) ) { | 635 | if( dit.current()->name() == it.current()->text(0) ) { |
636 | d->selectedFiles->addToSelection( **dit ); | 636 | d->selectedFiles->addToSelection( **dit ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | audioView->setSelected( it.current(),FALSE); | 639 | audioView->setSelected( it.current(),FALSE); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | tabWidget->setCurrentPage(0); | 642 | tabWidget->setCurrentPage(0); |
643 | } | 643 | } |
644 | break; | 644 | break; |
645 | case 2: { // video | 645 | case 2: { // video |
646 | QListViewItemIterator it( videoView ); | 646 | QListViewItemIterator it( videoView ); |
647 | // iterate through all items of the listview | 647 | // iterate through all items of the listview |
648 | for ( ; it.current(); ++it ) { | 648 | for ( ; it.current(); ++it ) { |
649 | if ( it.current()->isSelected() ) { | 649 | if ( it.current()->isSelected() ) { |
650 | QListIterator<DocLnk> dit( vFiles.children() ); | 650 | QListIterator<DocLnk> dit( vFiles.children() ); |
651 | for ( ; dit.current(); ++dit ) { | 651 | for ( ; dit.current(); ++dit ) { |
652 | if( dit.current()->name() == it.current()->text(0) ) { | 652 | if( dit.current()->name() == it.current()->text(0) ) { |
653 | d->selectedFiles->addToSelection( **dit ); | 653 | d->selectedFiles->addToSelection( **dit ); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | videoView->setSelected( it.current(),FALSE); | 656 | videoView->setSelected( it.current(),FALSE); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | tabWidget->setCurrentPage(0); | 659 | tabWidget->setCurrentPage(0); |
660 | } | 660 | } |
661 | break; | 661 | break; |
662 | }; | 662 | }; |
663 | } | 663 | } |
664 | 664 | ||
665 | void PlayListWidget::removeSelected() { | 665 | void PlayListWidget::removeSelected() { |
666 | d->selectedFiles->removeSelected( ); | 666 | d->selectedFiles->removeSelected( ); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PlayListWidget::playIt( QListViewItem *it) { | 669 | void PlayListWidget::playIt( QListViewItem *it) { |
670 | qDebug("playIt"); | 670 | qDebug("playIt"); |
671 | mediaPlayerState->setPlaying(FALSE); | 671 | mediaPlayerState->setPlaying(FALSE); |
672 | mediaPlayerState->setPlaying(TRUE); | 672 | mediaPlayerState->setPlaying(TRUE); |
673 | d->selectedFiles->unSelect(); | 673 | d->selectedFiles->unSelect(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void PlayListWidget::addToSelection( QListViewItem *it) { | 676 | void PlayListWidget::addToSelection( QListViewItem *it) { |
677 | d->setDocumentUsed = FALSE; | 677 | d->setDocumentUsed = FALSE; |
678 | 678 | ||
679 | if(it) { | 679 | if(it) { |
680 | switch (tabWidget->currentPageIndex()) { | 680 | switch (tabWidget->currentPageIndex()) { |
681 | case 1: { | 681 | case 1: { |
682 | QListIterator<DocLnk> dit( files.children() ); | 682 | QListIterator<DocLnk> dit( files.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 683 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it->text(0)) { | 684 | if( dit.current()->name() == it->text(0)) { |
685 | d->selectedFiles->addToSelection( **dit ); | 685 | d->selectedFiles->addToSelection( **dit ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | break; | 689 | break; |
690 | case 2: { | 690 | case 2: { |
691 | QListIterator<DocLnk> dit( vFiles.children() ); | 691 | QListIterator<DocLnk> dit( vFiles.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 692 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 693 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 694 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | } | 697 | } |
698 | break; | 698 | break; |
699 | case 0: | 699 | case 0: |
700 | break; | 700 | break; |
701 | }; | 701 | }; |
702 | tabWidget->setCurrentPage(0); | 702 | tabWidget->setCurrentPage(0); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::tabChanged(QWidget *widg) { | 706 | void PlayListWidget::tabChanged(QWidget *widg) { |
707 | 707 | ||
708 | switch ( tabWidget->currentPageIndex()) { | 708 | switch ( tabWidget->currentPageIndex()) { |
709 | case 0: | 709 | case 0: |
710 | { | 710 | { |
711 | if( !tbDeletePlaylist->isHidden()) | 711 | if( !tbDeletePlaylist->isHidden()) |
712 | tbDeletePlaylist->hide(); | 712 | tbDeletePlaylist->hide(); |
713 | d->tbRemoveFromList->setEnabled(TRUE); | 713 | d->tbRemoveFromList->setEnabled(TRUE); |
714 | d->tbAddToList->setEnabled(FALSE); | 714 | d->tbAddToList->setEnabled(FALSE); |
715 | } | 715 | } |
716 | break; | 716 | break; |
717 | case 1: | 717 | case 1: |
718 | { | 718 | { |
719 | audioView->clear(); | 719 | audioView->clear(); |
720 | populateAudioView(); | 720 | populateAudioView(); |
721 | 721 | ||
722 | if( !tbDeletePlaylist->isHidden()) | 722 | if( !tbDeletePlaylist->isHidden()) |
723 | tbDeletePlaylist->hide(); | 723 | tbDeletePlaylist->hide(); |
724 | d->tbRemoveFromList->setEnabled(FALSE); | 724 | d->tbRemoveFromList->setEnabled(FALSE); |
725 | d->tbAddToList->setEnabled(TRUE); | 725 | d->tbAddToList->setEnabled(TRUE); |
726 | } | 726 | } |
727 | break; | 727 | break; |
728 | case 2: | 728 | case 2: |
729 | { | 729 | { |
730 | videoView->clear(); | 730 | videoView->clear(); |
731 | populateVideoView(); | 731 | populateVideoView(); |
732 | if( !tbDeletePlaylist->isHidden()) | 732 | if( !tbDeletePlaylist->isHidden()) |
733 | tbDeletePlaylist->hide(); | 733 | tbDeletePlaylist->hide(); |
734 | d->tbRemoveFromList->setEnabled(FALSE); | 734 | d->tbRemoveFromList->setEnabled(FALSE); |
735 | d->tbAddToList->setEnabled(TRUE); | 735 | d->tbAddToList->setEnabled(TRUE); |
736 | } | 736 | } |
737 | break; | 737 | break; |
738 | case 3: | 738 | case 3: |
739 | { | 739 | { |
740 | if( tbDeletePlaylist->isHidden()) | 740 | if( tbDeletePlaylist->isHidden()) |
741 | tbDeletePlaylist->show(); | 741 | tbDeletePlaylist->show(); |
742 | playLists->reread(); | 742 | playLists->reread(); |
743 | } | 743 | } |
744 | break; | 744 | break; |
745 | }; | 745 | }; |
746 | } | 746 | } |
747 | 747 | ||
748 | void PlayListWidget::btnPlay(bool b) { | 748 | void PlayListWidget::btnPlay(bool b) { |
749 | 749 | ||
750 | // mediaPlayerState->setPlaying(b); | 750 | // mediaPlayerState->setPlaying(b); |
751 | switch ( tabWidget->currentPageIndex()) { | 751 | switch ( tabWidget->currentPageIndex()) { |
752 | case 0: | 752 | case 0: |
753 | { | 753 | { |
754 | mediaPlayerState->setPlaying(b); | 754 | mediaPlayerState->setPlaying(b); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | case 1: | 757 | case 1: |
758 | { | 758 | { |
759 | addToSelection( audioView->currentItem() ); | 759 | addToSelection( audioView->currentItem() ); |
760 | mediaPlayerState->setPlaying(b); | 760 | mediaPlayerState->setPlaying(b); |
761 | d->selectedFiles->removeSelected( ); | 761 | d->selectedFiles->removeSelected( ); |
762 | tabWidget->setCurrentPage(1); | 762 | tabWidget->setCurrentPage(1); |
763 | d->selectedFiles->unSelect(); | 763 | d->selectedFiles->unSelect(); |
764 | insanityBool=FALSE; | 764 | insanityBool=FALSE; |
765 | }// audioView->clearSelection(); | 765 | }// audioView->clearSelection(); |
766 | break; | 766 | break; |
767 | case 2: | 767 | case 2: |
768 | { | 768 | { |
769 | addToSelection( videoView->currentItem() ); | 769 | addToSelection( videoView->currentItem() ); |
770 | mediaPlayerState->setPlaying(b); | 770 | mediaPlayerState->setPlaying(b); |
771 | qApp->processEvents(); | 771 | qApp->processEvents(); |
772 | d->selectedFiles->removeSelected( ); | 772 | d->selectedFiles->removeSelected( ); |
773 | tabWidget->setCurrentPage(2); | 773 | tabWidget->setCurrentPage(2); |
774 | d->selectedFiles->unSelect(); | 774 | d->selectedFiles->unSelect(); |
775 | insanityBool=FALSE; | 775 | insanityBool=FALSE; |
776 | }// videoView->clearSelection(); | 776 | }// videoView->clearSelection(); |
777 | break; | 777 | break; |
778 | }; | 778 | }; |
779 | 779 | ||
780 | } | 780 | } |
781 | 781 | ||
782 | void PlayListWidget::deletePlaylist() { | 782 | void PlayListWidget::deletePlaylist() { |
783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
784 | (tr("You really want to delete\nthis playlist?")), | 784 | (tr("You really want to delete\nthis playlist?")), |
785 | (tr("Yes")), (tr("No")), 0 )){ | 785 | (tr("Yes")), (tr("No")), 0 )){ |
786 | case 0: // Yes clicked, | 786 | case 0: // Yes clicked, |
787 | QFile().remove(playLists->selected()->file()); | 787 | QFile().remove(playLists->selected()->file()); |
788 | QFile().remove(playLists->selected()->linkFile()); | 788 | QFile().remove(playLists->selected()->linkFile()); |
789 | playLists->reread(); | 789 | playLists->reread(); |
790 | break; | 790 | break; |
791 | case 1: // Cancel | 791 | case 1: // Cancel |
792 | break; | 792 | break; |
793 | }; | 793 | }; |
794 | } | 794 | } |
795 | 795 | ||
796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
797 | switch (mouse) { | 797 | switch (mouse) { |
798 | case 1: | 798 | case 1: |
799 | break; | 799 | break; |
800 | case 2:{ | 800 | case 2:{ |
801 | QPopupMenu m; | 801 | QPopupMenu m; |
802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
804 | m.insertSeparator(); | 804 | m.insertSeparator(); |
805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
806 | m.exec( QCursor::pos() ); | 806 | m.exec( QCursor::pos() ); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | }; | 809 | }; |
810 | } | 810 | } |
811 | 811 | ||
812 | void PlayListWidget::playSelected() { | 812 | void PlayListWidget::playSelected() { |
813 | btnPlay( TRUE); | 813 | btnPlay( TRUE); |
814 | } | 814 | } |
815 | 815 | ||
816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
817 | switch (mouse) { | 817 | switch (mouse) { |
818 | case 1: | 818 | case 1: |
819 | 819 | ||
820 | break; | 820 | break; |
821 | case 2: | 821 | case 2: |
822 | { | 822 | { |
823 | QPopupMenu m; | 823 | QPopupMenu m; |
824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
826 | m.exec( QCursor::pos() ); | 826 | m.exec( QCursor::pos() ); |
827 | } | 827 | } |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | } | 830 | } |
831 | 831 | ||
832 | void PlayListWidget::listDelete() { | 832 | void PlayListWidget::listDelete() { |
833 | Config cfg( "OpiePlayer" ); | 833 | Config cfg( "OpiePlayer" ); |
834 | cfg.setGroup("PlayList"); | 834 | cfg.setGroup("PlayList"); |
835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
836 | QString file; | 836 | QString file; |
837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
838 | switch ( tabWidget->currentPageIndex()) { | 838 | switch ( tabWidget->currentPageIndex()) { |
839 | case 0: | 839 | case 0: |
840 | break; | 840 | break; |
841 | case 1: | 841 | case 1: |
842 | { | 842 | { |
843 | file = audioView->selectedItem()->text(0); | 843 | file = audioView->selectedItem()->text(0); |
844 | QListIterator<DocLnk> dit( files.children() ); | 844 | QListIterator<DocLnk> dit( files.children() ); |
845 | for ( ; dit.current(); ++dit ) { | 845 | for ( ; dit.current(); ++dit ) { |
846 | if( dit.current()->name() == file) { | 846 | if( dit.current()->name() == file) { |
847 | // qDebug(file); | 847 | // qDebug(file); |
848 | LnkProperties prop( dit.current() ); | 848 | LnkProperties prop( dit.current() ); |
849 | prop.showMaximized(); | 849 | prop.showMaximized(); |
850 | prop.exec(); | 850 | prop.exec(); |
851 | } | 851 | } |
852 | } | 852 | } |
853 | populateAudioView(); | 853 | populateAudioView(); |
854 | } | 854 | } |
855 | break; | 855 | break; |
856 | case 2: | 856 | case 2: |
857 | { | 857 | { |
858 | 858 | ||
859 | } | 859 | } |
860 | break; | 860 | break; |
861 | }; | 861 | }; |
862 | } | 862 | } |
863 | 863 | ||
864 | void PlayListWidget::scanForAudio() { | 864 | void PlayListWidget::scanForAudio() { |
865 | qDebug("scan for audio"); | 865 | qDebug("scan for audio"); |
866 | files.detachChildren(); | 866 | files.detachChildren(); |
867 | QListIterator<DocLnk> sdit( files.children() ); | 867 | QListIterator<DocLnk> sdit( files.children() ); |
868 | for ( ; sdit.current(); ++sdit ) { | 868 | for ( ; sdit.current(); ++sdit ) { |
869 | delete sdit.current(); | 869 | delete sdit.current(); |
870 | } | 870 | } |
871 | Global::findDocuments(&files, "audio/*"); | 871 | Global::findDocuments(&files, "audio/*"); |
872 | audioScan = TRUE; | 872 | audioScan = TRUE; |
873 | } | 873 | } |
874 | void PlayListWidget::scanForVideo() { | 874 | void PlayListWidget::scanForVideo() { |
875 | qDebug("scan for video"); | 875 | qDebug("scan for video"); |
876 | vFiles.detachChildren(); | 876 | vFiles.detachChildren(); |
877 | QListIterator<DocLnk> sdit( vFiles.children() ); | 877 | QListIterator<DocLnk> sdit( vFiles.children() ); |
878 | for ( ; sdit.current(); ++sdit ) { | 878 | for ( ; sdit.current(); ++sdit ) { |
879 | delete sdit.current(); | 879 | delete sdit.current(); |
880 | } | 880 | } |
881 | Global::findDocuments(&vFiles, "video/*"); | 881 | Global::findDocuments(&vFiles, "video/*"); |
882 | videoScan = TRUE; | 882 | videoScan = TRUE; |
883 | } | 883 | } |
884 | 884 | ||
885 | void PlayListWidget::populateAudioView() { | 885 | void PlayListWidget::populateAudioView() { |
886 | 886 | ||
887 | audioView->clear(); | 887 | audioView->clear(); |
888 | StorageInfo storageInfo; | 888 | StorageInfo storageInfo; |
889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
890 | if(!audioScan) scanForAudio(); | 890 | if(!audioScan) scanForAudio(); |
891 | 891 | ||
892 | QListIterator<DocLnk> dit( files.children() ); | 892 | QListIterator<DocLnk> dit( files.children() ); |
893 | QListIterator<FileSystem> it ( fs ); | 893 | QListIterator<FileSystem> it ( fs ); |
894 | 894 | ||
895 | QString storage; | 895 | QString storage; |
896 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
897 | for( ; it.current(); ++it ){ | 897 | for( ; it.current(); ++it ){ |
898 | const QString name = (*it)->name(); | 898 | const QString name = (*it)->name(); |
899 | const QString path = (*it)->path(); | 899 | const QString path = (*it)->path(); |
900 | if(dit.current()->file().find(path) != -1 ) storage=name; | 900 | if(dit.current()->file().find(path) != -1 ) storage=name; |
901 | } | 901 | } |
902 | 902 | ||
903 | QListViewItem * newItem; | 903 | QListViewItem * newItem; |
904 | if ( QFile( dit.current()->file()).exists() ) { | 904 | if ( QFile( dit.current()->file()).exists() ) { |
905 | // qDebug(dit.current()->name()); | 905 | // qDebug(dit.current()->name()); |
906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
907 | QString::number( QFile( dit.current()->file()).size() ), storage); | 907 | QString::number( QFile( dit.current()->file()).size() ), storage); |
908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void PlayListWidget::populateVideoView() { | 914 | void PlayListWidget::populateVideoView() { |
915 | videoView->clear(); | 915 | videoView->clear(); |
916 | StorageInfo storageInfo; | 916 | StorageInfo storageInfo; |
917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
918 | 918 | ||
919 | if(!videoScan ) scanForVideo(); | 919 | if(!videoScan ) scanForVideo(); |
920 | 920 | ||
921 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 921 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
922 | QListIterator<FileSystem> it ( fs ); | 922 | QListIterator<FileSystem> it ( fs ); |
923 | videoView->clear(); | 923 | videoView->clear(); |
924 | QString storage; | 924 | QString storage; |
925 | for ( ; Vdit.current(); ++Vdit ) { | 925 | for ( ; Vdit.current(); ++Vdit ) { |
926 | for( ; it.current(); ++it ){ | 926 | for( ; it.current(); ++it ){ |
927 | const QString name = (*it)->name(); | 927 | const QString name = (*it)->name(); |
928 | const QString path = (*it)->path(); | 928 | const QString path = (*it)->path(); |
929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
930 | } | 930 | } |
931 | 931 | ||
932 | QListViewItem * newItem; | 932 | QListViewItem * newItem; |
933 | if ( QFile( Vdit.current()->file()).exists() ) { | 933 | if ( QFile( Vdit.current()->file()).exists() ) { |
934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | void PlayListWidget::openFile() { | 941 | void PlayListWidget::openFile() { |
942 | QString filename, name; | 942 | QString filename, name; |
943 | InputDialog *fileDlg; | 943 | InputDialog *fileDlg; |
944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
945 | fileDlg->exec(); | 945 | fileDlg->exec(); |
946 | if( fileDlg->result() == 1 ) { | 946 | if( fileDlg->result() == 1 ) { |
947 | filename = fileDlg->LineEdit1->text(); | 947 | filename = fileDlg->LineEdit1->text(); |
948 | 948 | ||
949 | qDebug("Selected filename is "+filename); | 949 | qDebug("Selected filename is "+filename); |
950 | if(filename.right(3) == "m3u") { | 950 | if(filename.right(3) == "m3u") { |
951 | readm3u( filename ); | 951 | readm3u( filename ); |
952 | } else if(filename.right(3) == "pls") { | 952 | } else if(filename.right(3) == "pls") { |
953 | readPls( filename ); | 953 | readPls( filename ); |
954 | } else { | 954 | } else { |
955 | DocLnk lnk; | 955 | DocLnk lnk; |
956 | 956 | ||
957 | lnk.setName(filename); //sets file name | 957 | lnk.setName(filename); //sets file name |
958 | // probably not needed anymore either | ||
959 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") { | ||
960 | filename += "/"; | ||
961 | } | ||
962 | lnk.setFile(filename); //sets File property | 958 | lnk.setFile(filename); //sets File property |
963 | |||
964 | lnk.setType("audio/x-mpegurl"); | 959 | lnk.setType("audio/x-mpegurl"); |
965 | lnk.setExec("opieplayer"); | 960 | lnk.setExec("opieplayer"); |
966 | lnk.setIcon("opieplayer/MPEGPlayer"); | 961 | lnk.setIcon("opieplayer/MPEGPlayer"); |
967 | 962 | ||
968 | if(!lnk.writeLink()) { | 963 | if(!lnk.writeLink()) { |
969 | qDebug("Writing doclink did not work"); | 964 | qDebug("Writing doclink did not work"); |
970 | } | 965 | } |
971 | d->selectedFiles->addToSelection( lnk); | 966 | d->selectedFiles->addToSelection( lnk); |
972 | } | 967 | } |
973 | } | 968 | } |
974 | if(fileDlg) { | 969 | if(fileDlg) { |
975 | delete fileDlg; | 970 | delete fileDlg; |
976 | } | 971 | } |
977 | } | 972 | } |
978 | 973 | ||
979 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 974 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
980 | { | 975 | { |
981 | switch ( e->key() ) { | 976 | switch ( e->key() ) { |
982 | ////////////////////////////// Zaurus keys | 977 | ////////////////////////////// Zaurus keys |
983 | case Key_F9: //activity | 978 | case Key_F9: //activity |
984 | // if(audioUI->isHidden()) | 979 | // if(audioUI->isHidden()) |
985 | // audioUI->showMaximized(); | 980 | // audioUI->showMaximized(); |
986 | break; | 981 | break; |
987 | case Key_F10: //contacts | 982 | case Key_F10: //contacts |
988 | // if( videoUI->isHidden()) | 983 | // if( videoUI->isHidden()) |
989 | // videoUI->showMaximized(); | 984 | // videoUI->showMaximized(); |
990 | break; | 985 | break; |
991 | case Key_F11: //menu | 986 | case Key_F11: //menu |
992 | break; | 987 | break; |
993 | case Key_F12: //home | 988 | case Key_F12: //home |
994 | // doBlank(); | 989 | // doBlank(); |
995 | break; | 990 | break; |
996 | case Key_F13: //mail | 991 | case Key_F13: //mail |
997 | // doUnblank(); | 992 | // doUnblank(); |
998 | break; | 993 | break; |
999 | case Key_Q: //add to playlist | 994 | case Key_Q: //add to playlist |
1000 | qDebug("Add"); | 995 | qDebug("Add"); |
1001 | addSelected(); | 996 | addSelected(); |
1002 | break; | 997 | break; |
1003 | case Key_R: //remove from playlist | 998 | case Key_R: //remove from playlist |
1004 | removeSelected(); | 999 | removeSelected(); |
1005 | break; | 1000 | break; |
1006 | // case Key_P: //play | 1001 | // case Key_P: //play |
1007 | // qDebug("Play"); | 1002 | // qDebug("Play"); |
1008 | // playSelected(); | 1003 | // playSelected(); |
1009 | // break; | 1004 | // break; |
1010 | case Key_Space: | 1005 | case Key_Space: |
1011 | qDebug("Play"); | 1006 | qDebug("Play"); |
1012 | // playSelected(); puh | 1007 | // playSelected(); puh |
1013 | break; | 1008 | break; |
1014 | case Key_1: | 1009 | case Key_1: |
1015 | tabWidget->setCurrentPage(0); | 1010 | tabWidget->setCurrentPage(0); |
1016 | break; | 1011 | break; |
1017 | case Key_2: | 1012 | case Key_2: |
1018 | tabWidget->setCurrentPage(1); | 1013 | tabWidget->setCurrentPage(1); |
1019 | break; | 1014 | break; |
1020 | case Key_3: | 1015 | case Key_3: |
1021 | tabWidget->setCurrentPage(2); | 1016 | tabWidget->setCurrentPage(2); |
1022 | break; | 1017 | break; |
1023 | case Key_4: | 1018 | case Key_4: |
1024 | tabWidget->setCurrentPage(3); | 1019 | tabWidget->setCurrentPage(3); |
1025 | break; | 1020 | break; |
1026 | case Key_Down: | 1021 | case Key_Down: |
1027 | if ( !d->selectedFiles->next() ) | 1022 | if ( !d->selectedFiles->next() ) |
1028 | d->selectedFiles->first(); | 1023 | d->selectedFiles->first(); |
1029 | 1024 | ||
1030 | break; | 1025 | break; |
1031 | case Key_Up: | 1026 | case Key_Up: |
1032 | if ( !d->selectedFiles->prev() ) | 1027 | if ( !d->selectedFiles->prev() ) |
1033 | // d->selectedFiles->last(); | 1028 | // d->selectedFiles->last(); |
1034 | 1029 | ||
1035 | break; | 1030 | break; |
1036 | 1031 | ||
1037 | } | 1032 | } |
1038 | } | 1033 | } |
1039 | 1034 | ||
1040 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1035 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1041 | { | 1036 | { |
1042 | // qDebug("Key press"); | 1037 | // qDebug("Key press"); |
1043 | // switch ( e->key() ) { | 1038 | // switch ( e->key() ) { |
1044 | // ////////////////////////////// Zaurus keys | 1039 | // ////////////////////////////// Zaurus keys |
1045 | // case Key_A: //add to playlist | 1040 | // case Key_A: //add to playlist |
1046 | // qDebug("Add"); | 1041 | // qDebug("Add"); |
1047 | // addSelected(); | 1042 | // addSelected(); |
1048 | // break; | 1043 | // break; |
1049 | // case Key_R: //remove from playlist | 1044 | // case Key_R: //remove from playlist |
1050 | // removeSelected(); | 1045 | // removeSelected(); |
1051 | // break; | 1046 | // break; |
1052 | // case Key_P: //play | 1047 | // case Key_P: //play |
1053 | // qDebug("Play"); | 1048 | // qDebug("Play"); |
1054 | // playSelected(); | 1049 | // playSelected(); |
1055 | // break; | 1050 | // break; |
1056 | // case Key_Space: | 1051 | // case Key_Space: |
1057 | // qDebug("Play"); | 1052 | // qDebug("Play"); |
1058 | // playSelected(); | 1053 | // playSelected(); |
1059 | // break; | 1054 | // break; |
1060 | // } | 1055 | // } |
1061 | } | 1056 | } |
1062 | 1057 | ||
1063 | void PlayListWidget::doBlank() { | 1058 | void PlayListWidget::doBlank() { |
1064 | qDebug("do blanking"); | 1059 | qDebug("do blanking"); |
1065 | fd=open("/dev/fb0",O_RDWR); | 1060 | fd=open("/dev/fb0",O_RDWR); |
1066 | if (fd != -1) { | 1061 | if (fd != -1) { |
1067 | ioctl(fd,FBIOBLANK,1); | 1062 | ioctl(fd,FBIOBLANK,1); |
1068 | // close(fd); | 1063 | // close(fd); |
1069 | } | 1064 | } |
1070 | } | 1065 | } |
1071 | 1066 | ||
1072 | void PlayListWidget::doUnblank() { | 1067 | void PlayListWidget::doUnblank() { |
1073 | // this crashes opieplayer with a segfault | 1068 | // this crashes opieplayer with a segfault |
1074 | // int fd; | 1069 | // int fd; |
1075 | // fd=open("/dev/fb0",O_RDWR); | 1070 | // fd=open("/dev/fb0",O_RDWR); |
1076 | qDebug("do unblanking"); | 1071 | qDebug("do unblanking"); |
1077 | if (fd != -1) { | 1072 | if (fd != -1) { |
1078 | ioctl(fd,FBIOBLANK,0); | 1073 | ioctl(fd,FBIOBLANK,0); |
1079 | close(fd); | 1074 | close(fd); |
1080 | } | 1075 | } |
1081 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1076 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1082 | h <<-3;// v[1]; // -3 Force on | 1077 | h <<-3;// v[1]; // -3 Force on |
1083 | } | 1078 | } |
1084 | 1079 | ||
1085 | void PlayListWidget::readm3u(const QString &filename) { | 1080 | void PlayListWidget::readm3u(const QString &filename) { |
1086 | 1081 | ||
1087 | qDebug("m3u filename is "+filename); | 1082 | qDebug("m3u filename is "+filename); |
1088 | QFile f(filename); | 1083 | QFile f(filename); |
1089 | 1084 | ||
1090 | if(f.open(IO_ReadOnly)) { | 1085 | if(f.open(IO_ReadOnly)) { |
1091 | QTextStream t(&f); | 1086 | QTextStream t(&f); |
1092 | QString s;//, first, second; | 1087 | QString s;//, first, second; |
1093 | int i=0; | 1088 | int i=0; |
1094 | while ( !t.atEnd()) { | 1089 | while ( !t.atEnd()) { |
1095 | s=t.readLine(); | 1090 | s=t.readLine(); |
1096 | 1091 | ||
1097 | if(s.find("#",0,TRUE) == -1) { | 1092 | if(s.find("#",0,TRUE) == -1) { |
1098 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1093 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1099 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1094 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1100 | s=s.right(s.length()-2); | 1095 | s=s.right(s.length()-2); |
1101 | DocLnk lnk( s ); | 1096 | DocLnk lnk( s ); |
1102 | QFileInfo f(s); | 1097 | QFileInfo f(s); |
1103 | QString name = f.baseName(); | 1098 | QString name = f.baseName(); |
1104 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1099 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1105 | lnk.setName( name ); | 1100 | lnk.setName( name ); |
1106 | s=s.replace( QRegExp("\\"),"/"); | 1101 | s=s.replace( QRegExp("\\"),"/"); |
1107 | lnk.setFile( s ); | 1102 | lnk.setFile( s ); |
1108 | lnk.writeLink(); | 1103 | lnk.writeLink(); |
1109 | qDebug("add "+name); | 1104 | qDebug("add "+name); |
1110 | d->selectedFiles->addToSelection( lnk); | 1105 | d->selectedFiles->addToSelection( lnk); |
1111 | } else { // is url | 1106 | } else { // is url |
1112 | s.replace(QRegExp("%20")," "); | 1107 | s.replace(QRegExp("%20")," "); |
1113 | DocLnk lnk( s ); | 1108 | DocLnk lnk( s ); |
1114 | QString name; | 1109 | QString name; |
1115 | if(name.left(4)=="http") { | 1110 | if(name.left(4)=="http") { |
1116 | name = s.right( s.length() - 7); | 1111 | name = s.right( s.length() - 7); |
1117 | } else { | 1112 | } else { |
1118 | name = s; | 1113 | name = s; |
1119 | } | 1114 | } |
1120 | lnk.setName(name); | 1115 | lnk.setName(name); |
1121 | if(s.at(s.length()-4) == '.') { | 1116 | if(s.at(s.length()-4) == '.') { |
1122 | lnk.setFile( s); | 1117 | lnk.setFile( s); |
1123 | } else { | 1118 | } else { |
1124 | lnk.setFile( s+"/"); | 1119 | lnk.setFile( s+"/"); |
1125 | } | 1120 | } |
1126 | lnk.setType("audio/x-mpegurl"); | 1121 | lnk.setType("audio/x-mpegurl"); |
1127 | lnk.writeLink(); | 1122 | lnk.writeLink(); |
1128 | d->selectedFiles->addToSelection( lnk); | 1123 | d->selectedFiles->addToSelection( lnk); |
1129 | } | 1124 | } |
1130 | i++; | 1125 | i++; |
1131 | } | 1126 | } |
1132 | } | 1127 | } |
1133 | } | 1128 | } |
1134 | } | 1129 | } |
1135 | f.close(); | 1130 | f.close(); |
1136 | } | 1131 | } |
1137 | 1132 | ||
1138 | void PlayListWidget::writem3u() { | 1133 | void PlayListWidget::writem3u() { |
1139 | 1134 | ||
1140 | InputDialog *fileDlg; | 1135 | InputDialog *fileDlg; |
1141 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1136 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1142 | fileDlg->exec(); | 1137 | fileDlg->exec(); |
1143 | QString filename,list; | 1138 | QString filename,list; |
1144 | if( fileDlg->result() == 1 ) { | 1139 | if( fileDlg->result() == 1 ) { |
1145 | filename = fileDlg->LineEdit1->text(); | 1140 | filename = fileDlg->LineEdit1->text(); |
1146 | qDebug(filename); | 1141 | qDebug(filename); |
1147 | int noOfFiles = 0; | 1142 | int noOfFiles = 0; |
1148 | d->selectedFiles->first(); | 1143 | d->selectedFiles->first(); |
1149 | do { | 1144 | do { |
1150 | // we dont check for existance because of url's | 1145 | // we dont check for existance because of url's |
1151 | // qDebug(d->selectedFiles->current()->file()); | 1146 | // qDebug(d->selectedFiles->current()->file()); |
1152 | list += d->selectedFiles->current()->file()+"\n"; | 1147 | list += d->selectedFiles->current()->file()+"\n"; |
1153 | noOfFiles++; | 1148 | noOfFiles++; |
1154 | } | 1149 | } |
1155 | while ( d->selectedFiles->next() ); | 1150 | while ( d->selectedFiles->next() ); |
1156 | qDebug(list); | 1151 | qDebug(list); |
1157 | if(filename.left(1) != "/") | 1152 | if(filename.left(1) != "/") |
1158 | filename=QPEApplication::documentDir()+"/"+filename; | 1153 | filename=QPEApplication::documentDir()+"/"+filename; |
1159 | if(filename.right(3) != "m3u") | 1154 | if(filename.right(3) != "m3u") |
1160 | filename=filename+".m3u"; | 1155 | filename=filename+".m3u"; |
1161 | 1156 | ||
1162 | QFile f(filename); | 1157 | QFile f(filename); |
1163 | f.open(IO_WriteOnly); | 1158 | f.open(IO_WriteOnly); |
1164 | f.writeBlock(list, list.length()); | 1159 | f.writeBlock(list, list.length()); |
1165 | f.close(); | 1160 | f.close(); |
1166 | } | 1161 | } |
1167 | if(fileDlg) delete fileDlg; | 1162 | if(fileDlg) delete fileDlg; |
1168 | } | 1163 | } |
1169 | 1164 | ||
1170 | void PlayListWidget::readPls(const QString &filename) { | 1165 | void PlayListWidget::readPls(const QString &filename) { |
1171 | 1166 | ||
1172 | qDebug("pls filename is "+filename); | 1167 | qDebug("pls filename is "+filename); |
1173 | QFile f(filename); | 1168 | QFile f(filename); |
1174 | 1169 | ||
1175 | if(f.open(IO_ReadOnly)) { | 1170 | if(f.open(IO_ReadOnly)) { |
1176 | QTextStream t(&f); | 1171 | QTextStream t(&f); |
1177 | QString s;//, first, second; | 1172 | QString s;//, first, second; |
1178 | int i=0; | 1173 | int i=0; |
1179 | while ( !t.atEnd()) { | 1174 | while ( !t.atEnd()) { |
1180 | s=t.readLine(); | 1175 | s=t.readLine(); |
1181 | if(s.left(4) == "File") { | 1176 | if(s.left(4) == "File") { |
1182 | s=s.right(s.length() - 6); | 1177 | s=s.right(s.length() - 6); |
1183 | s.replace(QRegExp("%20")," "); | 1178 | s.replace(QRegExp("%20")," "); |
1184 | qDebug("adding "+s+" to playlist"); | 1179 | qDebug("adding "+s+" to playlist"); |
1185 | // numberofentries=2 | 1180 | // numberofentries=2 |
1186 | // File1=http | 1181 | // File1=http |
1187 | // Title | 1182 | // Title |
1188 | // Length | 1183 | // Length |
1189 | // Version | 1184 | // Version |
1190 | // File2=http | 1185 | // File2=http |
1191 | s=s.replace( QRegExp("\\"),"/"); | 1186 | s=s.replace( QRegExp("\\"),"/"); |
1192 | DocLnk lnk( s ); | 1187 | DocLnk lnk( s ); |
1193 | QFileInfo f(s); | 1188 | QFileInfo f(s); |
1194 | QString name = f.baseName(); | 1189 | QString name = f.baseName(); |
1195 | if(name.left(4)=="http") | 1190 | if(name.left(4)=="http") |
1196 | name = s.right( s.length() - 7); | 1191 | name = s.right( s.length() - 7); |
1197 | else | 1192 | else |
1198 | name=s; | 1193 | name=s; |
1199 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1194 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1200 | lnk.setName( name); | 1195 | lnk.setName( name); |
1201 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1196 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1202 | lnk.setFile( s); | 1197 | lnk.setFile( s); |
1203 | else { //if its a url | 1198 | else { //if its a url |
1204 | if( name.right(1).find('/') == -1) | 1199 | if( name.right(1).find('/') == -1) |
1205 | s+="/"; | 1200 | s+="/"; |
1206 | lnk.setFile( s); | 1201 | lnk.setFile( s); |
1207 | } | 1202 | } |
1208 | lnk.setType("audio/x-mpegurl"); | 1203 | lnk.setType("audio/x-mpegurl"); |
1209 | 1204 | ||
1210 | qDebug("DocLnk add "+name); | 1205 | qDebug("DocLnk add "+name); |
1211 | d->selectedFiles->addToSelection( lnk); | 1206 | d->selectedFiles->addToSelection( lnk); |
1212 | } | 1207 | } |
1213 | } | 1208 | } |
1214 | i++; | 1209 | i++; |
1215 | } | 1210 | } |
1216 | } | 1211 | } |
1217 | 1212 | ||