summaryrefslogtreecommitdiffstats
path: root/amarok/src/transferdialog.cpp
blob: 499fa0a2b31b904d5bce99b421c9e46fbb2bdb41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//
// C++ Implementation: transferdialog
//
// Description:
//
//
// Author: Jeff Mitchell <kde-dev@emailgoeshere.com>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "amarok.h"
#include "debug.h"
#include "mediabrowser.h"
#include "transferdialog.h"

#include <tqcheckbox.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqvbox.h>

#include <tdeapplication.h>
#include <kcombobox.h>
#include <tdeconfig.h>
#include <klineedit.h>
#include <tdelocale.h>
#include <kpushbutton.h>

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<KComboBox>();
    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"