Make the ServiceListDelegate use less handcoded values and more general variables...
[amarok.git] / src / transferdialog.cpp
blob44344fd3dff4ba045433d81c8821d8f79415867c
1 //
2 // C++ Implementation: transferdialog
3 //
4 // Description:
5 //
6 //
7 // Author: Jeff Mitchell <kde-dev@emailgoeshere.com>, (C) 2005
8 //
9 // Copyright: See COPYING file that comes with this distribution
13 #include "transferdialog.h"
15 #include "amarok.h"
16 #include "debug.h"
17 #include "mediabrowser.h"
19 #include <KApplication>
20 #include <KComboBox>
21 #include <KConfig>
22 #include <KLineEdit>
23 #include <KLocale>
24 #include <KPushButton>
25 #include <KVBox>
27 #include <QCheckBox>
28 #include <q3groupbox.h>
29 #include <QLabel>
30 #include <QLayout>
31 #include <Q3PtrList>
34 TransferDialog::TransferDialog( MediaDevice *mdev )
35 : KDialog( Amarok::mainWindow() )
37 setModal( true );
38 setButtons( Ok|Cancel );
39 setDefaultButton( Ok );
40 showButtonSeparator( true );
42 m_dev = mdev;
43 m_accepted = false;
44 m_sort1LastIndex = m_sort2LastIndex = -1;
46 kapp->setTopWidget( this );
47 setCaption( KDialog::makeStandardCaption( i18n( "Transfer Queue to Device" ) ) );
49 KVBox *vbox = new KVBox( this );
50 setMainWidget( vbox );
52 QString transferDir = mdev->getTransferDir();
54 Q3GroupBox *location = new Q3GroupBox( 1, Qt::Vertical, i18n( "Music Location" ), vbox );
56 new QLabel( i18n( "Your music will be transferred to:\n%1" )
57 .arg( transferDir ), location );
59 KVBox *vbox2 = new KVBox( vbox );
60 QLayout *vlayout = vbox2->layout();
61 if( vlayout )
62 vlayout->addItem( new QSpacerItem( 0, 25 ) );
64 new QLabel( i18n( "You can have your music automatically grouped in\n"
65 "a variety of ways. Each grouping will create\n"
66 "directories based upon the specified criteria.\n"), vbox );
68 Q3GroupBox *sorting = new Q3GroupBox( 6, Qt::Vertical, i18n( "Groupings" ), vbox );
69 m_label1 = new QLabel( i18n( "Select first grouping:\n" ), sorting );
70 m_sort1 = new KComboBox( sorting );
71 m_label2 = new QLabel( i18n( "Select second grouping:\n" ), sorting );
72 m_sort2 = new KComboBox( sorting );
73 m_label3 = new QLabel( i18n( "Select third grouping:\n" ), sorting );
74 m_sort3 = new KComboBox( sorting );
76 m_combolist = new Q3PtrList<KComboBox>();
77 m_combolist->append( m_sort1 );
78 m_combolist->append( m_sort2 );
79 m_combolist->append( m_sort3 );
81 KComboBox * comboTemp;
82 for( comboTemp = m_combolist->first(); comboTemp; comboTemp = m_combolist->next() )
84 comboTemp->addItem( i18n("None") );
85 comboTemp->addItem( i18n("Artist") );
86 comboTemp->addItem( i18n("Album") );
87 comboTemp->addItem( i18n("Genre") );
88 comboTemp->setCurrentItem( 0 );
91 m_sort1->setCurrentItem( mdev->m_firstSort );
92 m_sort2->setCurrentItem( mdev->m_secondSort );
93 m_sort3->setCurrentItem( mdev->m_thirdSort );
95 m_label2->setDisabled( m_sort1->currentIndex() == 0 );
96 m_sort2->setDisabled( m_sort1->currentIndex() == 0 );
97 m_label3->setDisabled( m_sort2->currentIndex() == 0 );
98 m_sort3->setDisabled( m_sort2->currentIndex() == 0 );
100 connect( m_sort1, SIGNAL( activated(int) ), SLOT( sort1_activated(int)) );
101 connect( m_sort2, SIGNAL( activated(int) ), SLOT( sort2_activated(int)) );
103 KVBox *vbox3 = new KVBox( vbox );
104 QLayout *vlayout2 = vbox3->layout();
105 if( vlayout2 )
106 vlayout2->addItem( new QSpacerItem( 0, 25 ) );
108 Q3GroupBox *options = new Q3GroupBox( 6, Qt::Vertical, i18n( "Options" ), vbox );
110 QCheckBox *convertSpaces = new QCheckBox( i18n( "Convert spaces to underscores" ), options );
111 convertSpaces->setChecked( mdev->getSpacesToUnderscores() );
113 connect( convertSpaces, SIGNAL( toggled(bool) ), this, SLOT( convertSpaces_toggled(bool) ) );
114 connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
115 connect(this,SIGNAL(cancelClicked()),this,SLOT(slotCancel()));
118 void
119 TransferDialog::slotOk()
121 m_accepted = true;
122 //KDialog::slotOk();
123 slotButtonClicked( Ok );
125 m_dev->setFirstSort( m_sort1->currentText() );
126 m_dev->setSecondSort( m_sort2->currentText() );
127 m_dev->setThirdSort( m_sort3->currentText() );
130 void
131 TransferDialog::slotCancel()
133 m_accepted = false;
134 //KDialog::slotCancel();
135 slotButtonClicked( Cancel );
138 void
139 TransferDialog::sort1_activated( int index )
141 //sort3
142 if( m_sort2LastIndex > 0 )
143 m_sort3->addItem( m_sort2->itemText( m_sort2LastIndex ), m_sort2LastIndex );
144 if( m_sort1LastIndex > 0 )
145 m_sort3->addItem( m_sort1->itemText( m_sort1LastIndex ), m_sort1LastIndex );
146 if( index > 0 )
147 m_sort3->removeItem( index );
148 m_sort3->setCurrentItem( 0 );
149 m_sort3->setDisabled( true );
150 //sort2
151 if( m_sort1LastIndex > 0 )
152 m_sort2->addItem( m_sort1->itemText( m_sort1LastIndex ), m_sort1LastIndex );
153 if( index > 0 )
154 m_sort2->removeItem( index );
155 m_sort2->setCurrentItem( 0 );
156 if( index == 0 )
157 m_sort2->setDisabled( true );
158 else
159 m_sort2->setDisabled( false );
161 m_sort2LastIndex = 0;
162 m_sort1LastIndex = index;
165 void
166 TransferDialog::sort2_activated( int index )
168 //sort3
169 if( m_sort2LastIndex > 0 )
170 m_sort3->addItem( m_sort2->itemText( m_sort2LastIndex ), m_sort2LastIndex );
171 if( index > 0 )
172 m_sort3->removeItem( index );
173 m_sort3->setCurrentItem( 0 );
174 if( index == 0 )
175 m_sort3->setDisabled( true );
176 else
177 m_sort3->setDisabled( false );
179 m_sort2LastIndex = index;
182 void
183 TransferDialog::convertSpaces_toggled( bool on )
185 m_dev->setSpacesToUnderscores( on );
188 #include "transferdialog.moc"