summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp56
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
4 files changed, 59 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp
index 3ef4d03..3094876 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.cpp
+++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp
@@ -76,11 +76,13 @@ void PlayListFileView::populateView()
76 if ( QFile::exists( dit.current()->file() ) || 76 if ( QFile::exists( dit.current()->file() ) ||
77 dit.current()->file().left( 4 ) == "http" ) { 77 dit.current()->file().left( 4 ) == "http" ) {
78 78
79 unsigned long size = QFile( dit.current()->file() ).size(); 79 unsigned long size = QFile( dit.current()->file() ).size();
80 QString sizestr;
81 fileSize(size, sizestr);
80 82
81 newItem = new QListViewItem( this, dit.current()->name(), 83 newItem = new QListViewItem( this, dit.current()->name(),
82 QString::number( size ), "" /*storage*/, 84 sizestr, "" /*storage*/,
83 dit.current()->file() ); 85 dit.current()->file() );
84 newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); 86 newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) );
85 } 87 }
86 } 88 }
@@ -90,6 +92,15 @@ void PlayListFileView::checkSelection()
90{ 92{
91 emit itemsSelected( hasSelection() ); 93 emit itemsSelected( hasSelection() );
92} 94}
93 95
96void PlayListFileView::fileSize(unsigned long size, QString &str) {
97 if( size > 1048576 )
98 str.sprintf( "%.0fM", size / 1048576.0 );
99 else if( size > 1024 )
100 str.sprintf( "%.0fK", size / 1024.0 );
101 else
102 str.sprintf( "%d", size );
103}
104
94/* vim: et sw=4 ts=4 105/* vim: et sw=4 ts=4
95 */ 106 */
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h
index 5b15526..d92f258 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.h
+++ b/noncore/multimedia/opieplayer2/playlistfileview.h
@@ -24,8 +24,9 @@ signals:
24private slots: 24private slots:
25 void checkSelection(); 25 void checkSelection();
26 26
27private: 27private:
28 void fileSize(unsigned long size, QString &str);
28 QString m_mimeTypePattern; 29 QString m_mimeTypePattern;
29 QString m_itemPixmapName; 30 QString m_itemPixmapName;
30 DocLnkSet m_files; 31 DocLnkSet m_files;
31 bool m_scannedFiles; 32 bool m_scannedFiles;
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 5f4159c..83eb83b 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -179,8 +179,40 @@ void PlayListWidget::initializeStates() {
179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
180 d->playListFrame->show(); 180 d->playListFrame->show();
181} 181}
182 182
183void PlayListWidget::setButtons(void) {
184 bool hasitem;
185
186 switch ( currentTab() ) {
187 case CurrentPlayList:
188 {
189 hasitem = !d->selectedFiles->isEmpty();
190 d->tbPlay->setEnabled( hasitem );
191 d->tbRemoveFromList->setEnabled( hasitem );
192 }
193 break;
194 case AudioFiles:
195 {
196 d->tbPlay->setEnabled( audioView->hasSelection() );
197 d->tbRemoveFromList->setEnabled( false );
198 }
199 break;
200 case VideoFiles:
201 {
202 d->tbPlay->setEnabled( videoView->hasSelection() );
203 d->tbRemoveFromList->setEnabled( false );
204 }
205 break;
206 case PlayLists:
207 {
208 d->tbPlay->setEnabled( false );
209 d->tbRemoveFromList->setEnabled( false );
210 }
211 break;
212 };
213}
214
183void PlayListWidget::writeDefaultPlaylist() { 215void PlayListWidget::writeDefaultPlaylist() {
184 216
185 Config config( "OpiePlayer" ); 217 Config config( "OpiePlayer" );
186 config.setGroup( "PlayList" ); 218 config.setGroup( "PlayList" );
@@ -219,8 +251,9 @@ void PlayListWidget::clearList() {
219 Config cfg( "OpiePlayer" ); 251 Config cfg( "OpiePlayer" );
220 cfg.setGroup("PlayList"); 252 cfg.setGroup("PlayList");
221 cfg.writeEntry("CurrentPlaylist","default"); 253 cfg.writeEntry("CurrentPlaylist","default");
222 setCaption("OpiePlayer"); 254 setCaption("OpiePlayer");
255 setButtons();
223} 256}
224 257
225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 258void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
226 switch (mouse) { 259 switch (mouse) {
@@ -283,8 +316,10 @@ void PlayListWidget::addAllToList() {
283 tabWidget->setCurrentPage(0); 316 tabWidget->setCurrentPage(0);
284 317
285 writeCurrentM3u(); 318 writeCurrentM3u();
286 d->selectedFiles->first(); 319 d->selectedFiles->first();
320
321 setButtons();
287} 322}
288 323
289 324
290void PlayListWidget::addAllMusicToList() { 325void PlayListWidget::addAllMusicToList() {
@@ -304,8 +339,10 @@ void PlayListWidget::addAllMusicToList() {
304 339
305 tabWidget->setCurrentPage(0); 340 tabWidget->setCurrentPage(0);
306 writeCurrentM3u(); 341 writeCurrentM3u();
307 d->selectedFiles->first(); 342 d->selectedFiles->first();
343
344 setButtons();
308} 345}
309 346
310 347
311void PlayListWidget::addAllVideoToList() { 348void PlayListWidget::addAllVideoToList() {
@@ -323,8 +360,10 @@ void PlayListWidget::addAllVideoToList() {
323 } 360 }
324 tabWidget->setCurrentPage(0); 361 tabWidget->setCurrentPage(0);
325 writeCurrentM3u(); 362 writeCurrentM3u();
326 d->selectedFiles->first(); 363 d->selectedFiles->first();
364
365 setButtons();
327} 366}
328 367
329 368
330void PlayListWidget::setDocument( const QString& _fileref ) { 369void PlayListWidget::setDocument( const QString& _fileref ) {
@@ -475,8 +514,9 @@ void PlayListWidget::addSelected() {
475 514
476void PlayListWidget::removeSelected() { 515void PlayListWidget::removeSelected() {
477 d->selectedFiles->removeSelected( ); 516 d->selectedFiles->removeSelected( );
478 writeCurrentM3u(); 517 writeCurrentM3u();
518 setButtons();
479} 519}
480 520
481 521
482void PlayListWidget::playIt( QListViewItem *it) { 522void PlayListWidget::playIt( QListViewItem *it) {
@@ -509,10 +549,8 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
509 549
510 550
511void PlayListWidget::tabChanged(QWidget *) { 551void PlayListWidget::tabChanged(QWidget *) {
512 552
513 d->tbPlay->setEnabled( true );
514
515 disconnect( audioView, SIGNAL( itemsSelected(bool) ), 553 disconnect( audioView, SIGNAL( itemsSelected(bool) ),
516 d->tbPlay, SLOT( setEnabled(bool) ) ); 554 d->tbPlay, SLOT( setEnabled(bool) ) );
517 disconnect( videoView, SIGNAL( itemsSelected(bool) ), 555 disconnect( videoView, SIGNAL( itemsSelected(bool) ),
518 d->tbPlay, SLOT( setEnabled(bool) ) ); 556 d->tbPlay, SLOT( setEnabled(bool) ) );
@@ -524,12 +562,10 @@ void PlayListWidget::tabChanged(QWidget *) {
524 { 562 {
525 if( !tbDeletePlaylist->isHidden() ) { 563 if( !tbDeletePlaylist->isHidden() ) {
526 tbDeletePlaylist->hide(); 564 tbDeletePlaylist->hide();
527 } 565 }
528 d->tbRemoveFromList->setEnabled(TRUE);
529 d->tbAddToList->setEnabled(FALSE); 566 d->tbAddToList->setEnabled(FALSE);
530 567
531 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
532 } 568 }
533 break; 569 break;
534 case AudioFiles: 570 case AudioFiles:
535 { 571 {
@@ -537,16 +573,13 @@ void PlayListWidget::tabChanged(QWidget *) {
537 573
538 if( !tbDeletePlaylist->isHidden() ) { 574 if( !tbDeletePlaylist->isHidden() ) {
539 tbDeletePlaylist->hide(); 575 tbDeletePlaylist->hide();
540 } 576 }
541 d->tbRemoveFromList->setEnabled(FALSE);
542 d->tbAddToList->setEnabled(TRUE); 577 d->tbAddToList->setEnabled(TRUE);
543 578
544 connect( audioView, SIGNAL( itemsSelected(bool) ), 579 connect( audioView, SIGNAL( itemsSelected(bool) ),
545 d->tbPlay, SLOT( setEnabled(bool) ) ); 580 d->tbPlay, SLOT( setEnabled(bool) ) );
546 581
547 d->tbPlay->setEnabled( audioView->hasSelection() );
548
549 currentFileListView = audioView; 582 currentFileListView = audioView;
550 } 583 }
551 break; 584 break;
552 case VideoFiles: 585 case VideoFiles:
@@ -554,16 +587,13 @@ void PlayListWidget::tabChanged(QWidget *) {
554 videoView->populateView(); 587 videoView->populateView();
555 if( !tbDeletePlaylist->isHidden() ) { 588 if( !tbDeletePlaylist->isHidden() ) {
556 tbDeletePlaylist->hide(); 589 tbDeletePlaylist->hide();
557 } 590 }
558 d->tbRemoveFromList->setEnabled(FALSE);
559 d->tbAddToList->setEnabled(TRUE); 591 d->tbAddToList->setEnabled(TRUE);
560 592
561 connect( videoView, SIGNAL( itemsSelected(bool) ), 593 connect( videoView, SIGNAL( itemsSelected(bool) ),
562 d->tbPlay, SLOT( setEnabled(bool) ) ); 594 d->tbPlay, SLOT( setEnabled(bool) ) );
563 595
564 d->tbPlay->setEnabled( videoView->hasSelection() );
565
566 currentFileListView = videoView; 596 currentFileListView = videoView;
567 } 597 }
568 break; 598 break;
569 case PlayLists: 599 case PlayLists:
@@ -573,12 +603,13 @@ void PlayListWidget::tabChanged(QWidget *) {
573 } 603 }
574 playLists->reread(); 604 playLists->reread();
575 d->tbAddToList->setEnabled(FALSE); 605 d->tbAddToList->setEnabled(FALSE);
576 606
577 d->tbPlay->setEnabled( false );
578 } 607 }
579 break; 608 break;
580 }; 609 };
610
611 setButtons();
581} 612}
582 613
583 614
584void PlayListWidget::btnPlay(bool b) { 615void PlayListWidget::btnPlay(bool b) {
@@ -709,8 +740,10 @@ void PlayListWidget::openFile() {
709 QFileInfo info( str ); 740 QFileInfo info( str );
710 DocLnk lnk = addFileToPlaylist( str, info.baseName() ); 741 DocLnk lnk = addFileToPlaylist( str, info.baseName() );
711 d->selectedFiles->setSelectedItem( lnk.name() ); 742 d->selectedFiles->setSelectedItem( lnk.name() );
712 } 743 }
744
745 setButtons();
713} 746}
714 747
715void PlayListWidget::openDirectory() { 748void PlayListWidget::openDirectory() {
716 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, 749 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
@@ -778,8 +811,9 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
778 811
779 d->selectedFiles->setSelectedItem( s); 812 d->selectedFiles->setSelectedItem( s);
780 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 813 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
781 814
815 setButtons();
782} 816}
783 817
784// writes current playlist to current m3u file */ 818// writes current playlist to current m3u file */
785 void PlayListWidget::writeCurrentM3u() { 819 void PlayListWidget::writeCurrentM3u() {
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 1f5ba92..7db0029 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -131,8 +131,9 @@ private slots:
131 void playSelected(); 131 void playSelected();
132 132
133private: 133private:
134 DocLnk addFileToPlaylist(const QString& directory, const QString& name); 134 DocLnk addFileToPlaylist(const QString& directory, const QString& name);
135 void setButtons(void);
135 bool fromSetDocument; 136 bool fromSetDocument;
136 bool insanityBool; 137 bool insanityBool;
137 QString setDocFileRef, currentPlayList; 138 QString setDocFileRef, currentPlayList;
138 int selected; 139 int selected;