Revert previous commit, was incorrect
[amarok.git] / src / transferdialog.cpp
bloba35c1c39a5a5f7b42070ddf1a05e93df3bdce7f1
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"
18 #include "MediaDevice.h"
20 #include <KApplication>
21 #include <KComboBox>
22 #include <KConfig>
23 #include <KLineEdit>
24 #include <KLocale>
25 #include <KPushButton>
26 #include <KVBox>
28 #include <QCheckBox>
29 #include <q3groupbox.h>
30 #include <QLabel>
31 #include <QLayout>
32 #include <Q3PtrList>
35 TransferDialog::TransferDialog( MediaDevice *mdev )
36 : KDialog( Amarok::mainWindow() )
38 setModal( true );
39 setButtons( Ok|Cancel );
40 setDefaultButton( Ok );
41 showButtonSeparator( true );
43 m_dev = mdev;
44 m_accepted = false;
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();
62 if( vlayout )
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();
106 if( vlayout2 )
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()));
119 void
120 TransferDialog::slotOk()
122 m_accepted = true;
123 //KDialog::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() );
131 void
132 TransferDialog::slotCancel()
134 m_accepted = false;
135 //KDialog::slotCancel();
136 slotButtonClicked( Cancel );
139 void
140 TransferDialog::sort1_activated( int index )
142 //sort3
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 );
147 if( index > 0 )
148 m_sort3->removeItem( index );
149 m_sort3->setCurrentItem( 0 );
150 m_sort3->setDisabled( true );
151 //sort2
152 if( m_sort1LastIndex > 0 )
153 m_sort2->addItem( m_sort1->itemText( m_sort1LastIndex ), m_sort1LastIndex );
154 if( index > 0 )
155 m_sort2->removeItem( index );
156 m_sort2->setCurrentItem( 0 );
157 if( index == 0 )
158 m_sort2->setDisabled( true );
159 else
160 m_sort2->setDisabled( false );
162 m_sort2LastIndex = 0;
163 m_sort1LastIndex = index;
166 void
167 TransferDialog::sort2_activated( int index )
169 //sort3
170 if( m_sort2LastIndex > 0 )
171 m_sort3->addItem( m_sort2->itemText( m_sort2LastIndex ), m_sort2LastIndex );
172 if( index > 0 )
173 m_sort3->removeItem( index );
174 m_sort3->setCurrentItem( 0 );
175 if( index == 0 )
176 m_sort3->setDisabled( true );
177 else
178 m_sort3->setDisabled( false );
180 m_sort2LastIndex = index;
183 void
184 TransferDialog::convertSpaces_toggled( bool on )
186 m_dev->setSpacesToUnderscores( on );
189 #include "transferdialog.moc"