author | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
commit | 1bebd27631a6c9d1ab967cbb32dd4e796b3b0402 (patch) (unidiff) | |
tree | 8ce49800cba26f6f2c33de74a71d4efe0338843f /core/multimedia/opieplayer/playlistwidget.cpp | |
parent | d948361c1b475fab4660b28fbf5ec21fd34d923f (diff) | |
download | opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.zip opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.gz opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.bz2 |
fixed 2
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 510 |
1 files changed, 355 insertions, 155 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 0423e7a..202f351 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
@@ -23,2 +23,4 @@ | |||
23 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
24 | #include <qpe/qpeapplication.h> | ||
25 | |||
24 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
@@ -37,2 +39,6 @@ | |||
37 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qtabwidget.h> | ||
41 | #include <qlistview.h> | ||
42 | #include <qpoint.h> | ||
43 | //#include <qtimer.h> | ||
38 | 44 | ||
@@ -44,2 +50,5 @@ | |||
44 | 50 | ||
51 | #define BUTTONS_ON_TOOLBAR | ||
52 | #define SIDE_BUTTONS | ||
53 | #define CAN_SAVE_LOAD_PLAYLISTS | ||
45 | 54 | ||
@@ -47,11 +56,8 @@ extern MediaPlayerState *mediaPlayerState; | |||
47 | 56 | ||
57 | // class myFileSelector { | ||
48 | 58 | ||
59 | // }; | ||
49 | class PlayListWidgetPrivate { | 60 | class PlayListWidgetPrivate { |
50 | public: | 61 | public: |
51 | QToolButton *tbPlay; | 62 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
52 | QToolButton *tbFull; | ||
53 | QToolButton *tbLoop; | ||
54 | QToolButton *tbScale; | ||
55 | QToolButton *tbShuffle; | ||
56 | |||
57 | QFrame *playListFrame; | 63 | QFrame *playListFrame; |
@@ -67,10 +73,10 @@ public: | |||
67 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
68 | : QToolButton( parent, name ) { | 74 | : QToolButton( parent, name ) { |
69 | setTextLabel( name ); | 75 | setTextLabel( name ); |
70 | setPixmap( Resource::loadPixmap( icon ) ); | 76 | setPixmap( Resource::loadPixmap( icon ) ); |
71 | setAutoRaise( TRUE ); | 77 | setAutoRaise( TRUE ); |
72 | setFocusPolicy( QWidget::NoFocus ); | 78 | setFocusPolicy( QWidget::NoFocus ); |
73 | setToggleButton( t ); | 79 | setToggleButton( t ); |
74 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
75 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 81 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
76 | } | 82 | } |
@@ -82,5 +88,5 @@ public: | |||
82 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 88 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
83 | : QAction( text, QString::null, 0, 0 ) { | 89 | : QAction( text, QString::null, 0, 0 ) { |
84 | connect( this, SIGNAL( activated() ), handler, slot ); | 90 | connect( this, SIGNAL( activated() ), handler, slot ); |
85 | addTo( parent ); | 91 | addTo( parent ); |
86 | } | 92 | } |
@@ -95,2 +101,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
95 | d->current = NULL; | 101 | d->current = NULL; |
102 | // menuTimer = new QTimer( this ,"menu timer"), | ||
103 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | ||
96 | 104 | ||
@@ -98,3 +106,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
98 | 106 | ||
99 | setCaption( tr("MediaPlayer") ); | 107 | setCaption( tr("OpiePlayer") ); |
100 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 108 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
@@ -113,67 +121,129 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
113 | bar->setLabel( tr( "Play Operations" ) ); | 121 | bar->setLabel( tr( "Play Operations" ) ); |
114 | #ifdef BUTTONS_ON_TOOLBAR | 122 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),"mpegplayer/add_to_playlist",this , SLOT(addSelected()) ); |
115 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 123 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); |
116 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 124 | d->tbPlay = new ToolButton( bar, tr( "Play" ),"mpegplayer/play", mediaPlayerState, SLOT( setPlaying(bool)), TRUE ); |
117 | #endif | 125 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
118 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 126 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
119 | d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | ||
120 | d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | ||
121 | 127 | ||
122 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 128 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
123 | menu->insertItem( tr( "PlayList" ), pmPlayList ); | 129 | menu->insertItem( tr( "File" ), pmPlayList ); |
124 | new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) ); | ||
125 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 130 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
126 | new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); | 131 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
127 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 132 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
128 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 133 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
129 | #ifdef CAN_SAVE_LOAD_PLAYLISTS | ||
130 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 134 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
131 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 135 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
132 | #endif | 136 | |
137 | QPopupMenu *pmView = new QPopupMenu( this ); | ||
138 | menu->insertItem( tr( "View" ), pmView ); | ||
139 | |||
140 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | ||
141 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | ||
142 | fullScreenButton->addTo(pmView); | ||
143 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | ||
144 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | ||
145 | scaleButton->addTo(pmView); | ||
133 | 146 | ||
134 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 147 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
148 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
149 | |||
150 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | ||
151 | |||
152 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
153 | tabWidget->setTabShape(QTabWidget::Triangular); | ||
154 | |||
155 | QWidget *pTab; | ||
156 | pTab = new QWidget( tabWidget, "pTab" ); | ||
157 | playlistView = new QListView( pTab, "Videoview" ); | ||
158 | playlistView->setMinimumSize(236,260); | ||
159 | tabWidget->insertTab( pTab,"Playlist"); | ||
135 | 160 | ||
136 | // Add the playlist area | 161 | // Add the playlist area |
137 | QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton ); | ||
138 | d->playListFrame = vbox3; | ||
139 | 162 | ||
140 | QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); | 163 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
141 | plString->setBackgroundMode( QButton::PaletteButton ); | 164 | d->playListFrame = vbox3; |
142 | plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | 165 | d->playListFrame ->setMinimumSize(235,260); |
143 | 166 | ||
144 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 167 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
145 | d->selectedFiles = new PlayListSelection( hbox2 ); | ||
146 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | ||
147 | 168 | ||
148 | #ifndef BUTTONS_ON_TOOLBAR | 169 | d->selectedFiles = new PlayListSelection( hbox2); |
149 | d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 170 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
150 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | ||
151 | #endif | ||
152 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | ||
153 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | ||
154 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | ||
155 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | ||
156 | #ifndef BUTTONS_ON_TOOLBAR | ||
157 | d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
158 | #endif | ||
159 | 171 | ||
172 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | ||
173 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | ||
174 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | ||
175 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | ||
176 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | ||
177 | |||
178 | QWidget *aTab; | ||
179 | aTab = new QWidget( tabWidget, "aTab" ); | ||
180 | audioView = new QListView( aTab, "Audioview" ); | ||
181 | audioView->setMinimumSize(233,260); | ||
182 | audioView->addColumn( "Title",150); | ||
183 | audioView->addColumn("Size", 45); | ||
184 | audioView->addColumn("Media",35); | ||
185 | audioView->setColumnAlignment(1, Qt::AlignRight); | ||
186 | audioView->setColumnAlignment(2, Qt::AlignRight); | ||
187 | tabWidget->insertTab(aTab,"Audio"); | ||
188 | // audioView | ||
189 | Global::findDocuments(&files, "audio/*"); | ||
190 | QListIterator<DocLnk> dit( files.children() ); | ||
191 | QString storage; | ||
192 | for ( ; dit.current(); ++dit ) { | ||
193 | QListViewItem * newItem; | ||
194 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
195 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
196 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
197 | else storage="RAM"; | ||
198 | if ( QFile( dit.current()->file()).exists() ) { | ||
199 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
200 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
201 | } | ||
202 | } | ||
203 | // videowidget | ||
204 | |||
205 | QWidget *vTab; | ||
206 | vTab = new QWidget( tabWidget, "vTab" ); | ||
207 | videoView = new QListView( vTab, "Videoview" ); | ||
208 | videoView->setMinimumSize(233,260); | ||
209 | |||
210 | videoView->addColumn("Title",150); | ||
211 | videoView->addColumn("Size",45); | ||
212 | videoView->addColumn("Media",35); | ||
213 | videoView->setColumnAlignment(1, Qt::AlignRight); | ||
214 | videoView->setColumnAlignment(2, Qt::AlignRight); | ||
215 | |||
216 | tabWidget->insertTab( vTab,"Video"); | ||
217 | |||
218 | Global::findDocuments(&vFiles, "video/*"); | ||
219 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
220 | for ( ; Vdit.current(); ++Vdit ) { | ||
221 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
222 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
223 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
224 | else storage="RAM"; | ||
225 | QListViewItem * newItem; | ||
226 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
227 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
228 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
229 | } | ||
230 | } | ||
160 | // add the library area | 231 | // add the library area |
161 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 232 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
162 | 233 | ||
163 | QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); | 234 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
164 | libString->setBackgroundMode( QButton::PaletteButton ); | 235 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
165 | libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
166 | 236 | ||
167 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 237 | connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
168 | d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); | 238 | connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
169 | d->files->setBackgroundMode( PaletteButton ); | 239 | |
170 | QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); | 240 | connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), |
241 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
242 | connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | ||
243 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
171 | 244 | ||
172 | #ifdef SIDE_BUTTONS | ||
173 | new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); | ||
174 | new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) ); | ||
175 | QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch | ||
176 | #endif | ||
177 | 245 | ||
178 | connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 246 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
247 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
248 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
179 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 249 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
@@ -181,7 +251,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
181 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 251 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
182 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); | 252 | |
183 | connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); | 253 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); |
184 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); | 254 | // connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); |
255 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); | ||
256 | |||
185 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 257 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
186 | 258 | ||
259 | connect( d->selectedFiles, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
260 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
261 | |||
187 | setCentralWidget( vbox5 ); | 262 | setCentralWidget( vbox5 ); |
@@ -200,3 +275,3 @@ PlayListWidget::~PlayListWidget() { | |||
200 | if ( d->current ) | 275 | if ( d->current ) |
201 | delete d->current; | 276 | delete d->current; |
202 | delete d; | 277 | delete d; |
@@ -206,2 +281,3 @@ PlayListWidget::~PlayListWidget() { | |||
206 | void PlayListWidget::initializeStates() { | 281 | void PlayListWidget::initializeStates() { |
282 | |||
207 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 283 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
@@ -209,6 +285,6 @@ void PlayListWidget::initializeStates() { | |||
209 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 285 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
210 | d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 286 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
211 | d->tbScale->setOn( mediaPlayerState->scaled() ); | 287 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
212 | d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 288 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
213 | setPlaylist( mediaPlayerState->playlist() ); | 289 | // setPlaylist( mediaPlayerState->playlist() ); |
214 | } | 290 | } |
@@ -222,7 +298,7 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
222 | for ( int i = 0; i < noOfFiles; i++ ) { | 298 | for ( int i = 0; i < noOfFiles; i++ ) { |
223 | QString entryName; | 299 | QString entryName; |
224 | entryName.sprintf( "File%i", i + 1 ); | 300 | entryName.sprintf( "File%i", i + 1 ); |
225 | QString linkFile = cfg.readEntry( entryName ); | 301 | QString linkFile = cfg.readEntry( entryName ); |
226 | DocLnk lnk( linkFile ); | 302 | DocLnk lnk( linkFile ); |
227 | if ( lnk.isValid() ) | 303 | if ( lnk.isValid() ) |
228 | d->selectedFiles->addToSelection( lnk ); | 304 | d->selectedFiles->addToSelection( lnk ); |
@@ -240,24 +316,24 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
240 | do { | 316 | do { |
241 | const DocLnk *lnk = d->selectedFiles->current(); | 317 | const DocLnk *lnk = d->selectedFiles->current(); |
242 | if ( lnk ) { | 318 | if ( lnk ) { |
243 | QString entryName; | 319 | QString entryName; |
244 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 320 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
245 | cfg.writeEntry( entryName, lnk->linkFile() ); | 321 | cfg.writeEntry( entryName, lnk->linkFile() ); |
246 | // if this link does exist, add it so we have the file | 322 | // if this link does exist, add it so we have the file |
247 | // next time... | 323 | // next time... |
248 | if ( !QFile::exists( lnk->linkFile() ) ) { | 324 | if ( !QFile::exists( lnk->linkFile() ) ) { |
249 | // the way writing lnks doesn't really check for out | 325 | // the way writing lnks doesn't really check for out |
250 | // of disk space, but check it anyway. | 326 | // of disk space, but check it anyway. |
251 | if ( !lnk->writeLink() ) { | 327 | if ( !lnk->writeLink() ) { |
252 | QMessageBox::critical( 0, tr("Out of space"), | 328 | QMessageBox::critical( 0, tr("Out of space"), |
253 | tr( "There was a problem saving " | 329 | tr( "There was a problem saving " |
254 | "the playlist.\n" | 330 | "the playlist.\n" |
255 | "Your playlist " | 331 | "Your playlist " |
256 | "may be missing some entries\n" | 332 | "may be missing some entries\n" |
257 | "the next time you start it." ) | 333 | "the next time you start it." ) |
258 | ); | 334 | ); |
259 | } | 335 | } |
260 | } | 336 | } |
261 | noOfFiles++; | 337 | noOfFiles++; |
262 | } | 338 | } |
263 | } while ( d->selectedFiles->next() ); | 339 | } while ( d->selectedFiles->next() ); |
@@ -269,3 +345,3 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
269 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 345 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
270 | d->setDocumentUsed = FALSE; | 346 | d->setDocumentUsed = FALSE; |
271 | if ( mediaPlayerState->playlist() ) | 347 | if ( mediaPlayerState->playlist() ) |
@@ -273,3 +349,13 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { | |||
273 | else | 349 | else |
274 | mediaPlayerState->setPlaying( TRUE ); | 350 | mediaPlayerState->setPlaying( TRUE ); |
351 | } | ||
352 | |||
353 | |||
354 | void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { | ||
355 | qDebug("add"); | ||
356 | // d->selectedFiles->addToSelection( lnk ); | ||
357 | // } | ||
358 | // else | ||
359 | // mediaPlayerState->setPlaying( TRUE ); | ||
360 | // | ||
275 | } | 361 | } |
@@ -279,3 +365,3 @@ void PlayListWidget::clearList() { | |||
279 | while ( first() ) | 365 | while ( first() ) |
280 | d->selectedFiles->removeSelected(); | 366 | d->selectedFiles->removeSelected(); |
281 | } | 367 | } |
@@ -312,12 +398,12 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
312 | if ( fileref.isNull() ) { | 398 | if ( fileref.isNull() ) { |
313 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 399 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
314 | return; | 400 | return; |
315 | } | 401 | } |
316 | if ( mediaPlayerState->playlist() ) | 402 | if ( mediaPlayerState->playlist() ) |
317 | addToSelection( DocLnk( fileref ) ); | 403 | addToSelection( DocLnk( fileref ) ); |
318 | else { | 404 | else { |
319 | d->setDocumentUsed = TRUE; | 405 | d->setDocumentUsed = TRUE; |
320 | if ( d->current ) | 406 | if ( d->current ) |
321 | delete d->current; | 407 | delete d->current; |
322 | d->current = new DocLnk( fileref ); | 408 | d->current = new DocLnk( fileref ); |
323 | } | 409 | } |
@@ -343,7 +429,7 @@ const DocLnk *PlayListWidget::current() { | |||
343 | if ( mediaPlayerState->playlist() ) | 429 | if ( mediaPlayerState->playlist() ) |
344 | return d->selectedFiles->current(); | 430 | return d->selectedFiles->current(); |
345 | else if ( d->setDocumentUsed && d->current ) { | 431 | else if ( d->setDocumentUsed && d->current ) { |
346 | return d->current; | 432 | return d->current; |
347 | } else | 433 | } else |
348 | return d->files->selected(); | 434 | return d->files->selected(); |
349 | } | 435 | } |
@@ -353,25 +439,25 @@ bool PlayListWidget::prev() { | |||
353 | if ( mediaPlayerState->playlist() ) { | 439 | if ( mediaPlayerState->playlist() ) { |
354 | if ( mediaPlayerState->shuffled() ) { | 440 | if ( mediaPlayerState->shuffled() ) { |
355 | const DocLnk *cur = current(); | 441 | const DocLnk *cur = current(); |
356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 442 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
357 | for ( int i = 0; i < j; i++ ) { | 443 | for ( int i = 0; i < j; i++ ) { |
358 | if ( !d->selectedFiles->next() ) | 444 | if ( !d->selectedFiles->next() ) |
359 | d->selectedFiles->first(); | 445 | d->selectedFiles->first(); |
360 | } | 446 | } |
361 | if ( cur == current() ) | 447 | if ( cur == current() ) |
362 | if ( !d->selectedFiles->next() ) | 448 | if ( !d->selectedFiles->next() ) |
363 | d->selectedFiles->first(); | 449 | d->selectedFiles->first(); |
364 | return TRUE; | 450 | return TRUE; |
365 | } else { | 451 | } else { |
366 | if ( !d->selectedFiles->prev() ) { | 452 | if ( !d->selectedFiles->prev() ) { |
367 | if ( mediaPlayerState->looping() ) { | 453 | if ( mediaPlayerState->looping() ) { |
368 | return d->selectedFiles->last(); | 454 | return d->selectedFiles->last(); |
369 | } else { | 455 | } else { |
370 | return FALSE; | 456 | return FALSE; |
371 | } | 457 | } |
372 | } | 458 | } |
373 | return TRUE; | 459 | return TRUE; |
374 | } | 460 | } |
375 | } else { | 461 | } else { |
376 | return mediaPlayerState->looping(); | 462 | return mediaPlayerState->looping(); |
377 | } | 463 | } |
@@ -382,16 +468,16 @@ bool PlayListWidget::next() { | |||
382 | if ( mediaPlayerState->playlist() ) { | 468 | if ( mediaPlayerState->playlist() ) { |
383 | if ( mediaPlayerState->shuffled() ) { | 469 | if ( mediaPlayerState->shuffled() ) { |
384 | return prev(); | 470 | return prev(); |
385 | } else { | 471 | } else { |
386 | if ( !d->selectedFiles->next() ) { | 472 | if ( !d->selectedFiles->next() ) { |
387 | if ( mediaPlayerState->looping() ) { | 473 | if ( mediaPlayerState->looping() ) { |
388 | return d->selectedFiles->first(); | 474 | return d->selectedFiles->first(); |
389 | } else { | 475 | } else { |
390 | return FALSE; | 476 | return FALSE; |
391 | } | 477 | } |
392 | } | 478 | } |
393 | return TRUE; | 479 | return TRUE; |
394 | } | 480 | } |
395 | } else { | 481 | } else { |
396 | return mediaPlayerState->looping(); | 482 | return mediaPlayerState->looping(); |
397 | } | 483 | } |
@@ -402,5 +488,5 @@ bool PlayListWidget::first() { | |||
402 | if ( mediaPlayerState->playlist() ) | 488 | if ( mediaPlayerState->playlist() ) |
403 | return d->selectedFiles->first(); | 489 | return d->selectedFiles->first(); |
404 | else | 490 | else |
405 | return mediaPlayerState->looping(); | 491 | return mediaPlayerState->looping(); |
406 | } | 492 | } |
@@ -410,5 +496,5 @@ bool PlayListWidget::last() { | |||
410 | if ( mediaPlayerState->playlist() ) | 496 | if ( mediaPlayerState->playlist() ) |
411 | return d->selectedFiles->last(); | 497 | return d->selectedFiles->last(); |
412 | else | 498 | else |
413 | return mediaPlayerState->looping(); | 499 | return mediaPlayerState->looping(); |
414 | } | 500 | } |
@@ -436,5 +522,5 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
436 | if ( shown ) | 522 | if ( shown ) |
437 | d->playListFrame->show(); | 523 | d->playListFrame->show(); |
438 | else | 524 | else |
439 | d->playListFrame->hide(); | 525 | d->playListFrame->hide(); |
440 | } | 526 | } |
@@ -444,6 +530,120 @@ void PlayListWidget::setView( char view ) { | |||
444 | if ( view == 'l' ) | 530 | if ( view == 'l' ) |
445 | showMaximized(); | 531 | showMaximized(); |
446 | else | 532 | else |
447 | hide(); | 533 | hide(); |
534 | } | ||
535 | |||
536 | void PlayListWidget::addSelected() { | ||
537 | // QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); | ||
538 | int tabPage=tabWidget->currentPageIndex(); | ||
539 | switch (tabPage) { | ||
540 | case 0: //playlist | ||
541 | break; | ||
542 | case 1: { //audio | ||
543 | addToSelection( audioView->selectedItem() ); | ||
544 | } | ||
545 | break; | ||
546 | case 2: { // video | ||
547 | addToSelection( videoView->selectedItem() ); | ||
548 | } | ||
549 | break; | ||
550 | }; | ||
551 | } | ||
552 | |||
553 | void PlayListWidget::removeSelected() { | ||
554 | d->selectedFiles->removeSelected( ); | ||
555 | } | ||
556 | |||
557 | |||
558 | void PlayListWidget::playIt( QListViewItem *it) { | ||
559 | // d->setDocumentUsed = FALSE; | ||
560 | mediaPlayerState->setPlaying(true); | ||
561 | } | ||
562 | |||
563 | void PlayListWidget::addToSelection( QListViewItem *it) { | ||
564 | d->setDocumentUsed = FALSE; | ||
565 | |||
566 | if(it) { | ||
567 | qDebug("add to selection"); | ||
568 | int tabPage=tabWidget->currentPageIndex(); | ||
569 | switch (tabPage) { | ||
570 | case 1: { | ||
571 | QListIterator<DocLnk> dit( files.children() ); | ||
572 | for ( ; dit.current(); ++dit ) { | ||
573 | if( dit.current()->name() == it->text(0)) { | ||
574 | d->selectedFiles->addToSelection( **dit ); | ||
575 | } | ||
576 | } | ||
577 | } | ||
578 | break; | ||
579 | case 2: { | ||
580 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
581 | for ( ; dit.current(); ++dit ) { | ||
582 | qDebug(dit.current()->name()); | ||
583 | if( dit.current()->name() == it->text(0)) { | ||
584 | d->selectedFiles->addToSelection( **dit ); | ||
585 | } | ||
586 | } | ||
587 | } | ||
588 | break; | ||
589 | case 0: | ||
590 | break; | ||
591 | }; | ||
592 | tabWidget->setCurrentPage(0); | ||
593 | // mediaPlayerState->setPlaying( TRUE ); | ||
594 | } | ||
595 | } | ||
596 | |||
597 | void PlayListWidget::tabChanged(QWidget *widg) { | ||
598 | |||
599 | int tabPage=tabWidget->currentPageIndex(); | ||
600 | switch (tabPage) { | ||
601 | case 0: | ||
602 | { | ||
603 | d->tbRemoveFromList->setEnabled(TRUE); | ||
604 | d->tbAddToList->setEnabled(FALSE); | ||
605 | } | ||
606 | break; | ||
607 | case 1: | ||
608 | { | ||
609 | d->tbRemoveFromList->setEnabled(FALSE); | ||
610 | d->tbAddToList->setEnabled(TRUE); | ||
611 | } | ||
612 | break; | ||
613 | case 2: | ||
614 | { | ||
615 | d->tbRemoveFromList->setEnabled(FALSE); | ||
616 | d->tbAddToList->setEnabled(TRUE); | ||
617 | } | ||
618 | break; | ||
619 | }; | ||
448 | } | 620 | } |
449 | 621 | ||
622 | // void PlayListWidget::cancelMenuTimer() { | ||
623 | // if( menuTimer->isActive() ) | ||
624 | // menuTimer->stop(); | ||
625 | // } | ||
626 | |||
627 | // void PlayListWidget::showFileMenu() { | ||
628 | |||
629 | // } | ||
630 | |||
631 | // void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) | ||
632 | // { | ||
633 | // // QListView::contentsMousePressEvent( e ); | ||
634 | // menuTimer->start( 750, TRUE ); | ||
635 | // } | ||
636 | |||
637 | |||
638 | // void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) | ||
639 | // { | ||
640 | // // QListView::contentsMouseReleaseEvent( e ); | ||
641 | // menuTimer->stop(); | ||
642 | // } | ||
643 | // // void PlayListWidget::setFullScreen() { | ||
644 | // mediaPlayerState->toggleFullscreen( ); | ||
645 | // } | ||
646 | |||
647 | // void PlayListWidget::setScaled() { | ||
648 | // mediaPlayerState->toggleScaled(); | ||
649 | // } | ||