author | simon <simon> | 2002-12-02 17:42:44 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 17:42:44 (UTC) |
commit | c31f9b59dba873739494fcd9916c7cb9120ce1d9 (patch) (unidiff) | |
tree | 4b3371edaf5f0f6f6240a7bfe8f16be1dc111e8d | |
parent | 2f2f6cfbc31e0144060588b26814301ce99ebd39 (diff) | |
download | opie-c31f9b59dba873739494fcd9916c7cb9120ce1d9.zip opie-c31f9b59dba873739494fcd9916c7cb9120ce1d9.tar.gz opie-c31f9b59dba873739494fcd9916c7cb9120ce1d9.tar.bz2 |
- don't enable the play button if switching to the playlist tab and the
playlist is empty
- don't crash when starting to play and no item is selected in the
playlist. instead select the first item then.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.h b/noncore/multimedia/opieplayer2/playlistselection.h index d10bc82..9cc4e30 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.h +++ b/noncore/multimedia/opieplayer2/playlistselection.h | |||
@@ -1,63 +1,65 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | class PlayListSelection : public QListView { | 28 | class PlayListSelection : public QListView { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | PlayListSelection( QWidget *parent, const char *name=0 ); | 31 | PlayListSelection( QWidget *parent, const char *name=0 ); |
32 | ~PlayListSelection(); | 32 | ~PlayListSelection(); |
33 | 33 | ||
34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) | 34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) |
35 | public slots: | 35 | public slots: |
36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
37 | void removeSelected(); // Remove a media file from the playlist | 37 | void removeSelected(); // Remove a media file from the playlist |
38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
40 | void unSelect(); | 40 | void unSelect(); |
41 | void writeCurrent( Config &); | 41 | void writeCurrent( Config &); |
42 | void setSelectedItem( const QString & ); | 42 | void setSelectedItem( const QString & ); |
43 | bool prev(); | 43 | bool prev(); |
44 | bool next(); | 44 | bool next(); |
45 | bool first(); | 45 | bool first(); |
46 | bool last(); | 46 | bool last(); |
47 | 47 | ||
48 | bool isEmpty() const { return childCount() == 0; } | ||
49 | |||
48 | protected: | 50 | protected: |
49 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 51 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
50 | /* #ifdef USE_PLAYLIST_BACKGROUND */ | 52 | /* #ifdef USE_PLAYLIST_BACKGROUND */ |
51 | virtual void drawBackground( QPainter *p, const QRect &r ); | 53 | virtual void drawBackground( QPainter *p, const QRect &r ); |
52 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 54 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
53 | /* #endif */ | 55 | /* #endif */ |
54 | 56 | ||
55 | private: | 57 | private: |
56 | QList<DocLnk> selectedList; | 58 | QList<DocLnk> selectedList; |
57 | const DocLnk *lnk; | 59 | const DocLnk *lnk; |
58 | }; | 60 | }; |
59 | 61 | ||
60 | 62 | ||
61 | #endif // PLAY_LIST_SELECTION_H | 63 | #endif // PLAY_LIST_SELECTION_H |
62 | 64 | ||
63 | 65 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index f53def6..b08204e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1120 +1,1128 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | 52 | ||
53 | //only needed for the random play | 53 | //only needed for the random play |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <assert.h> | 55 | #include <assert.h> |
56 | 56 | ||
57 | #include "audiowidget.h" | 57 | #include "audiowidget.h" |
58 | #include "videowidget.h" | 58 | #include "videowidget.h" |
59 | 59 | ||
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | // extern AudioWidget *audioUI; | 61 | // extern AudioWidget *audioUI; |
62 | // extern VideoWidget *videoUI; | 62 | // extern VideoWidget *videoUI; |
63 | 63 | ||
64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
65 | // no m3u's here please | 65 | // no m3u's here please |
66 | 66 | ||
67 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 67 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
68 | : PlayListWidgetGui( parent, name, fl ) { | 68 | : PlayListWidgetGui( parent, name, fl ) { |
69 | 69 | ||
70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
71 | "opieplayer2/add_to_playlist", | 71 | "opieplayer2/add_to_playlist", |
72 | this , SLOT(addSelected() ) ); | 72 | this , SLOT(addSelected() ) ); |
73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
74 | "opieplayer2/remove_from_playlist", | 74 | "opieplayer2/remove_from_playlist", |
75 | this , SLOT(removeSelected() ) ); | 75 | this , SLOT(removeSelected() ) ); |
76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
77 | this , SLOT( btnPlay( bool) ), TRUE ); | 77 | this , SLOT( btnPlay( bool) ), TRUE ); |
78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
79 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 79 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
81 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 81 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
82 | 82 | ||
83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
85 | this, SLOT( addAllMusicToList() ) ); | 85 | this, SLOT( addAllMusicToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
87 | this, SLOT( addAllVideoToList() ) ); | 87 | this, SLOT( addAllVideoToList() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
89 | this, SLOT( addAllToList() ) ); | 89 | this, SLOT( addAllToList() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
92 | // this, SLOT( saveList() ) ); | 92 | // this, SLOT( saveList() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
94 | this, SLOT(writem3u() ) ); | 94 | this, SLOT(writem3u() ) ); |
95 | pmPlayList->insertSeparator(-1); | 95 | pmPlayList->insertSeparator(-1); |
96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
97 | this,SLOT( openFile() ) ); | 97 | this,SLOT( openFile() ) ); |
98 | pmPlayList->insertSeparator(-1); | 98 | pmPlayList->insertSeparator(-1); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
100 | this,SLOT( scanForAudio() ) ); | 100 | this,SLOT( scanForAudio() ) ); |
101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
102 | this,SLOT( scanForVideo() ) ); | 102 | this,SLOT( scanForVideo() ) ); |
103 | 103 | ||
104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
105 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 105 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
106 | 106 | ||
107 | Config cfg( "OpiePlayer" ); | 107 | Config cfg( "OpiePlayer" ); |
108 | bool b= cfg.readBoolEntry("FullScreen", 0); | 108 | bool b= cfg.readBoolEntry("FullScreen", 0); |
109 | mediaPlayerState->setFullscreen( b ); | 109 | mediaPlayerState->setFullscreen( b ); |
110 | pmView->setItemChecked( -16, b ); | 110 | pmView->setItemChecked( -16, b ); |
111 | 111 | ||
112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
115 | d->selectedFiles, SLOT(removeSelected() ) ); | 115 | d->selectedFiles, SLOT(removeSelected() ) ); |
116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
118 | // QVBox *stretch2 = new QVBox( vbox1 ); | 118 | // QVBox *stretch2 = new QVBox( vbox1 ); |
119 | 119 | ||
120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
121 | SLOT( deletePlaylist() ) ); | 121 | SLOT( deletePlaylist() ) ); |
122 | connect( pmView, SIGNAL( activated( int ) ), | 122 | connect( pmView, SIGNAL( activated( int ) ), |
123 | this, SLOT( pmViewActivated( int ) ) ); | 123 | this, SLOT( pmViewActivated( int ) ) ); |
124 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 124 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
125 | this, SLOT( skinsMenuActivated( int ) ) ); | 125 | this, SLOT( skinsMenuActivated( int ) ) ); |
126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
131 | this,SLOT( playIt( QListViewItem *) ) ); | 131 | this,SLOT( playIt( QListViewItem *) ) ); |
132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
133 | this, SLOT( addToSelection( QListViewItem *) ) ); | 133 | this, SLOT( addToSelection( QListViewItem *) ) ); |
134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
137 | this,SLOT( playIt( QListViewItem *) ) ); | 137 | this,SLOT( playIt( QListViewItem *) ) ); |
138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
139 | this, SLOT( addToSelection( QListViewItem *) ) ); | 139 | this, SLOT( addToSelection( QListViewItem *) ) ); |
140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
141 | this, SLOT( loadList( const DocLnk & ) ) ); | 141 | this, SLOT( loadList( const DocLnk & ) ) ); |
142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
143 | this, SLOT( tabChanged( QWidget* ) ) ); | 143 | this, SLOT( tabChanged( QWidget* ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
145 | d->tbPlay, SLOT( setOn( bool ) ) ); | 145 | d->tbPlay, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
147 | d->tbLoop, SLOT( setOn( bool ) ) ); | 147 | d->tbLoop, SLOT( setOn( bool ) ) ); |
148 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 148 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
149 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 149 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 154 | ||
155 | // see which skins are installed | 155 | // see which skins are installed |
156 | videoScan=false; | 156 | videoScan=false; |
157 | audioScan=false; | 157 | audioScan=false; |
158 | audioPopulated=false; | 158 | audioPopulated=false; |
159 | videoPopulated=false; | 159 | videoPopulated=false; |
160 | populateSkinsMenu(); | 160 | populateSkinsMenu(); |
161 | initializeStates(); | 161 | initializeStates(); |
162 | 162 | ||
163 | cfg.setGroup("PlayList"); | 163 | cfg.setGroup("PlayList"); |
164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
165 | loadList(DocLnk( currentPlaylist ) ); | 165 | loadList(DocLnk( currentPlaylist ) ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | PlayListWidget::~PlayListWidget() { | 169 | PlayListWidget::~PlayListWidget() { |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
178 | d->playListFrame->show(); | 178 | d->playListFrame->show(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 182 | ||
183 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 187 | if( currentString == filename) { |
188 | Om3u *m3uList; | 188 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | 190 | if( d->selectedFiles->first() ) { |
191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
192 | do { | 192 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 193 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 194 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 195 | } |
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | 201 | ||
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
208 | if( QFileInfo( lnk.file() ).exists() || | 208 | if( QFileInfo( lnk.file() ).exists() || |
209 | lnk.file().left(4) == "http" ) { | 209 | lnk.file().left(4) == "http" ) { |
210 | d->selectedFiles->addToSelection( lnk ); | 210 | d->selectedFiles->addToSelection( lnk ); |
211 | } | 211 | } |
212 | // writeCurrentM3u(); | 212 | // writeCurrentM3u(); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void PlayListWidget::clearList() { | 216 | void PlayListWidget::clearList() { |
217 | while ( first() ) { | 217 | while ( first() ) { |
218 | d->selectedFiles->removeSelected(); | 218 | d->selectedFiles->removeSelected(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 223 | switch (mouse) { |
224 | case 1: | 224 | case 1: |
225 | break; | 225 | break; |
226 | case 2: | 226 | case 2: |
227 | { | 227 | { |
228 | QPopupMenu m; | 228 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 239 | switch (mouse) { |
240 | case 1: | 240 | case 1: |
241 | break; | 241 | break; |
242 | case 2: | 242 | case 2: |
243 | { | 243 | { |
244 | QPopupMenu m; | 244 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 247 | m.exec( QCursor::pos() ); |
248 | } | 248 | } |
249 | break; | 249 | break; |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void PlayListWidget::addAllToList() { | 254 | void PlayListWidget::addAllToList() { |
255 | 255 | ||
256 | // QTime t; | 256 | // QTime t; |
257 | // t.start(); | 257 | // t.start(); |
258 | 258 | ||
259 | if(!audioScan) { | 259 | if(!audioScan) { |
260 | if(audioView->childCount() < 1) | 260 | if(audioView->childCount() < 1) |
261 | populateAudioView(); | 261 | populateAudioView(); |
262 | } | 262 | } |
263 | 263 | ||
264 | QListViewItemIterator audioIt( audioView ); | 264 | QListViewItemIterator audioIt( audioView ); |
265 | DocLnk lnk; | 265 | DocLnk lnk; |
266 | QString filename; | 266 | QString filename; |
267 | // iterate through all items of the listview | 267 | // iterate through all items of the listview |
268 | for ( ; audioIt.current(); ++audioIt ) { | 268 | for ( ; audioIt.current(); ++audioIt ) { |
269 | filename = audioIt.current()->text(3); | 269 | filename = audioIt.current()->text(3); |
270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
271 | lnk.setFile( filename ); //sets file name | 271 | lnk.setFile( filename ); //sets file name |
272 | d->selectedFiles->addToSelection( lnk); | 272 | d->selectedFiles->addToSelection( lnk); |
273 | } | 273 | } |
274 | 274 | ||
275 | if(!videoScan) { | 275 | if(!videoScan) { |
276 | if(videoView->childCount() < 1) | 276 | if(videoView->childCount() < 1) |
277 | populateVideoView(); | 277 | populateVideoView(); |
278 | } | 278 | } |
279 | 279 | ||
280 | QListViewItemIterator videoIt( videoView ); | 280 | QListViewItemIterator videoIt( videoView ); |
281 | for ( ; videoIt.current(); ++videoIt ) { | 281 | for ( ; videoIt.current(); ++videoIt ) { |
282 | filename = videoIt.current()->text(3); | 282 | filename = videoIt.current()->text(3); |
283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
284 | lnk.setFile( filename ); //sets file name | 284 | lnk.setFile( filename ); //sets file name |
285 | d->selectedFiles->addToSelection( lnk); | 285 | d->selectedFiles->addToSelection( lnk); |
286 | } | 286 | } |
287 | 287 | ||
288 | // d->selectedFiles->addToSelection( ); | 288 | // d->selectedFiles->addToSelection( ); |
289 | // if ( it.current()->isSelected() ) | 289 | // if ( it.current()->isSelected() ) |
290 | // lst->append( audioIt.current() ); | 290 | // lst->append( audioIt.current() ); |
291 | // } | 291 | // } |
292 | 292 | ||
293 | 293 | ||
294 | // if(!audioScan) | 294 | // if(!audioScan) |
295 | // scanForAudio(); | 295 | // scanForAudio(); |
296 | // if(!videoScan) | 296 | // if(!videoScan) |
297 | // scanForVideo(); | 297 | // scanForVideo(); |
298 | 298 | ||
299 | // DocLnkSet filesAll; | 299 | // DocLnkSet filesAll; |
300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
301 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 301 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
302 | // for ( ; Adit.current(); ++Adit ) { | 302 | // for ( ; Adit.current(); ++Adit ) { |
303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
304 | // d->selectedFiles->addToSelection( **Adit ); | 304 | // d->selectedFiles->addToSelection( **Adit ); |
305 | // } | 305 | // } |
306 | // } | 306 | // } |
307 | 307 | ||
308 | // qDebug("elapsed time %d", t.elapsed() ); | 308 | // qDebug("elapsed time %d", t.elapsed() ); |
309 | 309 | ||
310 | tabWidget->setCurrentPage(0); | 310 | tabWidget->setCurrentPage(0); |
311 | 311 | ||
312 | writeCurrentM3u(); | 312 | writeCurrentM3u(); |
313 | d->selectedFiles->first(); | 313 | d->selectedFiles->first(); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void PlayListWidget::addAllMusicToList() { | 317 | void PlayListWidget::addAllMusicToList() { |
318 | 318 | ||
319 | if(!audioScan) { | 319 | if(!audioScan) { |
320 | if(audioView->childCount() < 1) | 320 | if(audioView->childCount() < 1) |
321 | populateAudioView(); | 321 | populateAudioView(); |
322 | } | 322 | } |
323 | 323 | ||
324 | QListViewItemIterator audioIt( audioView ); | 324 | QListViewItemIterator audioIt( audioView ); |
325 | DocLnk lnk; | 325 | DocLnk lnk; |
326 | QString filename; | 326 | QString filename; |
327 | // iterate through all items of the listview | 327 | // iterate through all items of the listview |
328 | for ( ; audioIt.current(); ++audioIt ) { | 328 | for ( ; audioIt.current(); ++audioIt ) { |
329 | filename = audioIt.current()->text(3); | 329 | filename = audioIt.current()->text(3); |
330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
331 | lnk.setFile( filename ); //sets file name | 331 | lnk.setFile( filename ); //sets file name |
332 | d->selectedFiles->addToSelection( lnk); | 332 | d->selectedFiles->addToSelection( lnk); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* if(!audioScan) | 335 | /* if(!audioScan) |
336 | scanForAudio(); | 336 | scanForAudio(); |
337 | QListIterator<DocLnk> dit( files.children() ); | 337 | QListIterator<DocLnk> dit( files.children() ); |
338 | for ( ; dit.current(); ++dit ) { | 338 | for ( ; dit.current(); ++dit ) { |
339 | if( QFileInfo(dit.current()->file() ).exists() ) { | 339 | if( QFileInfo(dit.current()->file() ).exists() ) { |
340 | d->selectedFiles->addToSelection( **dit ); | 340 | d->selectedFiles->addToSelection( **dit ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | */ | 343 | */ |
344 | tabWidget->setCurrentPage(0); | 344 | tabWidget->setCurrentPage(0); |
345 | writeCurrentM3u(); | 345 | writeCurrentM3u(); |
346 | d->selectedFiles->first(); | 346 | d->selectedFiles->first(); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | void PlayListWidget::addAllVideoToList() { | 350 | void PlayListWidget::addAllVideoToList() { |
351 | 351 | ||
352 | if(!videoScan) { | 352 | if(!videoScan) { |
353 | if(videoView->childCount() < 1) | 353 | if(videoView->childCount() < 1) |
354 | populateVideoView(); | 354 | populateVideoView(); |
355 | } | 355 | } |
356 | 356 | ||
357 | QListViewItemIterator videoIt( videoView ); | 357 | QListViewItemIterator videoIt( videoView ); |
358 | DocLnk lnk; | 358 | DocLnk lnk; |
359 | QString filename; | 359 | QString filename; |
360 | for ( ; videoIt.current(); ++videoIt ) { | 360 | for ( ; videoIt.current(); ++videoIt ) { |
361 | filename = videoIt.current()->text(3); | 361 | filename = videoIt.current()->text(3); |
362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
363 | lnk.setFile( filename ); //sets file name | 363 | lnk.setFile( filename ); //sets file name |
364 | d->selectedFiles->addToSelection( lnk); | 364 | d->selectedFiles->addToSelection( lnk); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | /* if(!videoScan) | 368 | /* if(!videoScan) |
369 | scanForVideo(); | 369 | scanForVideo(); |
370 | QListIterator<DocLnk> dit( vFiles.children() ); | 370 | QListIterator<DocLnk> dit( vFiles.children() ); |
371 | for ( ; dit.current(); ++dit ) { | 371 | for ( ; dit.current(); ++dit ) { |
372 | if( QFileInfo( dit.current()->file() ).exists() ) { | 372 | if( QFileInfo( dit.current()->file() ).exists() ) { |
373 | d->selectedFiles->addToSelection( **dit ); | 373 | d->selectedFiles->addToSelection( **dit ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | */ | 376 | */ |
377 | tabWidget->setCurrentPage(0); | 377 | tabWidget->setCurrentPage(0); |
378 | writeCurrentM3u(); | 378 | writeCurrentM3u(); |
379 | d->selectedFiles->first(); | 379 | d->selectedFiles->first(); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | void PlayListWidget::setDocument( const QString& fileref ) { | 383 | void PlayListWidget::setDocument( const QString& fileref ) { |
384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
385 | fromSetDocument = TRUE; | 385 | fromSetDocument = TRUE; |
386 | if ( fileref.isNull() ) { | 386 | if ( fileref.isNull() ) { |
387 | QMessageBox::warning( this, tr( "Invalid File" ), | 387 | QMessageBox::warning( this, tr( "Invalid File" ), |
388 | tr( "There was a problem in getting the file." ) ); | 388 | tr( "There was a problem in getting the file." ) ); |
389 | return; | 389 | return; |
390 | } | 390 | } |
391 | 391 | ||
392 | clearList(); | 392 | clearList(); |
393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
394 | readm3u( fileref ); | 394 | readm3u( fileref ); |
395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
396 | readm3u( DocLnk( fileref).file() ); | 396 | readm3u( DocLnk( fileref).file() ); |
397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
398 | readPls( fileref ); | 398 | readPls( fileref ); |
399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
400 | readPls( DocLnk( fileref).file() ); | 400 | readPls( DocLnk( fileref).file() ); |
401 | } else { | 401 | } else { |
402 | clearList(); | 402 | clearList(); |
403 | addToSelection( DocLnk( fileref ) ); | 403 | addToSelection( DocLnk( fileref ) ); |
404 | writeCurrentM3u(); | 404 | writeCurrentM3u(); |
405 | 405 | ||
406 | d->setDocumentUsed = TRUE; | 406 | d->setDocumentUsed = TRUE; |
407 | mediaPlayerState->setPlaying( FALSE ); | 407 | mediaPlayerState->setPlaying( FALSE ); |
408 | mediaPlayerState->setPlaying( TRUE ); | 408 | mediaPlayerState->setPlaying( TRUE ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | void PlayListWidget::useSelectedDocument() { | 413 | void PlayListWidget::useSelectedDocument() { |
414 | d->setDocumentUsed = FALSE; | 414 | d->setDocumentUsed = FALSE; |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | const DocLnk *PlayListWidget::current() const { // this is fugly | 418 | const DocLnk *PlayListWidget::current() const { // this is fugly |
419 | assert( currentTab() == CurrentPlayList ); | 419 | assert( currentTab() == CurrentPlayList ); |
420 | 420 | ||
421 | return d->selectedFiles->current(); | 421 | const DocLnk *lnk = d->selectedFiles->current(); |
422 | if ( !lnk ) { | ||
423 | d->selectedFiles->first(); | ||
424 | lnk = d->selectedFiles->current(); | ||
425 | } | ||
426 | assert( lnk ); | ||
427 | return lnk; | ||
422 | } | 428 | } |
423 | 429 | ||
424 | 430 | ||
425 | bool PlayListWidget::prev() { | 431 | bool PlayListWidget::prev() { |
426 | if ( mediaPlayerState->isShuffled() ) { | 432 | if ( mediaPlayerState->isShuffled() ) { |
427 | const DocLnk *cur = current(); | 433 | const DocLnk *cur = current(); |
428 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 434 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
429 | for ( int i = 0; i < j; i++ ) { | 435 | for ( int i = 0; i < j; i++ ) { |
430 | if ( !d->selectedFiles->next() ) | 436 | if ( !d->selectedFiles->next() ) |
431 | d->selectedFiles->first(); | 437 | d->selectedFiles->first(); |
432 | } | 438 | } |
433 | if ( cur == current() ) | 439 | if ( cur == current() ) |
434 | if ( !d->selectedFiles->next() ) { | 440 | if ( !d->selectedFiles->next() ) { |
435 | d->selectedFiles->first(); | 441 | d->selectedFiles->first(); |
436 | } | 442 | } |
437 | return TRUE; | 443 | return TRUE; |
438 | } else { | 444 | } else { |
439 | if ( !d->selectedFiles->prev() ) { | 445 | if ( !d->selectedFiles->prev() ) { |
440 | if ( mediaPlayerState->isLooping() ) { | 446 | if ( mediaPlayerState->isLooping() ) { |
441 | return d->selectedFiles->last(); | 447 | return d->selectedFiles->last(); |
442 | } else { | 448 | } else { |
443 | return FALSE; | 449 | return FALSE; |
444 | } | 450 | } |
445 | } | 451 | } |
446 | return TRUE; | 452 | return TRUE; |
447 | } | 453 | } |
448 | } | 454 | } |
449 | 455 | ||
450 | 456 | ||
451 | bool PlayListWidget::next() { | 457 | bool PlayListWidget::next() { |
452 | //qDebug("<<<<<<<<<<<<next()"); | 458 | //qDebug("<<<<<<<<<<<<next()"); |
453 | if ( mediaPlayerState->isShuffled() ) { | 459 | if ( mediaPlayerState->isShuffled() ) { |
454 | return prev(); | 460 | return prev(); |
455 | } else { | 461 | } else { |
456 | if ( !d->selectedFiles->next() ) { | 462 | if ( !d->selectedFiles->next() ) { |
457 | if ( mediaPlayerState->isLooping() ) { | 463 | if ( mediaPlayerState->isLooping() ) { |
458 | return d->selectedFiles->first(); | 464 | return d->selectedFiles->first(); |
459 | } else { | 465 | } else { |
460 | return FALSE; | 466 | return FALSE; |
461 | } | 467 | } |
462 | } | 468 | } |
463 | return TRUE; | 469 | return TRUE; |
464 | } | 470 | } |
465 | } | 471 | } |
466 | 472 | ||
467 | 473 | ||
468 | bool PlayListWidget::first() { | 474 | bool PlayListWidget::first() { |
469 | return d->selectedFiles->first(); | 475 | return d->selectedFiles->first(); |
470 | } | 476 | } |
471 | 477 | ||
472 | 478 | ||
473 | bool PlayListWidget::last() { | 479 | bool PlayListWidget::last() { |
474 | return d->selectedFiles->last(); | 480 | return d->selectedFiles->last(); |
475 | } | 481 | } |
476 | 482 | ||
477 | 483 | ||
478 | void PlayListWidget::saveList() { | 484 | void PlayListWidget::saveList() { |
479 | writem3u(); | 485 | writem3u(); |
480 | } | 486 | } |
481 | 487 | ||
482 | 488 | ||
483 | void PlayListWidget::loadList( const DocLnk & lnk) { | 489 | void PlayListWidget::loadList( const DocLnk & lnk) { |
484 | QString name = lnk.name(); | 490 | QString name = lnk.name(); |
485 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 491 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
486 | 492 | ||
487 | if( name.length()>0) { | 493 | if( name.length()>0) { |
488 | setCaption("OpiePlayer: "+name); | 494 | setCaption("OpiePlayer: "+name); |
489 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 495 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
490 | clearList(); | 496 | clearList(); |
491 | readm3u(lnk.file()); | 497 | readm3u(lnk.file()); |
492 | tabWidget->setCurrentPage(0); | 498 | tabWidget->setCurrentPage(0); |
493 | } | 499 | } |
494 | } | 500 | } |
495 | 501 | ||
496 | void PlayListWidget::addSelected() { | 502 | void PlayListWidget::addSelected() { |
497 | assert( inFileListMode() ); | 503 | assert( inFileListMode() ); |
498 | 504 | ||
499 | QListView *fileListView = currentFileListView(); | 505 | QListView *fileListView = currentFileListView(); |
500 | QListViewItemIterator it( fileListView ); | 506 | QListViewItemIterator it( fileListView ); |
501 | for ( ; it.current(); ++it ) | 507 | for ( ; it.current(); ++it ) |
502 | if ( it.current()->isSelected() ) { | 508 | if ( it.current()->isSelected() ) { |
503 | QString filename = it.current()->text(3); | 509 | QString filename = it.current()->text(3); |
504 | 510 | ||
505 | DocLnk lnk; | 511 | DocLnk lnk; |
506 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 512 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
507 | lnk.setFile( filename ); //sets file name | 513 | lnk.setFile( filename ); //sets file name |
508 | 514 | ||
509 | d->selectedFiles->addToSelection( lnk ); | 515 | d->selectedFiles->addToSelection( lnk ); |
510 | } | 516 | } |
511 | 517 | ||
512 | fileListView->clearSelection(); | 518 | fileListView->clearSelection(); |
513 | 519 | ||
514 | tabWidget->setCurrentPage( 0 ); | 520 | tabWidget->setCurrentPage( 0 ); |
515 | writeCurrentM3u(); | 521 | writeCurrentM3u(); |
516 | } | 522 | } |
517 | 523 | ||
518 | 524 | ||
519 | void PlayListWidget::removeSelected() { | 525 | void PlayListWidget::removeSelected() { |
520 | d->selectedFiles->removeSelected( ); | 526 | d->selectedFiles->removeSelected( ); |
521 | writeCurrentM3u(); | 527 | writeCurrentM3u(); |
522 | } | 528 | } |
523 | 529 | ||
524 | 530 | ||
525 | void PlayListWidget::playIt( QListViewItem *it) { | 531 | void PlayListWidget::playIt( QListViewItem *it) { |
526 | if(!it) return; | 532 | if(!it) return; |
527 | mediaPlayerState->setPlaying(FALSE); | 533 | mediaPlayerState->setPlaying(FALSE); |
528 | mediaPlayerState->setPlaying(TRUE); | 534 | mediaPlayerState->setPlaying(TRUE); |
529 | d->selectedFiles->unSelect(); | 535 | d->selectedFiles->unSelect(); |
530 | } | 536 | } |
531 | 537 | ||
532 | 538 | ||
533 | void PlayListWidget::addToSelection( QListViewItem *it) { | 539 | void PlayListWidget::addToSelection( QListViewItem *it) { |
534 | d->setDocumentUsed = FALSE; | 540 | d->setDocumentUsed = FALSE; |
535 | 541 | ||
536 | if(it) { | 542 | if(it) { |
537 | if ( currentTab() == CurrentPlayList ) | 543 | if ( currentTab() == CurrentPlayList ) |
538 | return; | 544 | return; |
539 | // case 1: { | 545 | // case 1: { |
540 | DocLnk lnk; | 546 | DocLnk lnk; |
541 | QString filename; | 547 | QString filename; |
542 | 548 | ||
543 | filename=it->text(3); | 549 | filename=it->text(3); |
544 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
545 | lnk.setFile( filename ); //sets file name | 551 | lnk.setFile( filename ); //sets file name |
546 | d->selectedFiles->addToSelection( lnk); | 552 | d->selectedFiles->addToSelection( lnk); |
547 | 553 | ||
548 | writeCurrentM3u(); | 554 | writeCurrentM3u(); |
549 | tabWidget->setCurrentPage(0); | 555 | tabWidget->setCurrentPage(0); |
550 | 556 | ||
551 | } | 557 | } |
552 | } | 558 | } |
553 | 559 | ||
554 | 560 | ||
555 | void PlayListWidget::tabChanged(QWidget *) { | 561 | void PlayListWidget::tabChanged(QWidget *) { |
556 | 562 | ||
557 | d->tbPlay->setEnabled( true ); | 563 | d->tbPlay->setEnabled( true ); |
558 | 564 | ||
559 | switch ( currentTab() ) { | 565 | switch ( currentTab() ) { |
560 | case CurrentPlayList: | 566 | case CurrentPlayList: |
561 | { | 567 | { |
562 | if( !tbDeletePlaylist->isHidden() ) { | 568 | if( !tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->hide(); | 569 | tbDeletePlaylist->hide(); |
564 | } | 570 | } |
565 | d->tbRemoveFromList->setEnabled(TRUE); | 571 | d->tbRemoveFromList->setEnabled(TRUE); |
566 | d->tbAddToList->setEnabled(FALSE); | 572 | d->tbAddToList->setEnabled(FALSE); |
573 | |||
574 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | ||
567 | } | 575 | } |
568 | break; | 576 | break; |
569 | case AudioFiles: | 577 | case AudioFiles: |
570 | { | 578 | { |
571 | // audioView->clear(); | 579 | // audioView->clear(); |
572 | if(!audioPopulated) populateAudioView(); | 580 | if(!audioPopulated) populateAudioView(); |
573 | 581 | ||
574 | if( !tbDeletePlaylist->isHidden() ) { | 582 | if( !tbDeletePlaylist->isHidden() ) { |
575 | tbDeletePlaylist->hide(); | 583 | tbDeletePlaylist->hide(); |
576 | } | 584 | } |
577 | d->tbRemoveFromList->setEnabled(FALSE); | 585 | d->tbRemoveFromList->setEnabled(FALSE); |
578 | d->tbAddToList->setEnabled(TRUE); | 586 | d->tbAddToList->setEnabled(TRUE); |
579 | } | 587 | } |
580 | break; | 588 | break; |
581 | case VideoFiles: | 589 | case VideoFiles: |
582 | { | 590 | { |
583 | // videoView->clear(); | 591 | // videoView->clear(); |
584 | if(!videoPopulated) populateVideoView(); | 592 | if(!videoPopulated) populateVideoView(); |
585 | if( !tbDeletePlaylist->isHidden() ) { | 593 | if( !tbDeletePlaylist->isHidden() ) { |
586 | tbDeletePlaylist->hide(); | 594 | tbDeletePlaylist->hide(); |
587 | } | 595 | } |
588 | d->tbRemoveFromList->setEnabled(FALSE); | 596 | d->tbRemoveFromList->setEnabled(FALSE); |
589 | d->tbAddToList->setEnabled(TRUE); | 597 | d->tbAddToList->setEnabled(TRUE); |
590 | } | 598 | } |
591 | break; | 599 | break; |
592 | case PlayLists: | 600 | case PlayLists: |
593 | { | 601 | { |
594 | if( tbDeletePlaylist->isHidden() ) { | 602 | if( tbDeletePlaylist->isHidden() ) { |
595 | tbDeletePlaylist->show(); | 603 | tbDeletePlaylist->show(); |
596 | } | 604 | } |
597 | playLists->reread(); | 605 | playLists->reread(); |
598 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
599 | 607 | ||
600 | d->tbPlay->setEnabled( false ); | 608 | d->tbPlay->setEnabled( false ); |
601 | } | 609 | } |
602 | break; | 610 | break; |
603 | }; | 611 | }; |
604 | } | 612 | } |
605 | 613 | ||
606 | 614 | ||
607 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
608 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
609 | mediaPlayerState->setPlaying(b); | 617 | mediaPlayerState->setPlaying(b); |
610 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
611 | } | 619 | } |
612 | 620 | ||
613 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
614 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
615 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
616 | (tr("Yes")), (tr("No")), 0 )){ | 624 | (tr("Yes")), (tr("No")), 0 )){ |
617 | case 0: // Yes clicked, | 625 | case 0: // Yes clicked, |
618 | QFile().remove(playLists->selectedDocument().file()); | 626 | QFile().remove(playLists->selectedDocument().file()); |
619 | QFile().remove(playLists->selectedDocument().linkFile()); | 627 | QFile().remove(playLists->selectedDocument().linkFile()); |
620 | playLists->reread(); | 628 | playLists->reread(); |
621 | break; | 629 | break; |
622 | case 1: // Cancel | 630 | case 1: // Cancel |
623 | break; | 631 | break; |
624 | }; | 632 | }; |
625 | } | 633 | } |
626 | 634 | ||
627 | 635 | ||
628 | void PlayListWidget::playSelected() { | 636 | void PlayListWidget::playSelected() { |
629 | btnPlay( TRUE); | 637 | btnPlay( TRUE); |
630 | } | 638 | } |
631 | 639 | ||
632 | 640 | ||
633 | void PlayListWidget::scanForAudio() { | 641 | void PlayListWidget::scanForAudio() { |
634 | // qDebug("scan for audio"); | 642 | // qDebug("scan for audio"); |
635 | files.detachChildren(); | 643 | files.detachChildren(); |
636 | QListIterator<DocLnk> sdit( files.children() ); | 644 | QListIterator<DocLnk> sdit( files.children() ); |
637 | for ( ; sdit.current(); ++sdit ) { | 645 | for ( ; sdit.current(); ++sdit ) { |
638 | delete sdit.current(); | 646 | delete sdit.current(); |
639 | } | 647 | } |
640 | // Global::findDocuments( &files, "audio/*"); | 648 | // Global::findDocuments( &files, "audio/*"); |
641 | Global::findDocuments( &files, audioMimes); | 649 | Global::findDocuments( &files, audioMimes); |
642 | audioScan = true; | 650 | audioScan = true; |
643 | populateAudioView(); | 651 | populateAudioView(); |
644 | } | 652 | } |
645 | 653 | ||
646 | void PlayListWidget::scanForVideo() { | 654 | void PlayListWidget::scanForVideo() { |
647 | // qDebug("scan for video"); | 655 | // qDebug("scan for video"); |
648 | vFiles.detachChildren(); | 656 | vFiles.detachChildren(); |
649 | QListIterator<DocLnk> sdit( vFiles.children() ); | 657 | QListIterator<DocLnk> sdit( vFiles.children() ); |
650 | for ( ; sdit.current(); ++sdit ) { | 658 | for ( ; sdit.current(); ++sdit ) { |
651 | delete sdit.current(); | 659 | delete sdit.current(); |
652 | } | 660 | } |
653 | Global::findDocuments(&vFiles, "video/*"); | 661 | Global::findDocuments(&vFiles, "video/*"); |
654 | videoScan = true; | 662 | videoScan = true; |
655 | populateVideoView(); | 663 | populateVideoView(); |
656 | } | 664 | } |
657 | 665 | ||
658 | void PlayListWidget::populateAudioView() { | 666 | void PlayListWidget::populateAudioView() { |
659 | audioView->clear(); | 667 | audioView->clear(); |
660 | StorageInfo storageInfo; | 668 | StorageInfo storageInfo; |
661 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
662 | if(!audioScan) { | 670 | if(!audioScan) { |
663 | scanForAudio(); | 671 | scanForAudio(); |
664 | } | 672 | } |
665 | 673 | ||
666 | QListIterator<DocLnk> dit( files.children() ); | 674 | QListIterator<DocLnk> dit( files.children() ); |
667 | // QListIterator<FileSystem> it ( fs ); | 675 | // QListIterator<FileSystem> it ( fs ); |
668 | audioView->clear(); | 676 | audioView->clear(); |
669 | 677 | ||
670 | QString storage; | 678 | QString storage; |
671 | for ( ; dit.current(); ++dit ) { | 679 | for ( ; dit.current(); ++dit ) { |
672 | // // for( ; it.current(); ++it ){ | 680 | // // for( ; it.current(); ++it ){ |
673 | // const QString name = (*dit)->name(); | 681 | // const QString name = (*dit)->name(); |
674 | // const QString path = (*dit)->path(); | 682 | // const QString path = (*dit)->path(); |
675 | // if(dit.current()->file().find(path) != -1 ) { | 683 | // if(dit.current()->file().find(path) != -1 ) { |
676 | // storage = name; | 684 | // storage = name; |
677 | // // } | 685 | // // } |
678 | // } | 686 | // } |
679 | 687 | ||
680 | QListViewItem * newItem; | 688 | QListViewItem * newItem; |
681 | if ( QFile( dit.current()->file()).exists() || | 689 | if ( QFile( dit.current()->file()).exists() || |
682 | dit.current()->file().left(4) == "http" ) { | 690 | dit.current()->file().left(4) == "http" ) { |
683 | long size; | 691 | long size; |
684 | if( dit.current()->file().left(4) == "http" ) | 692 | if( dit.current()->file().left(4) == "http" ) |
685 | size=0; | 693 | size=0; |
686 | else | 694 | else |
687 | size = QFile( dit.current()->file() ).size(); | 695 | size = QFile( dit.current()->file() ).size(); |
688 | 696 | ||
689 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
690 | QString::number(size ), "" /*storage*/, | 698 | QString::number(size ), "" /*storage*/, |
691 | dit.current()->file() ); | 699 | dit.current()->file() ); |
692 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
693 | // qDebug("<<<< "+dit.current()->file()); | 701 | // qDebug("<<<< "+dit.current()->file()); |
694 | } | 702 | } |
695 | } | 703 | } |
696 | audioPopulated=true; | 704 | audioPopulated=true; |
697 | } | 705 | } |
698 | 706 | ||
699 | 707 | ||
700 | void PlayListWidget::populateVideoView() { | 708 | void PlayListWidget::populateVideoView() { |
701 | videoView->clear(); | 709 | videoView->clear(); |
702 | StorageInfo storageInfo; | 710 | StorageInfo storageInfo; |
703 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 711 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
704 | 712 | ||
705 | if(!videoScan ) { | 713 | if(!videoScan ) { |
706 | scanForVideo(); | 714 | scanForVideo(); |
707 | } | 715 | } |
708 | 716 | ||
709 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 717 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
710 | // QListIterator<FileSystem> it ( fs ); | 718 | // QListIterator<FileSystem> it ( fs ); |
711 | videoView->clear(); | 719 | videoView->clear(); |
712 | QString storage, pathName; | 720 | QString storage, pathName; |
713 | for ( ; Vdit.current(); ++Vdit ) { | 721 | for ( ; Vdit.current(); ++Vdit ) { |
714 | // // for( ; it.current(); ++it ) { | 722 | // // for( ; it.current(); ++it ) { |
715 | // const QString name = (*Vdit)->name(); | 723 | // const QString name = (*Vdit)->name(); |
716 | // const QString path = (*Vdit)->path(); | 724 | // const QString path = (*Vdit)->path(); |
717 | // if( Vdit.current()->file().find(path) != -1 ) { | 725 | // if( Vdit.current()->file().find(path) != -1 ) { |
718 | // storage=name; | 726 | // storage=name; |
719 | // pathName=path; | 727 | // pathName=path; |
720 | // // } | 728 | // // } |
721 | // } | 729 | // } |
722 | 730 | ||
723 | QListViewItem * newItem; | 731 | QListViewItem * newItem; |
724 | if ( QFile( Vdit.current()->file() ).exists() ) { | 732 | if ( QFile( Vdit.current()->file() ).exists() ) { |
725 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 733 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
726 | QString::number( QFile( Vdit.current()->file() ).size() ), | 734 | QString::number( QFile( Vdit.current()->file() ).size() ), |
727 | ""/*storage*/, Vdit.current()->file()); | 735 | ""/*storage*/, Vdit.current()->file()); |
728 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 736 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
729 | } | 737 | } |
730 | } | 738 | } |
731 | videoPopulated=true; | 739 | videoPopulated=true; |
732 | } | 740 | } |
733 | 741 | ||
734 | QListView *PlayListWidget::currentFileListView() const | 742 | QListView *PlayListWidget::currentFileListView() const |
735 | { | 743 | { |
736 | switch ( currentTab() ) { | 744 | switch ( currentTab() ) { |
737 | case AudioFiles: return audioView; | 745 | case AudioFiles: return audioView; |
738 | case VideoFiles: return videoView; | 746 | case VideoFiles: return videoView; |
739 | default: assert( false ); | 747 | default: assert( false ); |
740 | } | 748 | } |
741 | return 0; | 749 | return 0; |
742 | } | 750 | } |
743 | 751 | ||
744 | bool PlayListWidget::inFileListMode() const | 752 | bool PlayListWidget::inFileListMode() const |
745 | { | 753 | { |
746 | TabType tab = currentTab(); | 754 | TabType tab = currentTab(); |
747 | return tab == AudioFiles || tab == VideoFiles; | 755 | return tab == AudioFiles || tab == VideoFiles; |
748 | } | 756 | } |
749 | 757 | ||
750 | void PlayListWidget::openFile() { | 758 | void PlayListWidget::openFile() { |
751 | // http://66.28.164.33:2080 | 759 | // http://66.28.164.33:2080 |
752 | // http://somafm.com/star0242.m3u | 760 | // http://somafm.com/star0242.m3u |
753 | QString filename, name; | 761 | QString filename, name; |
754 | InputDialog *fileDlg; | 762 | InputDialog *fileDlg; |
755 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 763 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
756 | fileDlg->exec(); | 764 | fileDlg->exec(); |
757 | if( fileDlg->result() == 1 ) { | 765 | if( fileDlg->result() == 1 ) { |
758 | filename = fileDlg->text(); | 766 | filename = fileDlg->text(); |
759 | qDebug( "Selected filename is " + filename ); | 767 | qDebug( "Selected filename is " + filename ); |
760 | // Om3u *m3uList; | 768 | // Om3u *m3uList; |
761 | DocLnk lnk; | 769 | DocLnk lnk; |
762 | Config cfg( "OpiePlayer" ); | 770 | Config cfg( "OpiePlayer" ); |
763 | cfg.setGroup("PlayList"); | 771 | cfg.setGroup("PlayList"); |
764 | 772 | ||
765 | if(filename.left(4) == "http") { | 773 | if(filename.left(4) == "http") { |
766 | QString m3uFile, m3uFilePath; | 774 | QString m3uFile, m3uFilePath; |
767 | if(filename.find(":",8,TRUE) != -1) { //found a port | 775 | if(filename.find(":",8,TRUE) != -1) { //found a port |
768 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 776 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
769 | m3uFile = m3uFile.right( 7); | 777 | m3uFile = m3uFile.right( 7); |
770 | } else if(filename.left(4) == "http"){ | 778 | } else if(filename.left(4) == "http"){ |
771 | m3uFile=filename; | 779 | m3uFile=filename; |
772 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 780 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
773 | } else{ | 781 | } else{ |
774 | m3uFile=filename; | 782 | m3uFile=filename; |
775 | } | 783 | } |
776 | 784 | ||
777 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 785 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
778 | lnk.setName( filename ); //sets name | 786 | lnk.setName( filename ); //sets name |
779 | lnk.setFile( filename ); //sets file name | 787 | lnk.setFile( filename ); //sets file name |
780 | 788 | ||
781 | // lnk.setIcon("opieplayer2/musicfile"); | 789 | // lnk.setIcon("opieplayer2/musicfile"); |
782 | 790 | ||
783 | d->selectedFiles->addToSelection( lnk ); | 791 | d->selectedFiles->addToSelection( lnk ); |
784 | writeCurrentM3u(); | 792 | writeCurrentM3u(); |
785 | d->selectedFiles->setSelectedItem( lnk.name()); | 793 | d->selectedFiles->setSelectedItem( lnk.name()); |
786 | } | 794 | } |
787 | else if( filename.right( 3) == "m3u" ) { | 795 | else if( filename.right( 3) == "m3u" ) { |
788 | readm3u( filename ); | 796 | readm3u( filename ); |
789 | 797 | ||
790 | } else if( filename.right(3) == "pls" ) { | 798 | } else if( filename.right(3) == "pls" ) { |
791 | readPls( filename ); | 799 | readPls( filename ); |
792 | } else { | 800 | } else { |
793 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 801 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
794 | lnk.setFile( filename ); //sets file name | 802 | lnk.setFile( filename ); //sets file name |
795 | d->selectedFiles->addToSelection( lnk); | 803 | d->selectedFiles->addToSelection( lnk); |
796 | writeCurrentM3u(); | 804 | writeCurrentM3u(); |
797 | d->selectedFiles->setSelectedItem( lnk.name()); | 805 | d->selectedFiles->setSelectedItem( lnk.name()); |
798 | } | 806 | } |
799 | } | 807 | } |
800 | 808 | ||
801 | if( fileDlg ) { | 809 | if( fileDlg ) { |
802 | delete fileDlg; | 810 | delete fileDlg; |
803 | } | 811 | } |
804 | } | 812 | } |
805 | 813 | ||
806 | /* | 814 | /* |
807 | reads m3u and shows files/urls to playlist widget */ | 815 | reads m3u and shows files/urls to playlist widget */ |
808 | void PlayListWidget::readm3u( const QString &filename ) { | 816 | void PlayListWidget::readm3u( const QString &filename ) { |
809 | qDebug( "read m3u filename " + filename ); | 817 | qDebug( "read m3u filename " + filename ); |
810 | 818 | ||
811 | Om3u *m3uList; | 819 | Om3u *m3uList; |
812 | QString s, name; | 820 | QString s, name; |
813 | m3uList = new Om3u( filename, IO_ReadOnly ); | 821 | m3uList = new Om3u( filename, IO_ReadOnly ); |
814 | m3uList->readM3u(); | 822 | m3uList->readM3u(); |
815 | DocLnk lnk; | 823 | DocLnk lnk; |
816 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 824 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
817 | s = *it; | 825 | s = *it; |
818 | // qDebug("reading "+ s); | 826 | // qDebug("reading "+ s); |
819 | if(s.left(4)=="http") { | 827 | if(s.left(4)=="http") { |
820 | lnk.setName( s ); //sets file name | 828 | lnk.setName( s ); //sets file name |
821 | lnk.setIcon("opieplayer2/musicfile"); | 829 | lnk.setIcon("opieplayer2/musicfile"); |
822 | lnk.setFile( s ); //sets file name | 830 | lnk.setFile( s ); //sets file name |
823 | 831 | ||
824 | } else { | 832 | } else { |
825 | // if( QFileInfo( s ).exists() ) { | 833 | // if( QFileInfo( s ).exists() ) { |
826 | lnk.setName( QFileInfo(s).baseName()); | 834 | lnk.setName( QFileInfo(s).baseName()); |
827 | // if(s.right(4) == '.') {//if regular file | 835 | // if(s.right(4) == '.') {//if regular file |
828 | if(s.left(1) != "/") { | 836 | if(s.left(1) != "/") { |
829 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 837 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
830 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 838 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
831 | // lnk.setIcon(MimeType(s).pixmap() ); | 839 | // lnk.setIcon(MimeType(s).pixmap() ); |
832 | // lnk.setIcon("SoundPlayer"); | 840 | // lnk.setIcon("SoundPlayer"); |
833 | } else { | 841 | } else { |
834 | // qDebug("set link2 "+s); | 842 | // qDebug("set link2 "+s); |
835 | lnk.setFile( s); | 843 | lnk.setFile( s); |
836 | // lnk.setIcon(MimeType(s).pixmap() ); | 844 | // lnk.setIcon(MimeType(s).pixmap() ); |
837 | // lnk.setIcon("SoundPlayer"); | 845 | // lnk.setIcon("SoundPlayer"); |
838 | } | 846 | } |
839 | } | 847 | } |
840 | d->selectedFiles->addToSelection( lnk ); | 848 | d->selectedFiles->addToSelection( lnk ); |
841 | } | 849 | } |
842 | Config config( "OpiePlayer" ); | 850 | Config config( "OpiePlayer" ); |
843 | config.setGroup( "PlayList" ); | 851 | config.setGroup( "PlayList" ); |
844 | 852 | ||
845 | config.writeEntry("CurrentPlaylist",filename); | 853 | config.writeEntry("CurrentPlaylist",filename); |
846 | config.write(); | 854 | config.write(); |
847 | currentPlayList=filename; | 855 | currentPlayList=filename; |
848 | 856 | ||
849 | // m3uList->write(); | 857 | // m3uList->write(); |
850 | m3uList->close(); | 858 | m3uList->close(); |
851 | if(m3uList) delete m3uList; | 859 | if(m3uList) delete m3uList; |
852 | 860 | ||
853 | d->selectedFiles->setSelectedItem( s); | 861 | d->selectedFiles->setSelectedItem( s); |
854 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 862 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
855 | 863 | ||
856 | } | 864 | } |
857 | 865 | ||
858 | /* | 866 | /* |
859 | reads pls and adds files/urls to playlist */ | 867 | reads pls and adds files/urls to playlist */ |
860 | void PlayListWidget::readPls( const QString &filename ) { | 868 | void PlayListWidget::readPls( const QString &filename ) { |
861 | 869 | ||
862 | qDebug( "pls filename is " + filename ); | 870 | qDebug( "pls filename is " + filename ); |
863 | Om3u *m3uList; | 871 | Om3u *m3uList; |
864 | QString s, name; | 872 | QString s, name; |
865 | m3uList = new Om3u( filename, IO_ReadOnly ); | 873 | m3uList = new Om3u( filename, IO_ReadOnly ); |
866 | m3uList->readPls(); | 874 | m3uList->readPls(); |
867 | 875 | ||
868 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 876 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
869 | s = *it; | 877 | s = *it; |
870 | // s.replace( QRegExp( "%20" )," " ); | 878 | // s.replace( QRegExp( "%20" )," " ); |
871 | DocLnk lnk( s ); | 879 | DocLnk lnk( s ); |
872 | QFileInfo f( s ); | 880 | QFileInfo f( s ); |
873 | QString name = f.baseName(); | 881 | QString name = f.baseName(); |
874 | 882 | ||
875 | if( name.left( 4 ) == "http" ) { | 883 | if( name.left( 4 ) == "http" ) { |
876 | name = s.right( s.length() - 7); | 884 | name = s.right( s.length() - 7); |
877 | } else { | 885 | } else { |
878 | name = s; | 886 | name = s; |
879 | } | 887 | } |
880 | 888 | ||
881 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 889 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
882 | 890 | ||
883 | lnk.setName( name ); | 891 | lnk.setName( name ); |
884 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 892 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
885 | lnk.setFile( s ); | 893 | lnk.setFile( s ); |
886 | } else { //if its a url | 894 | } else { //if its a url |
887 | // if( name.right( 1 ).find( '/' ) == -1) { | 895 | // if( name.right( 1 ).find( '/' ) == -1) { |
888 | // s += "/"; | 896 | // s += "/"; |
889 | // } | 897 | // } |
890 | lnk.setFile( s ); | 898 | lnk.setFile( s ); |
891 | } | 899 | } |
892 | lnk.setType( "audio/x-mpegurl" ); | 900 | lnk.setType( "audio/x-mpegurl" ); |
893 | 901 | ||
894 | lnk.writeLink(); | 902 | lnk.writeLink(); |
895 | d->selectedFiles->addToSelection( lnk ); | 903 | d->selectedFiles->addToSelection( lnk ); |
896 | } | 904 | } |
897 | 905 | ||
898 | m3uList->close(); | 906 | m3uList->close(); |
899 | if(m3uList) delete m3uList; | 907 | if(m3uList) delete m3uList; |
900 | } | 908 | } |
901 | 909 | ||
902 | /* | 910 | /* |
903 | writes current playlist to current m3u file */ | 911 | writes current playlist to current m3u file */ |
904 | void PlayListWidget::writeCurrentM3u() { | 912 | void PlayListWidget::writeCurrentM3u() { |
905 | qDebug("writing to current m3u"); | 913 | qDebug("writing to current m3u"); |
906 | Config cfg( "OpiePlayer" ); | 914 | Config cfg( "OpiePlayer" ); |
907 | cfg.setGroup("PlayList"); | 915 | cfg.setGroup("PlayList"); |
908 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 916 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
909 | 917 | ||
910 | Om3u *m3uList; | 918 | Om3u *m3uList; |
911 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 919 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
912 | if( d->selectedFiles->first()) { | 920 | if( d->selectedFiles->first()) { |
913 | 921 | ||
914 | do { | 922 | do { |
915 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 923 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
916 | m3uList->add( d->selectedFiles->current()->file() ); | 924 | m3uList->add( d->selectedFiles->current()->file() ); |
917 | } | 925 | } |
918 | while ( d->selectedFiles->next() ); | 926 | while ( d->selectedFiles->next() ); |
919 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 927 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
920 | m3uList->write(); | 928 | m3uList->write(); |
921 | m3uList->close(); | 929 | m3uList->close(); |
922 | 930 | ||
923 | if(m3uList) delete m3uList; | 931 | if(m3uList) delete m3uList; |
924 | } | 932 | } |
925 | 933 | ||
926 | } | 934 | } |
927 | 935 | ||
928 | /* | 936 | /* |
929 | writes current playlist to m3u file */ | 937 | writes current playlist to m3u file */ |
930 | void PlayListWidget::writem3u() { | 938 | void PlayListWidget::writem3u() { |
931 | InputDialog *fileDlg; | 939 | InputDialog *fileDlg; |
932 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 940 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
933 | fileDlg->exec(); | 941 | fileDlg->exec(); |
934 | QString name, filename, list; | 942 | QString name, filename, list; |
935 | Om3u *m3uList; | 943 | Om3u *m3uList; |
936 | 944 | ||
937 | if( fileDlg->result() == 1 ) { | 945 | if( fileDlg->result() == 1 ) { |
938 | name = fileDlg->text(); | 946 | name = fileDlg->text(); |
939 | // qDebug( filename ); | 947 | // qDebug( filename ); |
940 | 948 | ||
941 | if( name.left( 1) != "/" ) { | 949 | if( name.left( 1) != "/" ) { |
942 | filename = QPEApplication::documentDir() + "/" + name; | 950 | filename = QPEApplication::documentDir() + "/" + name; |
943 | } | 951 | } |
944 | 952 | ||
945 | if( name.right( 3 ) != "m3u" ) { | 953 | if( name.right( 3 ) != "m3u" ) { |
946 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 954 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
947 | } | 955 | } |
948 | 956 | ||
949 | if( d->selectedFiles->first()) { | 957 | if( d->selectedFiles->first()) { |
950 | m3uList = new Om3u(filename, IO_ReadWrite); | 958 | m3uList = new Om3u(filename, IO_ReadWrite); |
951 | 959 | ||
952 | do { | 960 | do { |
953 | m3uList->add( d->selectedFiles->current()->file()); | 961 | m3uList->add( d->selectedFiles->current()->file()); |
954 | } | 962 | } |
955 | while ( d->selectedFiles->next() ); | 963 | while ( d->selectedFiles->next() ); |
956 | // qDebug( list ); | 964 | // qDebug( list ); |
957 | m3uList->write(); | 965 | m3uList->write(); |
958 | m3uList->close(); | 966 | m3uList->close(); |
959 | if(m3uList) delete m3uList; | 967 | if(m3uList) delete m3uList; |
960 | 968 | ||
961 | if(fileDlg) delete fileDlg; | 969 | if(fileDlg) delete fileDlg; |
962 | 970 | ||
963 | DocLnk lnk; | 971 | DocLnk lnk; |
964 | lnk.setFile( filename); | 972 | lnk.setFile( filename); |
965 | lnk.setIcon("opieplayer2/playlist2"); | 973 | lnk.setIcon("opieplayer2/playlist2"); |
966 | lnk.setName( name); //sets file name | 974 | lnk.setName( name); //sets file name |
967 | 975 | ||
968 | // qDebug(filename); | 976 | // qDebug(filename); |
969 | Config config( "OpiePlayer" ); | 977 | Config config( "OpiePlayer" ); |
970 | config.setGroup( "PlayList" ); | 978 | config.setGroup( "PlayList" ); |
971 | 979 | ||
972 | config.writeEntry("CurrentPlaylist",filename); | 980 | config.writeEntry("CurrentPlaylist",filename); |
973 | currentPlayList=filename; | 981 | currentPlayList=filename; |
974 | 982 | ||
975 | if(!lnk.writeLink()) { | 983 | if(!lnk.writeLink()) { |
976 | qDebug("Writing doclink did not work"); | 984 | qDebug("Writing doclink did not work"); |
977 | } | 985 | } |
978 | 986 | ||
979 | setCaption(tr("OpiePlayer: ") + name); | 987 | setCaption(tr("OpiePlayer: ") + name); |
980 | } | 988 | } |
981 | } | 989 | } |
982 | } | 990 | } |
983 | 991 | ||
984 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 992 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
985 | switch ( e->key() ) { | 993 | switch ( e->key() ) { |
986 | ////////////////////////////// Zaurus keys | 994 | ////////////////////////////// Zaurus keys |
987 | case Key_F9: //activity | 995 | case Key_F9: //activity |
988 | // if(audioUI->isHidden()) | 996 | // if(audioUI->isHidden()) |
989 | // audioUI->showMaximized(); | 997 | // audioUI->showMaximized(); |
990 | break; | 998 | break; |
991 | case Key_F10: //contacts | 999 | case Key_F10: //contacts |
992 | // if( videoUI->isHidden()) | 1000 | // if( videoUI->isHidden()) |
993 | // videoUI->showMaximized(); | 1001 | // videoUI->showMaximized(); |
994 | break; | 1002 | break; |
995 | case Key_F11: //menu | 1003 | case Key_F11: //menu |
996 | break; | 1004 | break; |
997 | case Key_F12: //home | 1005 | case Key_F12: //home |
998 | // doBlank(); | 1006 | // doBlank(); |
999 | break; | 1007 | break; |
1000 | case Key_F13: //mail | 1008 | case Key_F13: //mail |
1001 | // doUnblank(); | 1009 | // doUnblank(); |
1002 | break; | 1010 | break; |
1003 | case Key_Q: //add to playlist | 1011 | case Key_Q: //add to playlist |
1004 | addSelected(); | 1012 | addSelected(); |
1005 | break; | 1013 | break; |
1006 | case Key_R: //remove from playlist | 1014 | case Key_R: //remove from playlist |
1007 | removeSelected(); | 1015 | removeSelected(); |
1008 | break; | 1016 | break; |
1009 | // case Key_P: //play | 1017 | // case Key_P: //play |
1010 | // qDebug("Play"); | 1018 | // qDebug("Play"); |
1011 | // playSelected(); | 1019 | // playSelected(); |
1012 | // break; | 1020 | // break; |
1013 | case Key_Space: | 1021 | case Key_Space: |
1014 | // playSelected(); puh | 1022 | // playSelected(); puh |
1015 | break; | 1023 | break; |
1016 | case Key_1: | 1024 | case Key_1: |
1017 | tabWidget->setCurrentPage( 0 ); | 1025 | tabWidget->setCurrentPage( 0 ); |
1018 | break; | 1026 | break; |
1019 | case Key_2: | 1027 | case Key_2: |
1020 | tabWidget->setCurrentPage( 1 ); | 1028 | tabWidget->setCurrentPage( 1 ); |
1021 | break; | 1029 | break; |
1022 | case Key_3: | 1030 | case Key_3: |
1023 | tabWidget->setCurrentPage( 2 ); | 1031 | tabWidget->setCurrentPage( 2 ); |
1024 | break; | 1032 | break; |
1025 | case Key_4: | 1033 | case Key_4: |
1026 | tabWidget->setCurrentPage( 3 ); | 1034 | tabWidget->setCurrentPage( 3 ); |
1027 | break; | 1035 | break; |
1028 | case Key_Down: | 1036 | case Key_Down: |
1029 | if ( !d->selectedFiles->next() ) | 1037 | if ( !d->selectedFiles->next() ) |
1030 | d->selectedFiles->first(); | 1038 | d->selectedFiles->first(); |
1031 | break; | 1039 | break; |
1032 | case Key_Up: | 1040 | case Key_Up: |
1033 | if ( !d->selectedFiles->prev() ) | 1041 | if ( !d->selectedFiles->prev() ) |
1034 | // d->selectedFiles->last(); | 1042 | // d->selectedFiles->last(); |
1035 | break; | 1043 | break; |
1036 | } | 1044 | } |
1037 | } | 1045 | } |
1038 | 1046 | ||
1039 | void PlayListWidget::pmViewActivated(int index) { | 1047 | void PlayListWidget::pmViewActivated(int index) { |
1040 | // qDebug("%d", index); | 1048 | // qDebug("%d", index); |
1041 | switch(index) { | 1049 | switch(index) { |
1042 | case -16: | 1050 | case -16: |
1043 | { | 1051 | { |
1044 | mediaPlayerState->toggleFullscreen(); | 1052 | mediaPlayerState->toggleFullscreen(); |
1045 | bool b=mediaPlayerState->isFullscreen(); | 1053 | bool b=mediaPlayerState->isFullscreen(); |
1046 | pmView->setItemChecked( index, b); | 1054 | pmView->setItemChecked( index, b); |
1047 | Config cfg( "OpiePlayer" ); | 1055 | Config cfg( "OpiePlayer" ); |
1048 | cfg.writeEntry( "FullScreen", b ); | 1056 | cfg.writeEntry( "FullScreen", b ); |
1049 | } | 1057 | } |
1050 | break; | 1058 | break; |
1051 | }; | 1059 | }; |
1052 | } | 1060 | } |
1053 | 1061 | ||
1054 | void PlayListWidget::populateSkinsMenu() { | 1062 | void PlayListWidget::populateSkinsMenu() { |
1055 | int item = 0; | 1063 | int item = 0; |
1056 | defaultSkinIndex = 0; | 1064 | defaultSkinIndex = 0; |
1057 | QString skinName; | 1065 | QString skinName; |
1058 | Config cfg( "OpiePlayer" ); | 1066 | Config cfg( "OpiePlayer" ); |
1059 | cfg.setGroup("Options" ); | 1067 | cfg.setGroup("Options" ); |
1060 | QString skin = cfg.readEntry( "Skin", "default" ); | 1068 | QString skin = cfg.readEntry( "Skin", "default" ); |
1061 | 1069 | ||
1062 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1070 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1063 | skinsDir.setFilter( QDir::Dirs ); | 1071 | skinsDir.setFilter( QDir::Dirs ); |
1064 | skinsDir.setSorting(QDir::Name ); | 1072 | skinsDir.setSorting(QDir::Name ); |
1065 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1073 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1066 | QFileInfoListIterator it( *skinslist ); | 1074 | QFileInfoListIterator it( *skinslist ); |
1067 | QFileInfo *fi; | 1075 | QFileInfo *fi; |
1068 | while ( ( fi = it.current() ) ) { | 1076 | while ( ( fi = it.current() ) ) { |
1069 | skinName = fi->fileName(); | 1077 | skinName = fi->fileName(); |
1070 | // qDebug( fi->fileName() ); | 1078 | // qDebug( fi->fileName() ); |
1071 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1079 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1072 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1080 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1073 | } | 1081 | } |
1074 | if( skinName == "default" ) { | 1082 | if( skinName == "default" ) { |
1075 | defaultSkinIndex = item; | 1083 | defaultSkinIndex = item; |
1076 | } | 1084 | } |
1077 | if( skinName == skin ) { | 1085 | if( skinName == skin ) { |
1078 | skinsMenu->setItemChecked( item, TRUE ); | 1086 | skinsMenu->setItemChecked( item, TRUE ); |
1079 | } | 1087 | } |
1080 | ++it; | 1088 | ++it; |
1081 | } | 1089 | } |
1082 | } | 1090 | } |
1083 | 1091 | ||
1084 | void PlayListWidget::skinsMenuActivated( int item ) { | 1092 | void PlayListWidget::skinsMenuActivated( int item ) { |
1085 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1093 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1086 | skinsMenu->setItemChecked( i, FALSE ); | 1094 | skinsMenu->setItemChecked( i, FALSE ); |
1087 | } | 1095 | } |
1088 | skinsMenu->setItemChecked( item, TRUE ); | 1096 | skinsMenu->setItemChecked( item, TRUE ); |
1089 | 1097 | ||
1090 | Config cfg( "OpiePlayer" ); | 1098 | Config cfg( "OpiePlayer" ); |
1091 | cfg.setGroup("Options"); | 1099 | cfg.setGroup("Options"); |
1092 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1100 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1093 | QMessageBox::warning( this, tr( "OpiePlayer" ), | 1101 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1094 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | 1102 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); |
1095 | } | 1103 | } |
1096 | 1104 | ||
1097 | PlayListWidget::TabType PlayListWidget::currentTab() const | 1105 | PlayListWidget::TabType PlayListWidget::currentTab() const |
1098 | { | 1106 | { |
1099 | static const TabType indexToTabType[ TabTypeCount ] = | 1107 | static const TabType indexToTabType[ TabTypeCount ] = |
1100 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 1108 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
1101 | 1109 | ||
1102 | int index = tabWidget->currentPageIndex(); | 1110 | int index = tabWidget->currentPageIndex(); |
1103 | assert( index < TabTypeCount && index >= 0 ); | 1111 | assert( index < TabTypeCount && index >= 0 ); |
1104 | 1112 | ||
1105 | return indexToTabType[ index ]; | 1113 | return indexToTabType[ index ]; |
1106 | } | 1114 | } |
1107 | 1115 | ||
1108 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1116 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1109 | { | 1117 | { |
1110 | if ( currentTab() == CurrentPlayList ) { | 1118 | if ( currentTab() == CurrentPlayList ) { |
1111 | const DocLnk *lnk = current(); | 1119 | const DocLnk *lnk = current(); |
1112 | return Entry( lnk->name(), lnk->file() ); | 1120 | return Entry( lnk->name(), lnk->file() ); |
1113 | } | 1121 | } |
1114 | 1122 | ||
1115 | return Entry( currentFileListPathName() ); | 1123 | return Entry( currentFileListPathName() ); |
1116 | } | 1124 | } |
1117 | 1125 | ||
1118 | QString PlayListWidget::currentFileListPathName() const { | 1126 | QString PlayListWidget::currentFileListPathName() const { |
1119 | return currentFileListView()->currentItem()->text( 3 ); | 1127 | return currentFileListView()->currentItem()->text( 3 ); |
1120 | } | 1128 | } |