2 // C++ Implementation: transferdialog
7 // Author: Jeff Mitchell <kde-dev@emailgoeshere.com>, (C) 2005
9 // Copyright: See COPYING file that comes with this distribution
13 #include "transferdialog.h"
17 #include "mediabrowser.h"
18 #include "MediaDevice.h"
20 #include <KApplication>
25 #include <KPushButton>
29 #include <q3groupbox.h>
35 TransferDialog::TransferDialog( MediaDevice
*mdev
)
36 : KDialog( Amarok::mainWindow() )
39 setButtons( Ok
|Cancel
);
40 setDefaultButton( Ok
);
41 showButtonSeparator( true );
45 m_sort1LastIndex
= m_sort2LastIndex
= -1;
47 kapp
->setTopWidget( this );
48 setCaption( KDialog::makeStandardCaption( i18n( "Transfer Queue to Device" ) ) );
50 KVBox
*vbox
= new KVBox( this );
51 setMainWidget( vbox
);
53 QString transferDir
= mdev
->getTransferDir();
55 Q3GroupBox
*location
= new Q3GroupBox( 1, Qt::Vertical
, i18n( "Music Location" ), vbox
);
57 new QLabel( i18n( "Your music will be transferred to:\n%1" )
58 .arg( transferDir
), location
);
60 KVBox
*vbox2
= new KVBox( vbox
);
61 QLayout
*vlayout
= vbox2
->layout();
63 vlayout
->addItem( new QSpacerItem( 0, 25 ) );
65 new QLabel( i18n( "You can have your music automatically grouped in\n"
66 "a variety of ways. Each grouping will create\n"
67 "directories based upon the specified criteria.\n"), vbox
);
69 Q3GroupBox
*sorting
= new Q3GroupBox( 6, Qt::Vertical
, i18n( "Groupings" ), vbox
);
70 m_label1
= new QLabel( i18n( "Select first grouping:\n" ), sorting
);
71 m_sort1
= new KComboBox( sorting
);
72 m_label2
= new QLabel( i18n( "Select second grouping:\n" ), sorting
);
73 m_sort2
= new KComboBox( sorting
);
74 m_label3
= new QLabel( i18n( "Select third grouping:\n" ), sorting
);
75 m_sort3
= new KComboBox( sorting
);
77 m_combolist
= new Q3PtrList
<KComboBox
>();
78 m_combolist
->append( m_sort1
);
79 m_combolist
->append( m_sort2
);
80 m_combolist
->append( m_sort3
);
82 KComboBox
* comboTemp
;
83 for( comboTemp
= m_combolist
->first(); comboTemp
; comboTemp
= m_combolist
->next() )
85 comboTemp
->addItem( i18n("None") );
86 comboTemp
->addItem( i18n("Artist") );
87 comboTemp
->addItem( i18n("Album") );
88 comboTemp
->addItem( i18n("Genre") );
89 comboTemp
->setCurrentItem( 0 );
92 m_sort1
->setCurrentItem( mdev
->m_firstSort
);
93 m_sort2
->setCurrentItem( mdev
->m_secondSort
);
94 m_sort3
->setCurrentItem( mdev
->m_thirdSort
);
96 m_label2
->setDisabled( m_sort1
->currentIndex() == 0 );
97 m_sort2
->setDisabled( m_sort1
->currentIndex() == 0 );
98 m_label3
->setDisabled( m_sort2
->currentIndex() == 0 );
99 m_sort3
->setDisabled( m_sort2
->currentIndex() == 0 );
101 connect( m_sort1
, SIGNAL( activated(int) ), SLOT( sort1_activated(int)) );
102 connect( m_sort2
, SIGNAL( activated(int) ), SLOT( sort2_activated(int)) );
104 KVBox
*vbox3
= new KVBox( vbox
);
105 QLayout
*vlayout2
= vbox3
->layout();
107 vlayout2
->addItem( new QSpacerItem( 0, 25 ) );
109 Q3GroupBox
*options
= new Q3GroupBox( 6, Qt::Vertical
, i18n( "Options" ), vbox
);
111 QCheckBox
*convertSpaces
= new QCheckBox( i18n( "Convert spaces to underscores" ), options
);
112 convertSpaces
->setChecked( mdev
->getSpacesToUnderscores() );
114 connect( convertSpaces
, SIGNAL( toggled(bool) ), this, SLOT( convertSpaces_toggled(bool) ) );
115 connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
116 connect(this,SIGNAL(cancelClicked()),this,SLOT(slotCancel()));
120 TransferDialog::slotOk()
124 slotButtonClicked( Ok
);
126 m_dev
->setFirstSort( m_sort1
->currentText() );
127 m_dev
->setSecondSort( m_sort2
->currentText() );
128 m_dev
->setThirdSort( m_sort3
->currentText() );
132 TransferDialog::slotCancel()
135 //KDialog::slotCancel();
136 slotButtonClicked( Cancel
);
140 TransferDialog::sort1_activated( int index
)
143 if( m_sort2LastIndex
> 0 )
144 m_sort3
->addItem( m_sort2
->itemText( m_sort2LastIndex
), m_sort2LastIndex
);
145 if( m_sort1LastIndex
> 0 )
146 m_sort3
->addItem( m_sort1
->itemText( m_sort1LastIndex
), m_sort1LastIndex
);
148 m_sort3
->removeItem( index
);
149 m_sort3
->setCurrentItem( 0 );
150 m_sort3
->setDisabled( true );
152 if( m_sort1LastIndex
> 0 )
153 m_sort2
->addItem( m_sort1
->itemText( m_sort1LastIndex
), m_sort1LastIndex
);
155 m_sort2
->removeItem( index
);
156 m_sort2
->setCurrentItem( 0 );
158 m_sort2
->setDisabled( true );
160 m_sort2
->setDisabled( false );
162 m_sort2LastIndex
= 0;
163 m_sort1LastIndex
= index
;
167 TransferDialog::sort2_activated( int index
)
170 if( m_sort2LastIndex
> 0 )
171 m_sort3
->addItem( m_sort2
->itemText( m_sort2LastIndex
), m_sort2LastIndex
);
173 m_sort3
->removeItem( index
);
174 m_sort3
->setCurrentItem( 0 );
176 m_sort3
->setDisabled( true );
178 m_sort3
->setDisabled( false );
180 m_sort2LastIndex
= index
;
184 TransferDialog::convertSpaces_toggled( bool on
)
186 m_dev
->setSpacesToUnderscores( on
);
189 #include "transferdialog.moc"