add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / trackpickerdialog.cpp
blobb61681de20fb298b6e0413efcf2e748a7ad49b96
1 /***************************************************************************
2 begin : Sat Sep 6 2003
3 copyright : (C) 2003 - 2004 by Scott Wheeler
4 email : wheeler@kde.org
5 ***************************************************************************/
7 /***************************************************************************
8 * *
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. *
13 * *
14 ***************************************************************************/
16 #include "config-amarok.h"
18 #if HAVE_TUNEPIMP
20 #include "trackpickerdialog.h"
21 #include "trackpickerdialogbase.h"
23 #include <KApplication>
24 #include <k3listview.h>
25 #include <KLocale>
27 #include <QLabel>
31 #define NUMBER(x) (x == 0 ? QString::null : QString::number(x))
33 class TrackPickerItem : public K3ListViewItem
35 public:
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())),
40 m_result(result) {
41 //QString year;
42 //if(result.year() == QString::empty()) year = "xx";
43 //else year = result.year();
44 //setText(5,"xx");
46 KTRMResult result() const { return m_result; }
48 private:
49 KTRMResult m_result;
52 ////////////////////////////////////////////////////////////////////////////////
53 // public methods
54 ////////////////////////////////////////////////////////////////////////////////
56 TrackPickerDialog::TrackPickerDialog(const QString &name, const KTRMResultList &results, QWidget *parent)
57 : KDialog(parent)
59 setObjectName( name.toLatin1() );
60 setModal( true );
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 );
76 #endif
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);
85 // }
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 ) ) );
94 KTRMResult
95 TrackPickerDialog::result() const
97 if(m_base->trackList->selectedItem())
98 return static_cast<TrackPickerItem *>(m_base->trackList->selectedItem())->result();
99 else
100 return KTRMResult();
104 void
105 TrackPickerDialog::accept()
107 emit sigSelectionMade( result() );
108 KDialog::accept();
112 #include "trackpickerdialog.moc"
114 #endif // HAVE_TUNEPIMP