// // C++ Implementation: transferdialog // // Description: // // // Author: Jeff Mitchell , (C) 2005 // // Copyright: See COPYING file that comes with this distribution // // #include "amarok.h" #include "debug.h" #include "mediabrowser.h" #include "transferdialog.h" #include #include #include #include #include #include #include #include #include #include #include TransferDialog::TransferDialog( MediaDevice *mdev ) : KDialogBase( Amarok::mainWindow(), "transferdialog", true, TQString(), Ok|Cancel, Ok ) { m_dev = mdev; m_accepted = false; m_sort1LastIndex = m_sort2LastIndex = -1; kapp->setTopWidget( this ); setCaption( kapp->makeStdCaption( i18n( "Transfer Queue to Device" ) ) ); TQVBox* vbox = makeVBoxMainWidget(); vbox->setSpacing( KDialog::spacingHint() ); TQString transferDir = mdev->getTransferDir(); TQGroupBox *location = new TQGroupBox( 1, Qt::Vertical, i18n( "Music Location" ), vbox ); new TQLabel( i18n( "Your music will be transferred to:\n%1" ) .arg( transferDir ), location ); TQVBox *vbox2 = new TQVBox( vbox ); TQSpacerItem *spacer = new TQSpacerItem( 0, 25 ); TQLayout *vlayout = vbox2->layout(); if( vlayout ) vlayout->addItem( spacer ); new TQLabel( i18n( "You can have your music automatically grouped in\n" "a variety of ways. Each grouping will create\n" "directories based upon the specified criteria.\n"), vbox ); TQGroupBox *sorting = new TQGroupBox( 6, Qt::Vertical, i18n( "Groupings" ), vbox ); m_label1 = new TQLabel( i18n( "Select first grouping:\n" ), sorting ); m_sort1 = new KComboBox( sorting ); m_label2 = new TQLabel( i18n( "Select second grouping:\n" ), sorting ); m_sort2 = new KComboBox( sorting ); m_label3 = new TQLabel( i18n( "Select third grouping:\n" ), sorting ); m_sort3 = new KComboBox( sorting ); m_combolist = new TQPtrList(); m_combolist->append( m_sort1 ); m_combolist->append( m_sort2 ); m_combolist->append( m_sort3 ); KComboBox * comboTemp; for( comboTemp = m_combolist->first(); comboTemp; comboTemp = m_combolist->next() ) { comboTemp->insertItem( i18n("None") ); comboTemp->insertItem( i18n("Artist") ); comboTemp->insertItem( i18n("Album") ); comboTemp->insertItem( i18n("Genre") ); comboTemp->setCurrentItem( 0 ); } m_sort1->setCurrentItem( mdev->m_firstSort ); m_sort2->setCurrentItem( mdev->m_secondSort ); m_sort3->setCurrentItem( mdev->m_thirdSort ); m_label2->setDisabled( m_sort1->currentItem() == 0 ); m_sort2->setDisabled( m_sort1->currentItem() == 0 ); m_label3->setDisabled( m_sort2->currentItem() == 0 ); m_sort3->setDisabled( m_sort2->currentItem() == 0 ); connect( m_sort1, TQT_SIGNAL( activated(int) ), TQT_SLOT( sort1_activated(int)) ); connect( m_sort2, TQT_SIGNAL( activated(int) ), TQT_SLOT( sort2_activated(int)) ); TQVBox *vbox3 = new TQVBox( vbox ); TQSpacerItem *spacer2 = new TQSpacerItem( 0, 25 ); TQLayout *vlayout2 = vbox3->layout(); if( vlayout2 ) vlayout2->addItem( spacer2 ); TQGroupBox *options = new TQGroupBox( 6, Qt::Vertical, i18n( "Options" ), vbox ); TQCheckBox *convertSpaces = new TQCheckBox( i18n( "Convert spaces to underscores" ), options ); convertSpaces->setChecked( mdev->getSpacesToUnderscores() ); connect( convertSpaces, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( convertSpaces_toggled(bool) ) ); } void TransferDialog::slotOk() { m_accepted = true; KDialogBase::slotOk(); m_dev->setFirstSort( m_sort1->currentText() ); m_dev->setSecondSort( m_sort2->currentText() ); m_dev->setThirdSort( m_sort3->currentText() ); } void TransferDialog::slotCancel() { m_accepted = false; KDialogBase::slotCancel(); } void TransferDialog::sort1_activated( int index ) { //sort3 if( m_sort2LastIndex > 0 ) m_sort3->insertItem( m_sort2->text( m_sort2LastIndex ), m_sort2LastIndex ); if( m_sort1LastIndex > 0 ) m_sort3->insertItem( m_sort1->text( m_sort1LastIndex ), m_sort1LastIndex ); if( index > 0 ) m_sort3->removeItem( index ); m_sort3->setCurrentItem( 0 ); m_sort3->setDisabled( true ); //sort2 if( m_sort1LastIndex > 0 ) m_sort2->insertItem( m_sort1->text( m_sort1LastIndex ), m_sort1LastIndex ); if( index > 0 ) m_sort2->removeItem( index ); m_sort2->setCurrentItem( 0 ); if( index == 0 ) m_sort2->setDisabled( true ); else m_sort2->setDisabled( false ); m_sort2LastIndex = 0; m_sort1LastIndex = index; } void TransferDialog::sort2_activated( int index ) { //sort3 if( m_sort2LastIndex > 0 ) m_sort3->insertItem( m_sort2->text( m_sort2LastIndex ), m_sort2LastIndex ); if( index > 0 ) m_sort3->removeItem( index ); m_sort3->setCurrentItem( 0 ); if( index == 0 ) m_sort3->setDisabled( true ); else m_sort3->setDisabled( false ); m_sort2LastIndex = index; } void TransferDialog::convertSpaces_toggled( bool on ) { m_dev->setSpacesToUnderscores( on ); } #include "transferdialog.moc"