-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 1dee422..9065d63 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1212 +1,1211 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | 4 | ||
5 | #include <qpe/qpemenubar.h> | 5 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 6 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 7 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/lnkproperties.h> | 9 | #include <qpe/lnkproperties.h> |
10 | #include <qpe/storage.h> | 10 | #include <qpe/storage.h> |
11 | 11 | ||
12 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qcursor.h> | 17 | #include <qcursor.h> |
18 | #include <qimage.h> | 18 | #include <qimage.h> |
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | #include <qdir.h> | 20 | #include <qdir.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistbox.h> | 24 | #include <qlistbox.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qtabwidget.h> | 28 | #include <qtabwidget.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | #include <qpoint.h> | 30 | #include <qpoint.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include "playlistselection.h" | 37 | #include "playlistselection.h" |
38 | #include "playlistwidget.h" | 38 | #include "playlistwidget.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | 40 | ||
41 | #include "inputDialog.h" | 41 | #include "inputDialog.h" |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include "audiowidget.h" | 44 | #include "audiowidget.h" |
45 | #include "videowidget.h" | 45 | #include "videowidget.h" |
46 | 46 | ||
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <sys/file.h> | 48 | #include <sys/file.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/soundcard.h> | 50 | #include <sys/soundcard.h> |
51 | 51 | ||
52 | // for setBacklight() | 52 | // for setBacklight() |
53 | #include <linux/fb.h> | 53 | #include <linux/fb.h> |
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | #define BUTTONS_ON_TOOLBAR | 58 | #define BUTTONS_ON_TOOLBAR |
59 | #define SIDE_BUTTONS | 59 | #define SIDE_BUTTONS |
60 | #define CAN_SAVE_LOAD_PLAYLISTS | 60 | #define CAN_SAVE_LOAD_PLAYLISTS |
61 | 61 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
63 | 63 | ||
64 | 64 | ||
65 | class PlayListWidgetPrivate { | 65 | class PlayListWidgetPrivate { |
66 | public: | 66 | public: |
67 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 67 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
68 | QFrame *playListFrame; | 68 | QFrame *playListFrame; |
69 | FileSelector *files; | 69 | FileSelector *files; |
70 | PlayListSelection *selectedFiles; | 70 | PlayListSelection *selectedFiles; |
71 | bool setDocumentUsed; | 71 | bool setDocumentUsed; |
72 | DocLnk *current; | 72 | DocLnk *current; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | class ToolButton : public QToolButton { | 76 | class ToolButton : public QToolButton { |
77 | public: | 77 | public: |
78 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 78 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
79 | : QToolButton( parent, name ) { | 79 | : QToolButton( parent, name ) { |
80 | setTextLabel( name ); | 80 | setTextLabel( name ); |
81 | setPixmap( Resource::loadPixmap( icon ) ); | 81 | setPixmap( Resource::loadPixmap( icon ) ); |
82 | setAutoRaise( TRUE ); | 82 | setAutoRaise( TRUE ); |
83 | setFocusPolicy( QWidget::NoFocus ); | 83 | setFocusPolicy( QWidget::NoFocus ); |
84 | setToggleButton( t ); | 84 | setToggleButton( t ); |
85 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 85 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
86 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 86 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class MenuItem : public QAction { | 91 | class MenuItem : public QAction { |
92 | public: | 92 | public: |
93 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 93 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
94 | : QAction( text, QString::null, 0, 0 ) { | 94 | : QAction( text, QString::null, 0, 0 ) { |
95 | connect( this, SIGNAL( activated() ), handler, slot ); | 95 | connect( this, SIGNAL( activated() ), handler, slot ); |
96 | addTo( parent ); | 96 | addTo( parent ); |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | 100 | ||
101 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 101 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
102 | : QMainWindow( parent, name, fl ) { | 102 | : QMainWindow( parent, name, fl ) { |
103 | 103 | ||
104 | d = new PlayListWidgetPrivate; | 104 | d = new PlayListWidgetPrivate; |
105 | d->setDocumentUsed = FALSE; | 105 | d->setDocumentUsed = FALSE; |
106 | d->current = NULL; | 106 | d->current = NULL; |
107 | fromSetDocument = FALSE; | 107 | fromSetDocument = FALSE; |
108 | insanityBool=FALSE; | 108 | insanityBool=FALSE; |
109 | audioScan = FALSE; | 109 | audioScan = FALSE; |
110 | videoScan = FALSE; | 110 | videoScan = FALSE; |
111 | 111 | ||
112 | setBackgroundMode( PaletteButton ); | 112 | setBackgroundMode( PaletteButton ); |
113 | 113 | ||
114 | setCaption( tr("OpiePlayer") ); | 114 | setCaption( tr("OpiePlayer") ); |
115 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 115 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
116 | 116 | ||
117 | setToolBarsMovable( FALSE ); | 117 | setToolBarsMovable( FALSE ); |
118 | 118 | ||
119 | // Create Toolbar | 119 | // Create Toolbar |
120 | QPEToolBar *toolbar = new QPEToolBar( this ); | 120 | QPEToolBar *toolbar = new QPEToolBar( this ); |
121 | toolbar->setHorizontalStretchable( TRUE ); | 121 | toolbar->setHorizontalStretchable( TRUE ); |
122 | 122 | ||
123 | // Create Menubar | 123 | // Create Menubar |
124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
125 | menu->setMargin( 0 ); | 125 | menu->setMargin( 0 ); |
126 | 126 | ||
127 | QPEToolBar *bar = new QPEToolBar( this ); | 127 | QPEToolBar *bar = new QPEToolBar( this ); |
128 | bar->setLabel( tr( "Play Operations" ) ); | 128 | bar->setLabel( tr( "Play Operations" ) ); |
129 | 129 | ||
130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
131 | tbDeletePlaylist->setFlat(TRUE); | 131 | tbDeletePlaylist->setFlat(TRUE); |
132 | tbDeletePlaylist->setFixedSize(20,20); | 132 | tbDeletePlaylist->setFixedSize(20,20); |
133 | 133 | ||
134 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 134 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
135 | this , SLOT(addSelected()) ); | 135 | this , SLOT(addSelected()) ); |
136 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 136 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
137 | this , SLOT(removeSelected()) ); | 137 | this , SLOT(removeSelected()) ); |
138 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 138 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
139 | this , SLOT( btnPlay(bool) ), TRUE ); | 139 | this , SLOT( btnPlay(bool) ), TRUE ); |
140 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 140 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
141 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 141 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
142 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 142 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
143 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 143 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
144 | tbDeletePlaylist->hide(); | 144 | tbDeletePlaylist->hide(); |
145 | 145 | ||
146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
147 | menu->insertItem( tr( "File" ), pmPlayList ); | 147 | menu->insertItem( tr( "File" ), pmPlayList ); |
148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
152 | pmPlayList->insertSeparator(-1); | 152 | pmPlayList->insertSeparator(-1); |
153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
155 | pmPlayList->insertSeparator(-1); | 155 | pmPlayList->insertSeparator(-1); |
156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
157 | pmPlayList->insertSeparator(-1); | 157 | pmPlayList->insertSeparator(-1); |
158 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 158 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
160 | 160 | ||
161 | QPopupMenu *pmView = new QPopupMenu( this ); | 161 | QPopupMenu *pmView = new QPopupMenu( this ); |
162 | menu->insertItem( tr( "View" ), pmView ); | 162 | menu->insertItem( tr( "View" ), pmView ); |
163 | 163 | ||
164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
165 | fullScreenButton->addTo(pmView); | 165 | fullScreenButton->addTo(pmView); |
166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
167 | scaleButton->addTo(pmView); | 167 | scaleButton->addTo(pmView); |
168 | 168 | ||
169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 169 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 170 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
171 | 171 | ||
172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
173 | 173 | ||
174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
175 | // tabWidget->setTabShape(QTabWidget::Triangular); | 175 | // tabWidget->setTabShape(QTabWidget::Triangular); |
176 | 176 | ||
177 | QWidget *pTab; | 177 | QWidget *pTab; |
178 | pTab = new QWidget( tabWidget, "pTab" ); | 178 | pTab = new QWidget( tabWidget, "pTab" ); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 179 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 180 | ||
181 | 181 | ||
182 | // Add the playlist area | 182 | // Add the playlist area |
183 | 183 | ||
184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
185 | d->playListFrame = vbox3; | 185 | d->playListFrame = vbox3; |
186 | d->playListFrame ->setMinimumSize(235,260); | 186 | d->playListFrame ->setMinimumSize(235,260); |
187 | 187 | ||
188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
189 | 189 | ||
190 | d->selectedFiles = new PlayListSelection( hbox2); | 190 | d->selectedFiles = new PlayListSelection( hbox2); |
191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
192 | 192 | ||
193 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 193 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
194 | 194 | ||
195 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 195 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
196 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 196 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
197 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 197 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
198 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 198 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
199 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 199 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
200 | 200 | ||
201 | QWidget *aTab; | 201 | QWidget *aTab; |
202 | aTab = new QWidget( tabWidget, "aTab" ); | 202 | aTab = new QWidget( tabWidget, "aTab" ); |
203 | audioView = new QListView( aTab, "Audioview" ); | 203 | audioView = new QListView( aTab, "Audioview" ); |
204 | audioView->setMinimumSize(233,260); | 204 | audioView->setMinimumSize(233,260); |
205 | audioView->addColumn( tr("Title"),140); | 205 | audioView->addColumn( tr("Title"),140); |
206 | audioView->addColumn(tr("Size"), -1); | 206 | audioView->addColumn(tr("Size"), -1); |
207 | audioView->addColumn(tr("Media"),-1); | 207 | audioView->addColumn(tr("Media"),-1); |
208 | audioView->setColumnAlignment(1, Qt::AlignRight); | 208 | audioView->setColumnAlignment(1, Qt::AlignRight); |
209 | audioView->setColumnAlignment(2, Qt::AlignRight); | 209 | audioView->setColumnAlignment(2, Qt::AlignRight); |
210 | audioView->setAllColumnsShowFocus(TRUE); | 210 | audioView->setAllColumnsShowFocus(TRUE); |
211 | 211 | ||
212 | audioView->setMultiSelection( TRUE ); | 212 | audioView->setMultiSelection( TRUE ); |
213 | audioView->setSelectionMode( QListView::Extended); | 213 | audioView->setSelectionMode( QListView::Extended); |
214 | 214 | ||
215 | tabWidget->insertTab(aTab,tr("Audio")); | 215 | tabWidget->insertTab(aTab,tr("Audio")); |
216 | 216 | ||
217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
218 | 218 | ||
219 | QWidget *vTab; | 219 | QWidget *vTab; |
220 | vTab = new QWidget( tabWidget, "vTab" ); | 220 | vTab = new QWidget( tabWidget, "vTab" ); |
221 | videoView = new QListView( vTab, "Videoview" ); | 221 | videoView = new QListView( vTab, "Videoview" ); |
222 | videoView->setMinimumSize(233,260); | 222 | videoView->setMinimumSize(233,260); |
223 | 223 | ||
224 | videoView->addColumn(tr("Title"),140); | 224 | videoView->addColumn(tr("Title"),140); |
225 | videoView->addColumn(tr("Size"),-1); | 225 | videoView->addColumn(tr("Size"),-1); |
226 | videoView->addColumn(tr("Media"),-1); | 226 | videoView->addColumn(tr("Media"),-1); |
227 | videoView->setColumnAlignment(1, Qt::AlignRight); | 227 | videoView->setColumnAlignment(1, Qt::AlignRight); |
228 | videoView->setColumnAlignment(2, Qt::AlignRight); | 228 | videoView->setColumnAlignment(2, Qt::AlignRight); |
229 | videoView->setAllColumnsShowFocus(TRUE); | 229 | videoView->setAllColumnsShowFocus(TRUE); |
230 | videoView->setMultiSelection( TRUE ); | 230 | videoView->setMultiSelection( TRUE ); |
231 | videoView->setSelectionMode( QListView::Extended); | 231 | videoView->setSelectionMode( QListView::Extended); |
232 | 232 | ||
233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
234 | 234 | ||
235 | tabWidget->insertTab( vTab,tr("Video")); | 235 | tabWidget->insertTab( vTab,tr("Video")); |
236 | 236 | ||
237 | //playlists list | 237 | //playlists list |
238 | QWidget *LTab; | 238 | QWidget *LTab; |
239 | LTab = new QWidget( tabWidget, "LTab" ); | 239 | LTab = new QWidget( tabWidget, "LTab" ); |
240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
241 | playLists->setMinimumSize(233,260); | 241 | playLists->setMinimumSize(233,260); |
242 | tabWidget->insertTab(LTab,tr("Lists")); | 242 | tabWidget->insertTab(LTab,tr("Lists")); |
243 | 243 | ||
244 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 244 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
245 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 245 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
246 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 246 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
247 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 247 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
248 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 248 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( audioView, 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 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 251 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
252 | this,SLOT( playIt( QListViewItem *)) ); | 252 | this,SLOT( playIt( QListViewItem *)) ); |
253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
257 | this,SLOT( playIt( QListViewItem *)) ); | 257 | this,SLOT( playIt( QListViewItem *)) ); |
258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
265 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 265 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
266 | 266 | ||
267 | setCentralWidget( vbox5 ); | 267 | setCentralWidget( vbox5 ); |
268 | 268 | ||
269 | Config cfg( "OpiePlayer" ); | 269 | Config cfg( "OpiePlayer" ); |
270 | readConfig( cfg ); | 270 | readConfig( cfg ); |
271 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 271 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
272 | loadList(DocLnk( currentPlaylist)); | 272 | loadList(DocLnk( currentPlaylist)); |
273 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 273 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
274 | 274 | ||
275 | initializeStates(); | 275 | initializeStates(); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | PlayListWidget::~PlayListWidget() { | 279 | PlayListWidget::~PlayListWidget() { |
280 | Config cfg( "OpiePlayer" ); | 280 | Config cfg( "OpiePlayer" ); |
281 | writeConfig( cfg ); | 281 | writeConfig( cfg ); |
282 | 282 | ||
283 | if ( d->current ) { | 283 | if ( d->current ) { |
284 | delete d->current; | 284 | delete d->current; |
285 | } | 285 | } |
286 | delete d; | 286 | delete d; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void PlayListWidget::initializeStates() { | 290 | void PlayListWidget::initializeStates() { |
291 | 291 | ||
292 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 292 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
293 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 293 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
294 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 294 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
295 | setPlaylist( true); | 295 | setPlaylist( true); |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void PlayListWidget::readConfig( Config& cfg ) { | 299 | void PlayListWidget::readConfig( Config& cfg ) { |
300 | cfg.setGroup("PlayList"); | 300 | cfg.setGroup("PlayList"); |
301 | QString currentString = cfg.readEntry("current", "" ); | 301 | QString currentString = cfg.readEntry("current", "" ); |
302 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 302 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
303 | for ( int i = 0; i < noOfFiles; i++ ) { | 303 | for ( int i = 0; i < noOfFiles; i++ ) { |
304 | QString entryName; | 304 | QString entryName; |
305 | entryName.sprintf( "File%i", i + 1 ); | 305 | entryName.sprintf( "File%i", i + 1 ); |
306 | QString linkFile = cfg.readEntry( entryName ); | 306 | QString linkFile = cfg.readEntry( entryName ); |
307 | DocLnk lnk( linkFile ); | 307 | DocLnk lnk( linkFile ); |
308 | if ( lnk.isValid() ) { | 308 | if ( lnk.isValid() ) { |
309 | d->selectedFiles->addToSelection( lnk ); | 309 | d->selectedFiles->addToSelection( lnk ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | d->selectedFiles->setSelectedItem( currentString); | 312 | d->selectedFiles->setSelectedItem( currentString); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void PlayListWidget::writeConfig( Config& cfg ) const { | 316 | void PlayListWidget::writeConfig( Config& cfg ) const { |
317 | 317 | ||
318 | d->selectedFiles->writeCurrent( cfg); | 318 | d->selectedFiles->writeCurrent( cfg); |
319 | cfg.setGroup("PlayList"); | 319 | cfg.setGroup("PlayList"); |
320 | int noOfFiles = 0; | 320 | int noOfFiles = 0; |
321 | d->selectedFiles->first(); | 321 | d->selectedFiles->first(); |
322 | do { | 322 | do { |
323 | const DocLnk *lnk = d->selectedFiles->current(); | 323 | const DocLnk *lnk = d->selectedFiles->current(); |
324 | if ( lnk ) { | 324 | if ( lnk ) { |
325 | QString entryName; | 325 | QString entryName; |
326 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 326 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
327 | cfg.writeEntry( entryName, lnk->linkFile() ); | 327 | cfg.writeEntry( entryName, lnk->linkFile() ); |
328 | // if this link does exist, add it so we have the file | 328 | // if this link does exist, add it so we have the file |
329 | // next time... | 329 | // next time... |
330 | if ( !QFile::exists( lnk->linkFile() ) ) { | 330 | if ( !QFile::exists( lnk->linkFile() ) ) { |
331 | // the way writing lnks doesn't really check for out | 331 | // the way writing lnks doesn't really check for out |
332 | // of disk space, but check it anyway. | 332 | // of disk space, but check it anyway. |
333 | if ( !lnk->writeLink() ) { | 333 | if ( !lnk->writeLink() ) { |
334 | QMessageBox::critical( 0, tr("Out of space"), | 334 | QMessageBox::critical( 0, tr("Out of space"), |
335 | tr( "There was a problem saving " | 335 | tr( "There was a problem saving " |
336 | "the playlist.\n" | 336 | "the playlist.\n" |
337 | "Your playlist " | 337 | "Your playlist " |
338 | "may be missing some entries\n" | 338 | "may be missing some entries\n" |
339 | "the next time you start it." ) | 339 | "the next time you start it." ) |
340 | ); | 340 | ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | noOfFiles++; | 343 | noOfFiles++; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | while ( d->selectedFiles->next() ); | 346 | while ( d->selectedFiles->next() ); |
347 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 347 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 351 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
352 | d->setDocumentUsed = FALSE; | 352 | d->setDocumentUsed = FALSE; |
353 | if ( mediaPlayerState->playlist() ) { | 353 | if ( mediaPlayerState->playlist() ) { |
354 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 354 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
355 | d->selectedFiles->addToSelection( lnk ); | 355 | d->selectedFiles->addToSelection( lnk ); |
356 | } | 356 | } |
357 | else | 357 | else |
358 | mediaPlayerState->setPlaying( TRUE ); | 358 | mediaPlayerState->setPlaying( TRUE ); |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void PlayListWidget::clearList() { | 362 | void PlayListWidget::clearList() { |
363 | while ( first() ) { | 363 | while ( first() ) { |
364 | d->selectedFiles->removeSelected(); | 364 | d->selectedFiles->removeSelected(); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void PlayListWidget::addAllToList() { | 369 | void PlayListWidget::addAllToList() { |
370 | DocLnkSet filesAll; | 370 | DocLnkSet filesAll; |
371 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 371 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
372 | QListIterator<DocLnk> Adit( filesAll.children() ); | 372 | QListIterator<DocLnk> Adit( filesAll.children() ); |
373 | for ( ; Adit.current(); ++Adit ) { | 373 | for ( ; Adit.current(); ++Adit ) { |
374 | if(QFileInfo(Adit.current()->file()).exists()) { | 374 | if(QFileInfo(Adit.current()->file()).exists()) { |
375 | d->selectedFiles->addToSelection( **Adit ); | 375 | d->selectedFiles->addToSelection( **Adit ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::addAllMusicToList() { | 381 | void PlayListWidget::addAllMusicToList() { |
382 | QListIterator<DocLnk> dit( files.children() ); | 382 | QListIterator<DocLnk> dit( files.children() ); |
383 | for ( ; dit.current(); ++dit ) { | 383 | for ( ; dit.current(); ++dit ) { |
384 | if(QFileInfo(dit.current()->file()).exists()) { | 384 | if(QFileInfo(dit.current()->file()).exists()) { |
385 | d->selectedFiles->addToSelection( **dit ); | 385 | d->selectedFiles->addToSelection( **dit ); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void PlayListWidget::addAllVideoToList() { | 391 | void PlayListWidget::addAllVideoToList() { |
392 | QListIterator<DocLnk> dit( vFiles.children() ); | 392 | QListIterator<DocLnk> dit( vFiles.children() ); |
393 | for ( ; dit.current(); ++dit ) | 393 | for ( ; dit.current(); ++dit ) |
394 | if(QFileInfo( dit.current()->file()).exists()) | 394 | if(QFileInfo( dit.current()->file()).exists()) |
395 | d->selectedFiles->addToSelection( **dit ); | 395 | d->selectedFiles->addToSelection( **dit ); |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | void PlayListWidget::setDocument(const QString& fileref) { | 399 | void PlayListWidget::setDocument(const QString& fileref) { |
400 | qDebug(fileref); | 400 | qDebug(fileref); |
401 | fromSetDocument = TRUE; | 401 | fromSetDocument = TRUE; |
402 | if ( fileref.isNull() ) { | 402 | if ( fileref.isNull() ) { |
403 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 403 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | 406 | ||
407 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 407 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
408 | readm3u( fileref); | 408 | readm3u( fileref); |
409 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 409 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
410 | readPls( fileref); | 410 | readPls( fileref); |
411 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 411 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
412 | clearList(); | 412 | clearList(); |
413 | loadList(DocLnk(fileref)); | 413 | loadList(DocLnk(fileref)); |
414 | d->selectedFiles->first(); | 414 | d->selectedFiles->first(); |
415 | } else { | 415 | } else { |
416 | clearList(); | 416 | clearList(); |
417 | addToSelection( DocLnk( fileref ) ); | 417 | addToSelection( DocLnk( fileref ) ); |
418 | d->setDocumentUsed = TRUE; | 418 | d->setDocumentUsed = TRUE; |
419 | mediaPlayerState->setPlaying( FALSE ); | 419 | mediaPlayerState->setPlaying( FALSE ); |
420 | qApp->processEvents(); | 420 | qApp->processEvents(); |
421 | mediaPlayerState->setPlaying( TRUE ); | 421 | mediaPlayerState->setPlaying( TRUE ); |
422 | qApp->processEvents(); | 422 | qApp->processEvents(); |
423 | setCaption(tr("OpiePlayer")); | 423 | setCaption(tr("OpiePlayer")); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | 427 | ||
428 | void PlayListWidget::setActiveWindow() { | 428 | void PlayListWidget::setActiveWindow() { |
429 | qDebug("SETTING active window"); | 429 | qDebug("SETTING active window"); |
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->currentItem()->text(0); |
844 | QListIterator<DocLnk> dit( files.children() ); | 844 | QListIterator<DocLnk> Pdit( files.children() ); |
845 | for ( ; dit.current(); ++dit ) { | 845 | for ( ; Pdit.current(); ++Pdit ) { |
846 | if( dit.current()->name() == file) { | 846 | if( Pdit.current()->name() == file) { |
847 | // qDebug(file); | 847 | LnkProperties prop( Pdit.current() ); |
848 | LnkProperties prop( dit.current() ); | ||
849 | prop.showMaximized(); | 848 | prop.showMaximized(); |
850 | prop.exec(); | 849 | prop.exec(); |
851 | } | 850 | } |
852 | } | 851 | } |
853 | populateAudioView(); | 852 | populateAudioView(); |
854 | } | 853 | } |
855 | break; | 854 | break; |
856 | case 2: | 855 | case 2: |
857 | { | 856 | { |
858 | 857 | ||
859 | } | 858 | } |
860 | break; | 859 | break; |
861 | }; | 860 | }; |
862 | } | 861 | } |
863 | 862 | ||
864 | void PlayListWidget::scanForAudio() { | 863 | void PlayListWidget::scanForAudio() { |
865 | qDebug("scan for audio"); | 864 | qDebug("scan for audio"); |
866 | files.detachChildren(); | 865 | files.detachChildren(); |
867 | QListIterator<DocLnk> sdit( files.children() ); | 866 | QListIterator<DocLnk> sdit( files.children() ); |
868 | for ( ; sdit.current(); ++sdit ) { | 867 | for ( ; sdit.current(); ++sdit ) { |
869 | delete sdit.current(); | 868 | delete sdit.current(); |
870 | } | 869 | } |
871 | Global::findDocuments(&files, "audio/*"); | 870 | Global::findDocuments(&files, "audio/*"); |
872 | audioScan = TRUE; | 871 | audioScan = TRUE; |
873 | } | 872 | } |
874 | void PlayListWidget::scanForVideo() { | 873 | void PlayListWidget::scanForVideo() { |
875 | qDebug("scan for video"); | 874 | qDebug("scan for video"); |
876 | vFiles.detachChildren(); | 875 | vFiles.detachChildren(); |
877 | QListIterator<DocLnk> sdit( vFiles.children() ); | 876 | QListIterator<DocLnk> sdit( vFiles.children() ); |
878 | for ( ; sdit.current(); ++sdit ) { | 877 | for ( ; sdit.current(); ++sdit ) { |
879 | delete sdit.current(); | 878 | delete sdit.current(); |
880 | } | 879 | } |
881 | Global::findDocuments(&vFiles, "video/*"); | 880 | Global::findDocuments(&vFiles, "video/*"); |
882 | videoScan = TRUE; | 881 | videoScan = TRUE; |
883 | } | 882 | } |
884 | 883 | ||
885 | void PlayListWidget::populateAudioView() { | 884 | void PlayListWidget::populateAudioView() { |
886 | 885 | ||
887 | audioView->clear(); | 886 | audioView->clear(); |
888 | StorageInfo storageInfo; | 887 | StorageInfo storageInfo; |
889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 888 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
890 | if(!audioScan) scanForAudio(); | 889 | if(!audioScan) scanForAudio(); |
891 | 890 | ||
892 | QListIterator<DocLnk> dit( files.children() ); | 891 | QListIterator<DocLnk> dit( files.children() ); |
893 | QListIterator<FileSystem> it ( fs ); | 892 | QListIterator<FileSystem> it ( fs ); |
894 | 893 | ||
895 | QString storage; | 894 | QString storage; |
896 | for ( ; dit.current(); ++dit ) { | 895 | for ( ; dit.current(); ++dit ) { |
897 | for( ; it.current(); ++it ){ | 896 | for( ; it.current(); ++it ){ |
898 | const QString name = (*it)->name(); | 897 | const QString name = (*it)->name(); |
899 | const QString path = (*it)->path(); | 898 | const QString path = (*it)->path(); |
900 | if(dit.current()->file().find(path) != -1 ) storage=name; | 899 | if(dit.current()->file().find(path) != -1 ) storage=name; |
901 | } | 900 | } |
902 | 901 | ||
903 | QListViewItem * newItem; | 902 | QListViewItem * newItem; |
904 | if ( QFile( dit.current()->file()).exists() ) { | 903 | if ( QFile( dit.current()->file()).exists() ) { |
905 | // qDebug(dit.current()->name()); | 904 | // qDebug(dit.current()->name()); |
906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 905 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
907 | QString::number( QFile( dit.current()->file()).size() ), storage); | 906 | QString::number( QFile( dit.current()->file()).size() ), storage); |
908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 907 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
909 | } | 908 | } |
910 | } | 909 | } |
911 | 910 | ||
912 | } | 911 | } |
913 | 912 | ||
914 | void PlayListWidget::populateVideoView() { | 913 | void PlayListWidget::populateVideoView() { |
915 | videoView->clear(); | 914 | videoView->clear(); |
916 | StorageInfo storageInfo; | 915 | StorageInfo storageInfo; |
917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 916 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
918 | 917 | ||
919 | if(!videoScan ) scanForVideo(); | 918 | if(!videoScan ) scanForVideo(); |
920 | 919 | ||
921 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 920 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
922 | QListIterator<FileSystem> it ( fs ); | 921 | QListIterator<FileSystem> it ( fs ); |
923 | videoView->clear(); | 922 | videoView->clear(); |
924 | QString storage; | 923 | QString storage; |
925 | for ( ; Vdit.current(); ++Vdit ) { | 924 | for ( ; Vdit.current(); ++Vdit ) { |
926 | for( ; it.current(); ++it ){ | 925 | for( ; it.current(); ++it ){ |
927 | const QString name = (*it)->name(); | 926 | const QString name = (*it)->name(); |
928 | const QString path = (*it)->path(); | 927 | const QString path = (*it)->path(); |
929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 928 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
930 | } | 929 | } |
931 | 930 | ||
932 | QListViewItem * newItem; | 931 | QListViewItem * newItem; |
933 | if ( QFile( Vdit.current()->file()).exists() ) { | 932 | if ( QFile( Vdit.current()->file()).exists() ) { |
934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 933 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 934 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 935 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
937 | } | 936 | } |
938 | } | 937 | } |
939 | } | 938 | } |
940 | 939 | ||
941 | void PlayListWidget::openFile() { | 940 | void PlayListWidget::openFile() { |
942 | QString filename, name; | 941 | QString filename, name; |
943 | InputDialog *fileDlg; | 942 | InputDialog *fileDlg; |
944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 943 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
945 | fileDlg->exec(); | 944 | fileDlg->exec(); |
946 | if( fileDlg->result() == 1 ) { | 945 | if( fileDlg->result() == 1 ) { |
947 | filename = fileDlg->LineEdit1->text(); | 946 | filename = fileDlg->LineEdit1->text(); |
948 | 947 | ||
949 | qDebug("Selected filename is "+filename); | 948 | qDebug("Selected filename is "+filename); |
950 | if(filename.right(3) == "m3u") { | 949 | if(filename.right(3) == "m3u") { |
951 | readm3u( filename ); | 950 | readm3u( filename ); |
952 | } else if(filename.right(3) == "pls") { | 951 | } else if(filename.right(3) == "pls") { |
953 | readPls( filename ); | 952 | readPls( filename ); |
954 | } else { | 953 | } else { |
955 | DocLnk lnk; | 954 | DocLnk lnk; |
956 | 955 | ||
957 | lnk.setName(filename); //sets file name | 956 | lnk.setName(filename); //sets file name |
958 | lnk.setFile(filename); //sets File property | 957 | lnk.setFile(filename); //sets File property |
959 | lnk.setType("audio/x-mpegurl"); | 958 | lnk.setType("audio/x-mpegurl"); |
960 | lnk.setExec("opieplayer"); | 959 | lnk.setExec("opieplayer"); |
961 | lnk.setIcon("opieplayer/MPEGPlayer"); | 960 | lnk.setIcon("opieplayer/MPEGPlayer"); |
962 | 961 | ||
963 | if(!lnk.writeLink()) { | 962 | if(!lnk.writeLink()) { |
964 | qDebug("Writing doclink did not work"); | 963 | qDebug("Writing doclink did not work"); |
965 | } | 964 | } |
966 | d->selectedFiles->addToSelection( lnk); | 965 | d->selectedFiles->addToSelection( lnk); |
967 | } | 966 | } |
968 | } | 967 | } |
969 | if(fileDlg) { | 968 | if(fileDlg) { |
970 | delete fileDlg; | 969 | delete fileDlg; |
971 | } | 970 | } |
972 | } | 971 | } |
973 | 972 | ||
974 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 973 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
975 | { | 974 | { |
976 | switch ( e->key() ) { | 975 | switch ( e->key() ) { |
977 | ////////////////////////////// Zaurus keys | 976 | ////////////////////////////// Zaurus keys |
978 | case Key_F9: //activity | 977 | case Key_F9: //activity |
979 | // if(audioUI->isHidden()) | 978 | // if(audioUI->isHidden()) |
980 | // audioUI->showMaximized(); | 979 | // audioUI->showMaximized(); |
981 | break; | 980 | break; |
982 | case Key_F10: //contacts | 981 | case Key_F10: //contacts |
983 | // if( videoUI->isHidden()) | 982 | // if( videoUI->isHidden()) |
984 | // videoUI->showMaximized(); | 983 | // videoUI->showMaximized(); |
985 | break; | 984 | break; |
986 | case Key_F11: //menu | 985 | case Key_F11: //menu |
987 | break; | 986 | break; |
988 | case Key_F12: //home | 987 | case Key_F12: //home |
989 | // doBlank(); | 988 | // doBlank(); |
990 | break; | 989 | break; |
991 | case Key_F13: //mail | 990 | case Key_F13: //mail |
992 | // doUnblank(); | 991 | // doUnblank(); |
993 | break; | 992 | break; |
994 | case Key_Q: //add to playlist | 993 | case Key_Q: //add to playlist |
995 | qDebug("Add"); | 994 | qDebug("Add"); |
996 | addSelected(); | 995 | addSelected(); |
997 | break; | 996 | break; |
998 | case Key_R: //remove from playlist | 997 | case Key_R: //remove from playlist |
999 | removeSelected(); | 998 | removeSelected(); |
1000 | break; | 999 | break; |
1001 | // case Key_P: //play | 1000 | // case Key_P: //play |
1002 | // qDebug("Play"); | 1001 | // qDebug("Play"); |
1003 | // playSelected(); | 1002 | // playSelected(); |
1004 | // break; | 1003 | // break; |
1005 | case Key_Space: | 1004 | case Key_Space: |
1006 | qDebug("Play"); | 1005 | qDebug("Play"); |
1007 | // playSelected(); puh | 1006 | // playSelected(); puh |
1008 | break; | 1007 | break; |
1009 | case Key_1: | 1008 | case Key_1: |
1010 | tabWidget->setCurrentPage(0); | 1009 | tabWidget->setCurrentPage(0); |
1011 | break; | 1010 | break; |
1012 | case Key_2: | 1011 | case Key_2: |
1013 | tabWidget->setCurrentPage(1); | 1012 | tabWidget->setCurrentPage(1); |
1014 | break; | 1013 | break; |
1015 | case Key_3: | 1014 | case Key_3: |
1016 | tabWidget->setCurrentPage(2); | 1015 | tabWidget->setCurrentPage(2); |
1017 | break; | 1016 | break; |
1018 | case Key_4: | 1017 | case Key_4: |
1019 | tabWidget->setCurrentPage(3); | 1018 | tabWidget->setCurrentPage(3); |
1020 | break; | 1019 | break; |
1021 | case Key_Down: | 1020 | case Key_Down: |
1022 | if ( !d->selectedFiles->next() ) | 1021 | if ( !d->selectedFiles->next() ) |
1023 | d->selectedFiles->first(); | 1022 | d->selectedFiles->first(); |
1024 | 1023 | ||
1025 | break; | 1024 | break; |
1026 | case Key_Up: | 1025 | case Key_Up: |
1027 | if ( !d->selectedFiles->prev() ) | 1026 | if ( !d->selectedFiles->prev() ) |
1028 | // d->selectedFiles->last(); | 1027 | // d->selectedFiles->last(); |
1029 | 1028 | ||
1030 | break; | 1029 | break; |
1031 | 1030 | ||
1032 | } | 1031 | } |
1033 | } | 1032 | } |
1034 | 1033 | ||
1035 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1034 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1036 | { | 1035 | { |
1037 | // qDebug("Key press"); | 1036 | // qDebug("Key press"); |
1038 | // switch ( e->key() ) { | 1037 | // switch ( e->key() ) { |
1039 | // ////////////////////////////// Zaurus keys | 1038 | // ////////////////////////////// Zaurus keys |
1040 | // case Key_A: //add to playlist | 1039 | // case Key_A: //add to playlist |
1041 | // qDebug("Add"); | 1040 | // qDebug("Add"); |
1042 | // addSelected(); | 1041 | // addSelected(); |
1043 | // break; | 1042 | // break; |
1044 | // case Key_R: //remove from playlist | 1043 | // case Key_R: //remove from playlist |
1045 | // removeSelected(); | 1044 | // removeSelected(); |
1046 | // break; | 1045 | // break; |
1047 | // case Key_P: //play | 1046 | // case Key_P: //play |
1048 | // qDebug("Play"); | 1047 | // qDebug("Play"); |
1049 | // playSelected(); | 1048 | // playSelected(); |
1050 | // break; | 1049 | // break; |
1051 | // case Key_Space: | 1050 | // case Key_Space: |
1052 | // qDebug("Play"); | 1051 | // qDebug("Play"); |
1053 | // playSelected(); | 1052 | // playSelected(); |
1054 | // break; | 1053 | // break; |
1055 | // } | 1054 | // } |
1056 | } | 1055 | } |
1057 | 1056 | ||
1058 | void PlayListWidget::doBlank() { | 1057 | void PlayListWidget::doBlank() { |
1059 | qDebug("do blanking"); | 1058 | qDebug("do blanking"); |
1060 | fd=open("/dev/fb0",O_RDWR); | 1059 | fd=open("/dev/fb0",O_RDWR); |
1061 | if (fd != -1) { | 1060 | if (fd != -1) { |
1062 | ioctl(fd,FBIOBLANK,1); | 1061 | ioctl(fd,FBIOBLANK,1); |
1063 | // close(fd); | 1062 | // close(fd); |
1064 | } | 1063 | } |
1065 | } | 1064 | } |
1066 | 1065 | ||
1067 | void PlayListWidget::doUnblank() { | 1066 | void PlayListWidget::doUnblank() { |
1068 | // this crashes opieplayer with a segfault | 1067 | // this crashes opieplayer with a segfault |
1069 | // int fd; | 1068 | // int fd; |
1070 | // fd=open("/dev/fb0",O_RDWR); | 1069 | // fd=open("/dev/fb0",O_RDWR); |
1071 | qDebug("do unblanking"); | 1070 | qDebug("do unblanking"); |
1072 | if (fd != -1) { | 1071 | if (fd != -1) { |
1073 | ioctl(fd,FBIOBLANK,0); | 1072 | ioctl(fd,FBIOBLANK,0); |
1074 | close(fd); | 1073 | close(fd); |
1075 | } | 1074 | } |
1076 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1075 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1077 | h <<-3;// v[1]; // -3 Force on | 1076 | h <<-3;// v[1]; // -3 Force on |
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | void PlayListWidget::readm3u(const QString &filename) { | 1079 | void PlayListWidget::readm3u(const QString &filename) { |
1081 | 1080 | ||
1082 | qDebug("m3u filename is "+filename); | 1081 | qDebug("m3u filename is "+filename); |
1083 | QFile f(filename); | 1082 | QFile f(filename); |
1084 | 1083 | ||
1085 | if(f.open(IO_ReadOnly)) { | 1084 | if(f.open(IO_ReadOnly)) { |
1086 | QTextStream t(&f); | 1085 | QTextStream t(&f); |
1087 | QString s;//, first, second; | 1086 | QString s;//, first, second; |
1088 | int i=0; | 1087 | int i=0; |
1089 | while ( !t.atEnd()) { | 1088 | while ( !t.atEnd()) { |
1090 | s=t.readLine(); | 1089 | s=t.readLine(); |
1091 | 1090 | ||
1092 | if(s.find("#",0,TRUE) == -1) { | 1091 | if(s.find("#",0,TRUE) == -1) { |
1093 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1092 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1094 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1093 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1095 | s=s.right(s.length()-2); | 1094 | s=s.right(s.length()-2); |
1096 | DocLnk lnk( s ); | 1095 | DocLnk lnk( s ); |
1097 | QFileInfo f(s); | 1096 | QFileInfo f(s); |
1098 | QString name = f.baseName(); | 1097 | QString name = f.baseName(); |
1099 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1098 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1100 | lnk.setName( name ); | 1099 | lnk.setName( name ); |
1101 | s=s.replace( QRegExp("\\"),"/"); | 1100 | s=s.replace( QRegExp("\\"),"/"); |
1102 | lnk.setFile( s ); | 1101 | lnk.setFile( s ); |
1103 | lnk.writeLink(); | 1102 | lnk.writeLink(); |
1104 | qDebug("add "+name); | 1103 | qDebug("add "+name); |
1105 | d->selectedFiles->addToSelection( lnk); | 1104 | d->selectedFiles->addToSelection( lnk); |
1106 | } else { // is url | 1105 | } else { // is url |
1107 | s.replace(QRegExp("%20")," "); | 1106 | s.replace(QRegExp("%20")," "); |
1108 | DocLnk lnk( s ); | 1107 | DocLnk lnk( s ); |
1109 | QString name; | 1108 | QString name; |
1110 | if(name.left(4)=="http") { | 1109 | if(name.left(4)=="http") { |
1111 | name = s.right( s.length() - 7); | 1110 | name = s.right( s.length() - 7); |
1112 | } else { | 1111 | } else { |
1113 | name = s; | 1112 | name = s; |
1114 | } | 1113 | } |
1115 | lnk.setName(name); | 1114 | lnk.setName(name); |
1116 | if(s.at(s.length()-4) == '.') { | 1115 | if(s.at(s.length()-4) == '.') { |
1117 | lnk.setFile( s); | 1116 | lnk.setFile( s); |
1118 | } else { | 1117 | } else { |
1119 | lnk.setFile( s+"/"); | 1118 | lnk.setFile( s+"/"); |
1120 | } | 1119 | } |
1121 | lnk.setType("audio/x-mpegurl"); | 1120 | lnk.setType("audio/x-mpegurl"); |
1122 | lnk.writeLink(); | 1121 | lnk.writeLink(); |
1123 | d->selectedFiles->addToSelection( lnk); | 1122 | d->selectedFiles->addToSelection( lnk); |
1124 | } | 1123 | } |
1125 | i++; | 1124 | i++; |
1126 | } | 1125 | } |
1127 | } | 1126 | } |
1128 | } | 1127 | } |
1129 | } | 1128 | } |
1130 | f.close(); | 1129 | f.close(); |
1131 | } | 1130 | } |
1132 | 1131 | ||
1133 | void PlayListWidget::writem3u() { | 1132 | void PlayListWidget::writem3u() { |
1134 | 1133 | ||
1135 | InputDialog *fileDlg; | 1134 | InputDialog *fileDlg; |
1136 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1135 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1137 | fileDlg->exec(); | 1136 | fileDlg->exec(); |
1138 | QString filename,list; | 1137 | QString filename,list; |
1139 | if( fileDlg->result() == 1 ) { | 1138 | if( fileDlg->result() == 1 ) { |
1140 | filename = fileDlg->LineEdit1->text(); | 1139 | filename = fileDlg->LineEdit1->text(); |
1141 | qDebug(filename); | 1140 | qDebug(filename); |
1142 | int noOfFiles = 0; | 1141 | int noOfFiles = 0; |
1143 | d->selectedFiles->first(); | 1142 | d->selectedFiles->first(); |
1144 | do { | 1143 | do { |
1145 | // we dont check for existance because of url's | 1144 | // we dont check for existance because of url's |
1146 | // qDebug(d->selectedFiles->current()->file()); | 1145 | // qDebug(d->selectedFiles->current()->file()); |
1147 | list += d->selectedFiles->current()->file()+"\n"; | 1146 | list += d->selectedFiles->current()->file()+"\n"; |
1148 | noOfFiles++; | 1147 | noOfFiles++; |
1149 | } | 1148 | } |
1150 | while ( d->selectedFiles->next() ); | 1149 | while ( d->selectedFiles->next() ); |
1151 | qDebug(list); | 1150 | qDebug(list); |
1152 | if(filename.left(1) != "/") | 1151 | if(filename.left(1) != "/") |
1153 | filename=QPEApplication::documentDir()+"/"+filename; | 1152 | filename=QPEApplication::documentDir()+"/"+filename; |
1154 | if(filename.right(3) != "m3u") | 1153 | if(filename.right(3) != "m3u") |
1155 | filename=filename+".m3u"; | 1154 | filename=filename+".m3u"; |
1156 | 1155 | ||
1157 | QFile f(filename); | 1156 | QFile f(filename); |
1158 | f.open(IO_WriteOnly); | 1157 | f.open(IO_WriteOnly); |
1159 | f.writeBlock(list, list.length()); | 1158 | f.writeBlock(list, list.length()); |
1160 | f.close(); | 1159 | f.close(); |
1161 | } | 1160 | } |
1162 | if(fileDlg) delete fileDlg; | 1161 | if(fileDlg) delete fileDlg; |
1163 | } | 1162 | } |
1164 | 1163 | ||
1165 | void PlayListWidget::readPls(const QString &filename) { | 1164 | void PlayListWidget::readPls(const QString &filename) { |
1166 | 1165 | ||
1167 | qDebug("pls filename is "+filename); | 1166 | qDebug("pls filename is "+filename); |
1168 | QFile f(filename); | 1167 | QFile f(filename); |
1169 | 1168 | ||
1170 | if(f.open(IO_ReadOnly)) { | 1169 | if(f.open(IO_ReadOnly)) { |
1171 | QTextStream t(&f); | 1170 | QTextStream t(&f); |
1172 | QString s;//, first, second; | 1171 | QString s;//, first, second; |
1173 | int i=0; | 1172 | int i=0; |
1174 | while ( !t.atEnd()) { | 1173 | while ( !t.atEnd()) { |
1175 | s=t.readLine(); | 1174 | s=t.readLine(); |
1176 | if(s.left(4) == "File") { | 1175 | if(s.left(4) == "File") { |
1177 | s=s.right(s.length() - 6); | 1176 | s=s.right(s.length() - 6); |
1178 | s.replace(QRegExp("%20")," "); | 1177 | s.replace(QRegExp("%20")," "); |
1179 | qDebug("adding "+s+" to playlist"); | 1178 | qDebug("adding "+s+" to playlist"); |
1180 | // numberofentries=2 | 1179 | // numberofentries=2 |
1181 | // File1=http | 1180 | // File1=http |
1182 | // Title | 1181 | // Title |
1183 | // Length | 1182 | // Length |
1184 | // Version | 1183 | // Version |
1185 | // File2=http | 1184 | // File2=http |
1186 | s=s.replace( QRegExp("\\"),"/"); | 1185 | s=s.replace( QRegExp("\\"),"/"); |
1187 | DocLnk lnk( s ); | 1186 | DocLnk lnk( s ); |
1188 | QFileInfo f(s); | 1187 | QFileInfo f(s); |
1189 | QString name = f.baseName(); | 1188 | QString name = f.baseName(); |
1190 | if(name.left(4)=="http") | 1189 | if(name.left(4)=="http") |
1191 | name = s.right( s.length() - 7); | 1190 | name = s.right( s.length() - 7); |
1192 | else | 1191 | else |
1193 | name=s; | 1192 | name=s; |
1194 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1193 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1195 | lnk.setName( name); | 1194 | lnk.setName( name); |
1196 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1195 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1197 | lnk.setFile( s); | 1196 | lnk.setFile( s); |
1198 | else { //if its a url | 1197 | else { //if its a url |
1199 | if( name.right(1).find('/') == -1) | 1198 | if( name.right(1).find('/') == -1) |
1200 | s+="/"; | 1199 | s+="/"; |
1201 | lnk.setFile( s); | 1200 | lnk.setFile( s); |
1202 | } | 1201 | } |
1203 | lnk.setType("audio/x-mpegurl"); | 1202 | lnk.setType("audio/x-mpegurl"); |
1204 | 1203 | ||
1205 | qDebug("DocLnk add "+name); | 1204 | qDebug("DocLnk add "+name); |
1206 | d->selectedFiles->addToSelection( lnk); | 1205 | d->selectedFiles->addToSelection( lnk); |
1207 | } | 1206 | } |
1208 | } | 1207 | } |
1209 | i++; | 1208 | i++; |
1210 | } | 1209 | } |
1211 | } | 1210 | } |
1212 | 1211 | ||