1 /***************************************************************************
3 copyright : (C) 2003 - 2004 by Scott Wheeler
4 email : wheeler@kde.org
5 ***************************************************************************/
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
16 #include "config-amarok.h"
20 #include "trackpickerdialog.h"
21 #include "trackpickerdialogbase.h"
23 #include <KApplication>
24 #include <k3listview.h>
31 #define NUMBER(x) (x == 0 ? QString::null : QString::number(x))
33 class TrackPickerItem
: public K3ListViewItem
36 TrackPickerItem(K3ListView
*parent
, const KTRMResult
&result
) :
37 K3ListViewItem(parent
, parent
->lastChild(),
38 result
.title(), result
.artist(), result
.album(),
39 NUMBER(result
.track()), NUMBER(result
.year())),
42 //if(result.year() == QString::empty()) year = "xx";
43 //else year = result.year();
46 KTRMResult
result() const { return m_result
; }
52 ////////////////////////////////////////////////////////////////////////////////
54 ////////////////////////////////////////////////////////////////////////////////
56 TrackPickerDialog::TrackPickerDialog(const QString
&name
, const KTRMResultList
&results
, QWidget
*parent
)
59 setObjectName( name
.toLatin1() );
61 setButtons( Ok
| Cancel
);
62 setDefaultButton( Ok
);
63 showButtonSeparator( true );
65 kapp
->setTopWidget( this );
66 setCaption( KDialog::makeStandardCaption( i18n("MusicBrainz Results") ) );
68 m_base
= new TrackPickerDialogBase(this);
69 setMainWidget(m_base
);
70 //setSorting with a column that doesn't exist means manual sorting only
71 m_base
->trackList
->setSorting( 5 );
73 #if HAVE_TUNEPIMP >= 5
74 //remove year column, there won't be any results anyway
75 m_base
->trackList
->removeColumn( 4 );
78 m_base
->fileLabel
->setText(name
);
79 KTRMResultList::ConstIterator
end( results
.end() );
80 for(KTRMResultList::ConstIterator it
= results
.begin(); it
!= end
; ++it
)
81 new TrackPickerItem(m_base
->trackList
, *it
);
82 // for( int j = 0; j < 5; j++ ) {
83 // m_base->trackList->adjustColumn( j );
84 // //resultTable->setColumnStretchable(j,true);
86 m_base
->trackList
->setSelected(m_base
->trackList
->firstChild(), true);
87 // m_base->trackList->triggerUpdate();
88 setMinimumWidth(qMax(300, width()));
89 connect(this, SIGNAL( sigSelectionMade( KTRMResult
) ), parent
, SLOT( fillSelected( KTRMResult
) ) );
95 TrackPickerDialog::result() const
97 if(m_base
->trackList
->selectedItem())
98 return static_cast<TrackPickerItem
*>(m_base
->trackList
->selectedItem())->result();
105 TrackPickerDialog::accept()
107 emit
sigSelectionMade( result() );
112 #include "trackpickerdialog.moc"
114 #endif // HAVE_TUNEPIMP